| author | |
| committer | |
| log | 1c8f0b8909f342201f84def1efb8c6fb4386cc2c |
| tree | b58a1488ff85440a65565474627add3fdc66b32e |
| parent | d13bc04cb4c4c2f0806b9d9c676cb013ea888828 |
* Moved the tz.cpp patch to experimental/tzdb.cpp.
* Extended the __config_site patch to a few more files.677 files changed, 21356 insertions(+), 16160 deletions(-)
lib/libcxx/include/__algorithm/adjacent_find.h+3-3| ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _Iter, class _Sent, class _BinaryPredicate> | 28 | template <class _Iter, class _Sent, class _BinaryPredicate> |
| 29 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter | 29 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter |
| 30 | __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | 30 | __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 31 | if (__first == __last) | 31 | if (__first == __last) |
| 32 | return __first; | 32 | return __first; |
| ... | @@ -40,13 +40,13 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | ... | @@ -40,13 +40,13 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | template <class _ForwardIterator, class _BinaryPredicate> | 42 | template <class _ForwardIterator, class _BinaryPredicate> |
| 43 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 43 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 44 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { | 44 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { |
| 45 | return std::__adjacent_find(std::move(__first), std::move(__last), __pred); | 45 | return std::__adjacent_find(std::move(__first), std::move(__last), __pred); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | template <class _ForwardIterator> | 48 | template <class _ForwardIterator> |
| 49 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 49 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 50 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { | 50 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { |
| 51 | return std::adjacent_find(std::move(__first), std::move(__last), __equal_to()); | 51 | return std::adjacent_find(std::move(__first), std::move(__last), __equal_to()); |
| 52 | } | 52 | } |
lib/libcxx/include/__algorithm/all_of.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 _InputIterator, class _Predicate> | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 23 | all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 23 | all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | for (; __first != __last; ++__first) | 24 | for (; __first != __last; ++__first) |
| 25 | if (!__pred(*__first)) | 25 | if (!__pred(*__first)) |
lib/libcxx/include/__algorithm/any_of.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 _InputIterator, class _Predicate> | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 23 | any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 23 | any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | for (; __first != __last; ++__first) | 24 | for (; __first != __last; ++__first) |
| 25 | if (__pred(*__first)) | 25 | if (__pred(*__first)) |
lib/libcxx/include/__algorithm/binary_search.h+2-2| ... | @@ -22,14 +22,14 @@ | ... | @@ -22,14 +22,14 @@ |
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | template <class _ForwardIterator, class _Tp, class _Compare> | 24 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 25 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 25 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 26 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | 26 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 27 | __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp); | 27 | __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp); |
| 28 | return __first != __last && !__comp(__value, *__first); | 28 | return __first != __last && !__comp(__value, *__first); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | template <class _ForwardIterator, class _Tp> | 31 | template <class _ForwardIterator, class _Tp> |
| 32 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 32 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 33 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 33 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 34 | return std::binary_search(__first, __last, __value, __less<>()); | 34 | return std::binary_search(__first, __last, __value, __less<>()); |
| 35 | } | 35 | } |
lib/libcxx/include/__algorithm/clamp.h+2-2| ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 17 | 22 | #if _LIBCPP_STD_VER >= 17 |
| 23 | template <class _Tp, class _Compare> | 23 | template <class _Tp, class _Compare> |
| 24 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& | 24 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& |
| 25 | clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, | 25 | clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, |
| 26 | _LIBCPP_LIFETIMEBOUND const _Tp& __lo, | 26 | _LIBCPP_LIFETIMEBOUND const _Tp& __lo, |
| 27 | _LIBCPP_LIFETIMEBOUND const _Tp& __hi, | 27 | _LIBCPP_LIFETIMEBOUND const _Tp& __hi, |
| ... | @@ -31,7 +31,7 @@ clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, | ... | @@ -31,7 +31,7 @@ clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | template <class _Tp> | 33 | template <class _Tp> |
| 34 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& | 34 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& |
| 35 | clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, | 35 | clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, |
| 36 | _LIBCPP_LIFETIMEBOUND const _Tp& __lo, | 36 | _LIBCPP_LIFETIMEBOUND const _Tp& __lo, |
| 37 | _LIBCPP_LIFETIMEBOUND const _Tp& __hi) { | 37 | _LIBCPP_LIFETIMEBOUND const _Tp& __hi) { |
lib/libcxx/include/__algorithm/comp.h+5-3| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___ALGORITHM_COMP_H | 10 | #define _LIBCPP___ALGORITHM_COMP_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/desugars_to.h> |
| 14 | #include <__type_traits/operation_traits.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 |
| ... | @@ -27,7 +26,7 @@ struct __equal_to { | ... | @@ -27,7 +26,7 @@ struct __equal_to { |
| 27 | }; | 26 | }; |
| 28 | 27 | ||
| 29 | template <class _Tp, class _Up> | 28 | template <class _Tp, class _Up> |
| 30 | struct __desugars_to<__equal_tag, __equal_to, _Tp, _Up> : true_type {}; | 29 | inline const bool __desugars_to_v<__equal_tag, __equal_to, _Tp, _Up> = true; |
| 31 | 30 | ||
| 32 | // The definition is required because __less is part of the ABI, but it's empty | 31 | // The definition is required because __less is part of the ABI, but it's empty |
| 33 | // because all comparisons should be transparent. | 32 | // because all comparisons should be transparent. |
| ... | @@ -42,6 +41,9 @@ struct __less<void, void> { | ... | @@ -42,6 +41,9 @@ struct __less<void, void> { |
| 42 | } | 41 | } |
| 43 | }; | 42 | }; |
| 44 | 43 | ||
| 44 | template <class _Tp> | ||
| 45 | inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true; | ||
| 46 | |||
| 45 | _LIBCPP_END_NAMESPACE_STD | 47 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 48 | ||
| 47 | #endif // _LIBCPP___ALGORITHM_COMP_H | 49 | #endif // _LIBCPP___ALGORITHM_COMP_H |
lib/libcxx/include/__algorithm/comp_ref_type.h+3-3| ... | @@ -41,9 +41,9 @@ struct __debug_less { | ... | @@ -41,9 +41,9 @@ struct __debug_less { |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | template <class _LHS, class _RHS> | 43 | template <class _LHS, class _RHS> |
| 44 | _LIBCPP_CONSTEXPR_SINCE_CXX14 inline _LIBCPP_HIDE_FROM_ABI decltype((void)std::declval<_Compare&>()( | 44 | _LIBCPP_CONSTEXPR_SINCE_CXX14 inline |
| 45 | std::declval<_LHS&>(), std::declval<_RHS&>())) | 45 | _LIBCPP_HIDE_FROM_ABI decltype((void)std::declval<_Compare&>()(std::declval<_LHS&>(), std::declval<_RHS&>())) |
| 46 | __do_compare_assert(int, _LHS& __l, _RHS& __r) { | 46 | __do_compare_assert(int, _LHS& __l, _RHS& __r) { |
| 47 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering"); | 47 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering"); |
| 48 | (void)__l; | 48 | (void)__l; |
| 49 | (void)__r; | 49 | (void)__r; |
lib/libcxx/include/__algorithm/copy.h+2-4| ... | @@ -32,7 +32,7 @@ template <class, class _InIter, class _Sent, class _OutIter> | ... | @@ -32,7 +32,7 @@ template <class, class _InIter, class _Sent, class _OutIter> |
| 32 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); | 32 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); |
| 33 | 33 | ||
| 34 | template <class _AlgPolicy> | 34 | template <class _AlgPolicy> |
| 35 | struct __copy_loop { | 35 | struct __copy_impl { |
| 36 | template <class _InIter, class _Sent, class _OutIter> | 36 | template <class _InIter, class _Sent, class _OutIter> |
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 38 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { | 38 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { |
| ... | @@ -94,9 +94,7 @@ struct __copy_loop { | ... | @@ -94,9 +94,7 @@ struct __copy_loop { |
| 94 | __local_first = _Traits::__begin(++__segment_iterator); | 94 | __local_first = _Traits::__begin(++__segment_iterator); |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | }; | ||
| 98 | 97 | ||
| 99 | struct __copy_trivial { | ||
| 100 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 98 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. |
| 101 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> | 99 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> |
| 102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
| ... | @@ -108,7 +106,7 @@ struct __copy_trivial { | ... | @@ -108,7 +106,7 @@ struct __copy_trivial { |
| 108 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> | 106 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> |
| 109 | pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 107 | pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 110 | __copy(_InIter __first, _Sent __last, _OutIter __result) { | 108 | __copy(_InIter __first, _Sent __last, _OutIter __result) { |
| 111 | return std::__dispatch_copy_or_move<_AlgPolicy, __copy_loop<_AlgPolicy>, __copy_trivial>( | 109 | return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >( |
| 112 | std::move(__first), std::move(__last), std::move(__result)); | 110 | std::move(__first), std::move(__last), std::move(__result)); |
| 113 | } | 111 | } |
| 114 | 112 |
lib/libcxx/include/__algorithm/copy_backward.h+3-5| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__iterator/segmented_iterator.h> | 16 | #include <__iterator/segmented_iterator.h> |
| 17 | #include <__type_traits/common_type.h> | 17 | #include <__type_traits/common_type.h> |
| 18 | #include <__type_traits/is_copy_constructible.h> | 18 | #include <__type_traits/is_constructible.h> |
| 19 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| 20 | #include <__utility/pair.h> | 20 | #include <__utility/pair.h> |
| 21 | 21 | ||
| ... | @@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> | ... | @@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> |
| 33 | __copy_backward(_InIter __first, _Sent __last, _OutIter __result); | 33 | __copy_backward(_InIter __first, _Sent __last, _OutIter __result); |
| 34 | 34 | ||
| 35 | template <class _AlgPolicy> | 35 | template <class _AlgPolicy> |
| 36 | struct __copy_backward_loop { | 36 | struct __copy_backward_impl { |
| 37 | template <class _InIter, class _Sent, class _OutIter> | 37 | template <class _InIter, class _Sent, class _OutIter> |
| 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 39 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { | 39 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { |
| ... | @@ -104,9 +104,7 @@ struct __copy_backward_loop { | ... | @@ -104,9 +104,7 @@ struct __copy_backward_loop { |
| 104 | __local_last = _Traits::__end(__segment_iterator); | 104 | __local_last = _Traits::__end(__segment_iterator); |
| 105 | } | 105 | } |
| 106 | } | 106 | } |
| 107 | }; | ||
| 108 | 107 | ||
| 109 | struct __copy_backward_trivial { | ||
| 110 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 108 | // 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> | 109 | 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*> | 110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
| ... | @@ -118,7 +116,7 @@ struct __copy_backward_trivial { | ... | @@ -118,7 +116,7 @@ struct __copy_backward_trivial { |
| 118 | template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2> | 116 | template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2> |
| 119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2> | 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2> |
| 120 | __copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) { | 118 | __copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) { |
| 121 | return std::__dispatch_copy_or_move<_AlgPolicy, __copy_backward_loop<_AlgPolicy>, __copy_backward_trivial>( | 119 | return std::__copy_move_unwrap_iters<__copy_backward_impl<_AlgPolicy> >( |
| 122 | std::move(__first), std::move(__last), std::move(__result)); | 120 | std::move(__first), std::move(__last), std::move(__result)); |
| 123 | } | 121 | } |
| 124 | 122 |
lib/libcxx/include/__algorithm/copy_move_common.h+8-34| ... | @@ -19,9 +19,8 @@ | ... | @@ -19,9 +19,8 @@ |
| 19 | #include <__type_traits/enable_if.h> | 19 | #include <__type_traits/enable_if.h> |
| 20 | #include <__type_traits/is_always_bitcastable.h> | 20 | #include <__type_traits/is_always_bitcastable.h> |
| 21 | #include <__type_traits/is_constant_evaluated.h> | 21 | #include <__type_traits/is_constant_evaluated.h> |
| 22 | #include <__type_traits/is_copy_constructible.h> | 22 | #include <__type_traits/is_constructible.h> |
| 23 | #include <__type_traits/is_trivially_assignable.h> | 23 | #include <__type_traits/is_trivially_assignable.h> |
| 24 | #include <__type_traits/is_trivially_copyable.h> | ||
| 25 | #include <__type_traits/is_volatile.h> | 24 | #include <__type_traits/is_volatile.h> |
| 26 | #include <__utility/move.h> | 25 | #include <__utility/move.h> |
| 27 | #include <__utility/pair.h> | 26 | #include <__utility/pair.h> |
| ... | @@ -81,30 +80,17 @@ __copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) { | ... | @@ -81,30 +80,17 @@ __copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) { |
| 81 | 80 | ||
| 82 | // Iterator unwrapping and dispatching to the correct overload. | 81 | // Iterator unwrapping and dispatching to the correct overload. |
| 83 | 82 | ||
| 84 | template <class _F1, class _F2> | 83 | template <class _InIter, class _OutIter> |
| 85 | struct __overload : _F1, _F2 { | 84 | struct __can_rewrap |
| 86 | using _F1::operator(); | 85 | : integral_constant<bool, is_copy_constructible<_InIter>::value && is_copy_constructible<_OutIter>::value> {}; |
| 87 | using _F2::operator(); | ||
| 88 | }; | ||
| 89 | |||
| 90 | template <class _InIter, class _Sent, class _OutIter, class = void> | ||
| 91 | struct __can_rewrap : false_type {}; | ||
| 92 | |||
| 93 | template <class _InIter, class _Sent, class _OutIter> | ||
| 94 | struct __can_rewrap<_InIter, | ||
| 95 | _Sent, | ||
| 96 | _OutIter, | ||
| 97 | // Note that sentinels are always copy-constructible. | ||
| 98 | __enable_if_t< is_copy_constructible<_InIter>::value && is_copy_constructible<_OutIter>::value > > | ||
| 99 | : true_type {}; | ||
| 100 | 86 | ||
| 101 | template <class _Algorithm, | 87 | template <class _Algorithm, |
| 102 | class _InIter, | 88 | class _InIter, |
| 103 | class _Sent, | 89 | class _Sent, |
| 104 | class _OutIter, | 90 | class _OutIter, |
| 105 | __enable_if_t<__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0> | 91 | __enable_if_t<__can_rewrap<_InIter, _OutIter>::value, int> = 0> |
| 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> | 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> |
| 107 | __unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) { | 93 | __copy_move_unwrap_iters(_InIter __first, _Sent __last, _OutIter __out_first) { |
| 108 | auto __range = std::__unwrap_range(__first, std::move(__last)); | 94 | auto __range = std::__unwrap_range(__first, std::move(__last)); |
| 109 | auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first)); | 95 | auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first)); |
| 110 | return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)), | 96 | return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)), |
| ... | @@ -115,24 +101,12 @@ template <class _Algorithm, | ... | @@ -115,24 +101,12 @@ template <class _Algorithm, |
| 115 | class _InIter, | 101 | class _InIter, |
| 116 | class _Sent, | 102 | class _Sent, |
| 117 | class _OutIter, | 103 | class _OutIter, |
| 118 | __enable_if_t<!__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0> | 104 | __enable_if_t<!__can_rewrap<_InIter, _OutIter>::value, int> = 0> |
| 119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> | 105 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> |
| 120 | __unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) { | 106 | __copy_move_unwrap_iters(_InIter __first, _Sent __last, _OutIter __out_first) { |
| 121 | return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first)); | 107 | return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first)); |
| 122 | } | 108 | } |
| 123 | 109 | ||
| 124 | template <class _AlgPolicy, | ||
| 125 | class _NaiveAlgorithm, | ||
| 126 | class _OptimizedAlgorithm, | ||
| 127 | class _InIter, | ||
| 128 | class _Sent, | ||
| 129 | class _OutIter> | ||
| 130 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> | ||
| 131 | __dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) { | ||
| 132 | using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>; | ||
| 133 | return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first)); | ||
| 134 | } | ||
| 135 | |||
| 136 | _LIBCPP_END_NAMESPACE_STD | 110 | _LIBCPP_END_NAMESPACE_STD |
| 137 | 111 | ||
| 138 | _LIBCPP_POP_MACROS | 112 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__algorithm/count.h+1-1| ... | @@ -79,7 +79,7 @@ __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __l | ... | @@ -79,7 +79,7 @@ __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __l |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | template <class _InputIterator, class _Tp> | 81 | template <class _InputIterator, class _Tp> |
| 82 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> | 82 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> |
| 83 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | 83 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { |
| 84 | __identity __proj; | 84 | __identity __proj; |
| 85 | return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); | 85 | return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); |
lib/libcxx/include/__algorithm/count_if.h+3-3| ... | @@ -20,9 +20,9 @@ | ... | @@ -20,9 +20,9 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _InputIterator, class _Predicate> | 22 | template <class _InputIterator, class _Predicate> |
| 23 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 23 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 24 | typename iterator_traits<_InputIterator>::difference_type | 24 | typename iterator_traits<_InputIterator>::difference_type |
| 25 | count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 25 | count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 26 | typename iterator_traits<_InputIterator>::difference_type __r(0); | 26 | typename iterator_traits<_InputIterator>::difference_type __r(0); |
| 27 | for (; __first != __last; ++__first) | 27 | for (; __first != __last; ++__first) |
| 28 | if (__pred(*__first)) | 28 | if (__pred(*__first)) |
lib/libcxx/include/__algorithm/equal.h+21-58| ... | @@ -18,12 +18,11 @@ | ... | @@ -18,12 +18,11 @@ |
| 18 | #include <__iterator/distance.h> | 18 | #include <__iterator/distance.h> |
| 19 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__string/constexpr_c_functions.h> | 20 | #include <__string/constexpr_c_functions.h> |
| 21 | #include <__type_traits/desugars_to.h> | ||
| 21 | #include <__type_traits/enable_if.h> | 22 | #include <__type_traits/enable_if.h> |
| 22 | #include <__type_traits/integral_constant.h> | ||
| 23 | #include <__type_traits/is_constant_evaluated.h> | 23 | #include <__type_traits/is_constant_evaluated.h> |
| 24 | #include <__type_traits/is_equality_comparable.h> | 24 | #include <__type_traits/is_equality_comparable.h> |
| 25 | #include <__type_traits/is_volatile.h> | 25 | #include <__type_traits/is_volatile.h> |
| 26 | #include <__type_traits/operation_traits.h> | ||
| 27 | #include <__utility/move.h> | 26 | #include <__utility/move.h> |
| 28 | 27 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -47,7 +46,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo | ... | @@ -47,7 +46,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo |
| 47 | template <class _Tp, | 46 | template <class _Tp, |
| 48 | class _Up, | 47 | class _Up, |
| 49 | class _BinaryPredicate, | 48 | class _BinaryPredicate, |
| 50 | __enable_if_t<__desugars_to<__equal_tag, _BinaryPredicate, _Tp, _Up>::value && !is_volatile<_Tp>::value && | 49 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value && |
| 51 | !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, | 50 | !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, |
| 52 | int> = 0> | 51 | int> = 0> |
| 53 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 52 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| ... | @@ -56,33 +55,19 @@ __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) | ... | @@ -56,33 +55,19 @@ __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) |
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 57 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 59 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 58 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 60 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { | 59 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { |
| 61 | return std::__equal_iter_impl( | 60 | return std::__equal_iter_impl( |
| 62 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred); | 61 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred); |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | template <class _InputIterator1, class _InputIterator2> | 64 | template <class _InputIterator1, class _InputIterator2> |
| 66 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 65 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 67 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { | 66 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { |
| 68 | return std::equal(__first1, __last1, __first2, __equal_to()); | 67 | return std::equal(__first1, __last1, __first2, __equal_to()); |
| 69 | } | 68 | } |
| 70 | 69 | ||
| 71 | #if _LIBCPP_STD_VER >= 14 | 70 | #if _LIBCPP_STD_VER >= 14 |
| 72 | template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2> | ||
| 73 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
| 74 | __equal(_InputIterator1 __first1, | ||
| 75 | _InputIterator1 __last1, | ||
| 76 | _InputIterator2 __first2, | ||
| 77 | _InputIterator2 __last2, | ||
| 78 | _BinaryPredicate __pred, | ||
| 79 | input_iterator_tag, | ||
| 80 | input_iterator_tag) { | ||
| 81 | for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) | ||
| 82 | if (!__pred(*__first1, *__first2)) | ||
| 83 | return false; | ||
| 84 | return __first1 == __last1 && __first2 == __last2; | ||
| 85 | } | ||
| 86 | 71 | ||
| 87 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | 72 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 88 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( | 73 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( |
| ... | @@ -101,7 +86,7 @@ template <class _Tp, | ... | @@ -101,7 +86,7 @@ template <class _Tp, |
| 101 | class _Pred, | 86 | class _Pred, |
| 102 | class _Proj1, | 87 | class _Proj1, |
| 103 | class _Proj2, | 88 | class _Proj2, |
| 104 | __enable_if_t<__desugars_to<__equal_tag, _Pred, _Tp, _Up>::value && __is_identity<_Proj1>::value && | 89 | __enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value && |
| 105 | __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value && | 90 | __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value && |
| 106 | __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, | 91 | __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, |
| 107 | int> = 0> | 92 | int> = 0> |
| ... | @@ -110,17 +95,18 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, | ... | @@ -110,17 +95,18 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, |
| 110 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); | 95 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); |
| 111 | } | 96 | } |
| 112 | 97 | ||
| 113 | template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2> | 98 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 114 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 99 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 115 | __equal(_RandomAccessIterator1 __first1, | 100 | equal(_InputIterator1 __first1, |
| 116 | _RandomAccessIterator1 __last1, | 101 | _InputIterator1 __last1, |
| 117 | _RandomAccessIterator2 __first2, | 102 | _InputIterator2 __first2, |
| 118 | _RandomAccessIterator2 __last2, | 103 | _InputIterator2 __last2, |
| 119 | _BinaryPredicate __pred, | 104 | _BinaryPredicate __pred) { |
| 120 | random_access_iterator_tag, | 105 | if constexpr (__has_random_access_iterator_category<_InputIterator1>::value && |
| 121 | random_access_iterator_tag) { | 106 | __has_random_access_iterator_category<_InputIterator2>::value) { |
| 122 | if (std::distance(__first1, __last1) != std::distance(__first2, __last2)) | 107 | if (std::distance(__first1, __last1) != std::distance(__first2, __last2)) |
| 123 | return false; | 108 | return false; |
| 109 | } | ||
| 124 | __identity __proj; | 110 | __identity __proj; |
| 125 | return std::__equal_impl( | 111 | return std::__equal_impl( |
| 126 | std::__unwrap_iter(__first1), | 112 | std::__unwrap_iter(__first1), |
| ... | @@ -132,36 +118,13 @@ __equal(_RandomAccessIterator1 __first1, | ... | @@ -132,36 +118,13 @@ __equal(_RandomAccessIterator1 __first1, |
| 132 | __proj); | 118 | __proj); |
| 133 | } | 119 | } |
| 134 | 120 | ||
| 135 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | ||
| 136 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
| 137 | equal(_InputIterator1 __first1, | ||
| 138 | _InputIterator1 __last1, | ||
| 139 | _InputIterator2 __first2, | ||
| 140 | _InputIterator2 __last2, | ||
| 141 | _BinaryPredicate __pred) { | ||
| 142 | return std::__equal<_BinaryPredicate&>( | ||
| 143 | __first1, | ||
| 144 | __last1, | ||
| 145 | __first2, | ||
| 146 | __last2, | ||
| 147 | __pred, | ||
| 148 | typename iterator_traits<_InputIterator1>::iterator_category(), | ||
| 149 | typename iterator_traits<_InputIterator2>::iterator_category()); | ||
| 150 | } | ||
| 151 | |||
| 152 | template <class _InputIterator1, class _InputIterator2> | 121 | template <class _InputIterator1, class _InputIterator2> |
| 153 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 122 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 154 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | 123 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 155 | return std::__equal( | 124 | return std::equal(__first1, __last1, __first2, __last2, __equal_to()); |
| 156 | __first1, | ||
| 157 | __last1, | ||
| 158 | __first2, | ||
| 159 | __last2, | ||
| 160 | __equal_to(), | ||
| 161 | typename iterator_traits<_InputIterator1>::iterator_category(), | ||
| 162 | typename iterator_traits<_InputIterator2>::iterator_category()); | ||
| 163 | } | 125 | } |
| 164 | #endif | 126 | |
| 127 | #endif // _LIBCPP_STD_VER >= 14 | ||
| 165 | 128 | ||
| 166 | _LIBCPP_END_NAMESPACE_STD | 129 | _LIBCPP_END_NAMESPACE_STD |
| 167 | 130 |
lib/libcxx/include/__algorithm/equal_range.h+3-3| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | #include <__iterator/iterator_traits.h> | 23 | #include <__iterator/iterator_traits.h> |
| 24 | #include <__iterator/next.h> | 24 | #include <__iterator/next.h> |
| 25 | #include <__type_traits/is_callable.h> | 25 | #include <__type_traits/is_callable.h> |
| 26 | #include <__type_traits/is_copy_constructible.h> | 26 | #include <__type_traits/is_constructible.h> |
| 27 | #include <__utility/move.h> | 27 | #include <__utility/move.h> |
| 28 | #include <__utility/pair.h> | 28 | #include <__utility/pair.h> |
| 29 | 29 | ||
| ... | @@ -60,7 +60,7 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp | ... | @@ -60,7 +60,7 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | template <class _ForwardIterator, class _Tp, class _Compare> | 62 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 63 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | 63 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> |
| 64 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | 64 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 65 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); | 65 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); |
| 66 | static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); | 66 | static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); |
| ... | @@ -73,7 +73,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu | ... | @@ -73,7 +73,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | template <class _ForwardIterator, class _Tp> | 75 | template <class _ForwardIterator, class _Tp> |
| 76 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | 76 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> |
| 77 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 77 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 78 | return std::equal_range(std::move(__first), std::move(__last), __value, __less<>()); | 78 | return std::equal_range(std::move(__first), std::move(__last), __value, __less<>()); |
| 79 | } | 79 | } |
lib/libcxx/include/__algorithm/fill_n.h+58| ... | @@ -9,18 +9,74 @@ | ... | @@ -9,18 +9,74 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_FILL_N_H | 9 | #ifndef _LIBCPP___ALGORITHM_FILL_N_H |
| 10 | #define _LIBCPP___ALGORITHM_FILL_N_H | 10 | #define _LIBCPP___ALGORITHM_FILL_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/min.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__fwd/bit_reference.h> | ||
| 13 | #include <__iterator/iterator_traits.h> | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__memory/pointer_traits.h> | ||
| 14 | #include <__utility/convert_to_integral.h> | 17 | #include <__utility/convert_to_integral.h> |
| 15 | 18 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| 18 | #endif | 21 | #endif |
| 19 | 22 | ||
| 23 | _LIBCPP_PUSH_MACROS | ||
| 24 | #include <__undef_macros> | ||
| 25 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 27 | ||
| 22 | // fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | 28 | // fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. |
| 23 | 29 | ||
| 30 | template <class _OutputIterator, class _Size, class _Tp> | ||
| 31 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | ||
| 32 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value); | ||
| 33 | |||
| 34 | template <bool _FillVal, class _Cp> | ||
| 35 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 36 | __fill_n_bool(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { | ||
| 37 | using _It = __bit_iterator<_Cp, false>; | ||
| 38 | using __storage_type = typename _It::__storage_type; | ||
| 39 | |||
| 40 | const int __bits_per_word = _It::__bits_per_word; | ||
| 41 | // do first partial word | ||
| 42 | if (__first.__ctz_ != 0) { | ||
| 43 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | ||
| 44 | __storage_type __dn = std::min(__clz_f, __n); | ||
| 45 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | ||
| 46 | if (_FillVal) | ||
| 47 | *__first.__seg_ |= __m; | ||
| 48 | else | ||
| 49 | *__first.__seg_ &= ~__m; | ||
| 50 | __n -= __dn; | ||
| 51 | ++__first.__seg_; | ||
| 52 | } | ||
| 53 | // do middle whole words | ||
| 54 | __storage_type __nw = __n / __bits_per_word; | ||
| 55 | std::__fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0); | ||
| 56 | __n -= __nw * __bits_per_word; | ||
| 57 | // do last partial word | ||
| 58 | if (__n > 0) { | ||
| 59 | __first.__seg_ += __nw; | ||
| 60 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 61 | if (_FillVal) | ||
| 62 | *__first.__seg_ |= __m; | ||
| 63 | else | ||
| 64 | *__first.__seg_ &= ~__m; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | template <class _Cp, class _Size> | ||
| 69 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> | ||
| 70 | __fill_n(__bit_iterator<_Cp, false> __first, _Size __n, const bool& __value) { | ||
| 71 | if (__n > 0) { | ||
| 72 | if (__value) | ||
| 73 | std::__fill_n_bool<true>(__first, __n); | ||
| 74 | else | ||
| 75 | std::__fill_n_bool<false>(__first, __n); | ||
| 76 | } | ||
| 77 | return __first + __n; | ||
| 78 | } | ||
| 79 | |||
| 24 | template <class _OutputIterator, class _Size, class _Tp> | 80 | template <class _OutputIterator, class _Size, class _Tp> |
| 25 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 81 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 26 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { | 82 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { |
| ... | @@ -37,4 +93,6 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { | ... | @@ -37,4 +93,6 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { |
| 37 | 93 | ||
| 38 | _LIBCPP_END_NAMESPACE_STD | 94 | _LIBCPP_END_NAMESPACE_STD |
| 39 | 95 | ||
| 96 | _LIBCPP_POP_MACROS | ||
| 97 | |||
| 40 | #endif // _LIBCPP___ALGORITHM_FILL_N_H | 98 | #endif // _LIBCPP___ALGORITHM_FILL_N_H |
lib/libcxx/include/__algorithm/find.h+10-12| ... | @@ -43,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -43,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 43 | // generic implementation | 43 | // generic implementation |
| 44 | template <class _Iter, class _Sent, class _Tp, class _Proj> | 44 | template <class _Iter, class _Sent, class _Tp, class _Proj> |
| 45 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter | 45 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter |
| 46 | __find_impl(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { | 46 | __find(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { |
| 47 | for (; __first != __last; ++__first) | 47 | for (; __first != __last; ++__first) |
| 48 | if (std::__invoke(__proj, *__first) == __value) | 48 | if (std::__invoke(__proj, *__first) == __value) |
| 49 | break; | 49 | break; |
| ... | @@ -57,8 +57,7 @@ template <class _Tp, | ... | @@ -57,8 +57,7 @@ template <class _Tp, |
| 57 | __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && | 57 | __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && |
| 58 | sizeof(_Tp) == 1, | 58 | sizeof(_Tp) == 1, |
| 59 | int> = 0> | 59 | int> = 0> |
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* | 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { |
| 61 | __find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { | ||
| 62 | if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first)) | 61 | if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first)) |
| 63 | return __ret; | 62 | return __ret; |
| 64 | return __last; | 63 | return __last; |
| ... | @@ -71,8 +70,7 @@ template <class _Tp, | ... | @@ -71,8 +70,7 @@ template <class _Tp, |
| 71 | __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && | 70 | __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && |
| 72 | sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t), | 71 | sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t), |
| 73 | int> = 0> | 72 | int> = 0> |
| 74 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* | 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { |
| 75 | __find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { | ||
| 76 | if (auto __ret = std::__constexpr_wmemchr(__first, __value, __last - __first)) | 74 | if (auto __ret = std::__constexpr_wmemchr(__first, __value, __last - __first)) |
| 77 | return __ret; | 75 | return __ret; |
| 78 | return __last; | 76 | return __last; |
| ... | @@ -89,10 +87,10 @@ template <class _Tp, | ... | @@ -89,10 +87,10 @@ template <class _Tp, |
| 89 | is_signed<_Tp>::value == is_signed<_Up>::value, | 87 | is_signed<_Tp>::value == is_signed<_Up>::value, |
| 90 | int> = 0> | 88 | int> = 0> |
| 91 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* | 89 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* |
| 92 | __find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) { | 90 | __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) { |
| 93 | if (__value < numeric_limits<_Tp>::min() || __value > numeric_limits<_Tp>::max()) | 91 | if (__value < numeric_limits<_Tp>::min() || __value > numeric_limits<_Tp>::max()) |
| 94 | return __last; | 92 | return __last; |
| 95 | return std::__find_impl(__first, __last, _Tp(__value), __proj); | 93 | return std::__find(__first, __last, _Tp(__value), __proj); |
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | // __bit_iterator implementation | 96 | // __bit_iterator implementation |
| ... | @@ -134,7 +132,7 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) | ... | @@ -134,7 +132,7 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) |
| 134 | 132 | ||
| 135 | template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0> | 133 | template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0> |
| 136 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst> | 134 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst> |
| 137 | __find_impl(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { | 135 | __find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { |
| 138 | if (static_cast<bool>(__value)) | 136 | if (static_cast<bool>(__value)) |
| 139 | return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); | 137 | return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); |
| 140 | return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); | 138 | return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); |
| ... | @@ -150,7 +148,7 @@ template <class _SegmentedIterator, | ... | @@ -150,7 +148,7 @@ template <class _SegmentedIterator, |
| 150 | class _Proj, | 148 | class _Proj, |
| 151 | __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> | 149 | __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> |
| 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator | 150 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator |
| 153 | __find_impl(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) { | 151 | __find(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) { |
| 154 | return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj); | 152 | return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj); |
| 155 | } | 153 | } |
| 156 | 154 | ||
| ... | @@ -163,17 +161,17 @@ struct __find_segment { | ... | @@ -163,17 +161,17 @@ struct __find_segment { |
| 163 | template <class _InputIterator, class _Proj> | 161 | template <class _InputIterator, class _Proj> |
| 164 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _InputIterator | 162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _InputIterator |
| 165 | operator()(_InputIterator __first, _InputIterator __last, _Proj& __proj) const { | 163 | operator()(_InputIterator __first, _InputIterator __last, _Proj& __proj) const { |
| 166 | return std::__find_impl(__first, __last, __value_, __proj); | 164 | return std::__find(__first, __last, __value_, __proj); |
| 167 | } | 165 | } |
| 168 | }; | 166 | }; |
| 169 | 167 | ||
| 170 | // public API | 168 | // public API |
| 171 | template <class _InputIterator, class _Tp> | 169 | template <class _InputIterator, class _Tp> |
| 172 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 170 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
| 173 | find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | 171 | find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { |
| 174 | __identity __proj; | 172 | __identity __proj; |
| 175 | return std::__rewrap_iter( | 173 | return std::__rewrap_iter( |
| 176 | __first, std::__find_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __value, __proj)); | 174 | __first, std::__find(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __value, __proj)); |
| 177 | } | 175 | } |
| 178 | 176 | ||
| 179 | _LIBCPP_END_NAMESPACE_STD | 177 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/find_end.h+2-2| ... | @@ -205,7 +205,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo | ... | @@ -205,7 +205,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 207 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 208 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end( | 208 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end( |
| 209 | _ForwardIterator1 __first1, | 209 | _ForwardIterator1 __first1, |
| 210 | _ForwardIterator1 __last1, | 210 | _ForwardIterator1 __last1, |
| 211 | _ForwardIterator2 __first2, | 211 | _ForwardIterator2 __first2, |
| ... | @@ -215,7 +215,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ... | @@ -215,7 +215,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | template <class _ForwardIterator1, class _ForwardIterator2> | 217 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 218 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | 218 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 |
| 219 | find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | 219 | find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 220 | return std::find_end(__first1, __last1, __first2, __last2, __equal_to()); | 220 | return std::find_end(__first1, __last1, __first2, __last2, __equal_to()); |
| 221 | } | 221 | } |
lib/libcxx/include/__algorithm/find_first_of.h+2-2| ... | @@ -35,7 +35,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir | ... | @@ -35,7 +35,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 37 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 38 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( |
| 39 | _ForwardIterator1 __first1, | 39 | _ForwardIterator1 __first1, |
| 40 | _ForwardIterator1 __last1, | 40 | _ForwardIterator1 __last1, |
| 41 | _ForwardIterator2 __first2, | 41 | _ForwardIterator2 __first2, |
| ... | @@ -45,7 +45,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ... | @@ -45,7 +45,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | template <class _ForwardIterator1, class _ForwardIterator2> | 47 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | 48 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( |
| 49 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | 49 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 50 | return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to()); | 50 | return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to()); |
| 51 | } | 51 | } |
lib/libcxx/include/__algorithm/find_if.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 _InputIterator, class _Predicate> | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
| 23 | find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 23 | find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | for (; __first != __last; ++__first) | 24 | for (; __first != __last; ++__first) |
| 25 | if (__pred(*__first)) | 25 | if (__pred(*__first)) |
lib/libcxx/include/__algorithm/find_if_not.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 _InputIterator, class _Predicate> | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
| 23 | find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 23 | find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | for (; __first != __last; ++__first) | 24 | for (; __first != __last; ++__first) |
| 25 | if (!__pred(*__first)) | 25 | if (!__pred(*__first)) |
lib/libcxx/include/__algorithm/fold.h+4-6| ... | @@ -78,8 +78,7 @@ concept __indirectly_binary_left_foldable = | ... | @@ -78,8 +78,7 @@ concept __indirectly_binary_left_foldable = |
| 78 | 78 | ||
| 79 | struct __fold_left_with_iter { | 79 | struct __fold_left_with_iter { |
| 80 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> | 80 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> |
| 81 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto | 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { |
| 82 | operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { | ||
| 83 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>; | 82 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>; |
| 84 | 83 | ||
| 85 | if (__first == __last) { | 84 | if (__first == __last) { |
| ... | @@ -95,7 +94,7 @@ struct __fold_left_with_iter { | ... | @@ -95,7 +94,7 @@ struct __fold_left_with_iter { |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> | 96 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> |
| 98 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { | 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { |
| 99 | auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)); | 98 | auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)); |
| 100 | 99 | ||
| 101 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>; | 100 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>; |
| ... | @@ -107,13 +106,12 @@ inline constexpr auto fold_left_with_iter = __fold_left_with_iter(); | ... | @@ -107,13 +106,12 @@ inline constexpr auto fold_left_with_iter = __fold_left_with_iter(); |
| 107 | 106 | ||
| 108 | struct __fold_left { | 107 | struct __fold_left { |
| 109 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> | 108 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> |
| 110 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto | 109 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { |
| 111 | operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { | ||
| 112 | return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value; | 110 | return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value; |
| 113 | } | 111 | } |
| 114 | 112 | ||
| 115 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> | 113 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> |
| 116 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { | 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { |
| 117 | return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value; | 115 | return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value; |
| 118 | } | 116 | } |
| 119 | }; | 117 | }; |
lib/libcxx/include/__algorithm/includes.h+2-2| ... | @@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes( | ... | @@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes( |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | template <class _InputIterator1, class _InputIterator2, class _Compare> | 49 | template <class _InputIterator1, class _InputIterator2, class _Compare> |
| 50 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 51 | includes(_InputIterator1 __first1, | 51 | includes(_InputIterator1 __first1, |
| 52 | _InputIterator1 __last1, | 52 | _InputIterator1 __last1, |
| 53 | _InputIterator2 __first2, | 53 | _InputIterator2 __first2, |
| ... | @@ -67,7 +67,7 @@ includes(_InputIterator1 __first1, | ... | @@ -67,7 +67,7 @@ includes(_InputIterator1 __first1, |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | template <class _InputIterator1, class _InputIterator2> | 69 | template <class _InputIterator1, class _InputIterator2> |
| 70 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 70 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 71 | includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | 71 | includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 72 | return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>()); | 72 | return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>()); |
| 73 | } | 73 | } |
lib/libcxx/include/__algorithm/inplace_merge.h+2-2| ... | @@ -114,8 +114,8 @@ _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge( | ... | @@ -114,8 +114,8 @@ _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge( |
| 114 | for (_BidirectionalIterator __i = __middle; __i != __last; | 114 | for (_BidirectionalIterator __i = __middle; __i != __last; |
| 115 | __d.template __incr<value_type>(), (void)++__i, (void)++__p) | 115 | __d.template __incr<value_type>(), (void)++__i, (void)++__p) |
| 116 | ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | 116 | ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); |
| 117 | typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi; | 117 | typedef reverse_iterator<_BidirectionalIterator> _RBi; |
| 118 | typedef __unconstrained_reverse_iterator<value_type*> _Rv; | 118 | typedef reverse_iterator<value_type*> _Rv; |
| 119 | typedef __invert<_Compare> _Inverted; | 119 | typedef __invert<_Compare> _Inverted; |
| 120 | std::__half_inplace_merge<_AlgPolicy>( | 120 | std::__half_inplace_merge<_AlgPolicy>( |
| 121 | _Rv(__p), _Rv(__buff), _RBi(__middle), _RBi(__first), _RBi(__last), _Inverted(__comp)); | 121 | _Rv(__p), _Rv(__buff), _RBi(__middle), _RBi(__first), _RBi(__last), _Inverted(__comp)); |
lib/libcxx/include/__algorithm/is_heap.h+2-2| ... | @@ -22,13 +22,13 @@ | ... | @@ -22,13 +22,13 @@ |
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | template <class _RandomAccessIterator, class _Compare> | 24 | template <class _RandomAccessIterator, class _Compare> |
| 25 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 25 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 26 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | 26 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { |
| 27 | return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last; | 27 | return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | template <class _RandomAccessIterator> | 30 | template <class _RandomAccessIterator> |
| 31 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 31 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 32 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { | 32 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { |
| 33 | return std::is_heap(__first, __last, __less<>()); | 33 | return std::is_heap(__first, __last, __less<>()); |
| 34 | } | 34 | } |
lib/libcxx/include/__algorithm/is_heap_until.h+2-2| ... | @@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co | ... | @@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | template <class _RandomAccessIterator, class _Compare> | 48 | template <class _RandomAccessIterator, class _Compare> |
| 49 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | 49 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator |
| 50 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | 50 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { |
| 51 | return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)); | 51 | return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | template <class _RandomAccessIterator> | 54 | template <class _RandomAccessIterator> |
| 55 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | 55 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator |
| 56 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { | 56 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { |
| 57 | return std::__is_heap_until(__first, __last, __less<>()); | 57 | return std::__is_heap_until(__first, __last, __less<>()); |
| 58 | } | 58 | } |
lib/libcxx/include/__algorithm/is_partitioned.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 _InputIterator, class _Predicate> | 20 | template <class _InputIterator, class _Predicate> |
| 21 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 21 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 22 | is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 22 | is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 23 | for (; __first != __last; ++__first) | 23 | for (; __first != __last; ++__first) |
| 24 | if (!__pred(*__first)) | 24 | if (!__pred(*__first)) |
lib/libcxx/include/__algorithm/is_permutation.h+5-5| ... | @@ -113,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl( | ... | @@ -113,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl( |
| 113 | 113 | ||
| 114 | // 2+1 iterators, predicate. Not used by range algorithms. | 114 | // 2+1 iterators, predicate. Not used by range algorithms. |
| 115 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate> | 115 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate> |
| 116 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( | 116 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( |
| 117 | _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) { | 117 | _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) { |
| 118 | // Shorten sequences as much as possible by lopping of any equal prefix. | 118 | // Shorten sequences as much as possible by lopping of any equal prefix. |
| 119 | for (; __first1 != __last1; ++__first1, (void)++__first2) { | 119 | for (; __first1 != __last1; ++__first1, (void)++__first2) { |
| ... | @@ -247,7 +247,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( | ... | @@ -247,7 +247,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( |
| 247 | 247 | ||
| 248 | // 2+1 iterators, predicate | 248 | // 2+1 iterators, predicate |
| 249 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 249 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 250 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | 250 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( |
| 251 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { | 251 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { |
| 252 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, | 252 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, |
| 253 | "The predicate has to be callable"); | 253 | "The predicate has to be callable"); |
| ... | @@ -257,7 +257,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool i | ... | @@ -257,7 +257,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool i |
| 257 | 257 | ||
| 258 | // 2+1 iterators | 258 | // 2+1 iterators |
| 259 | template <class _ForwardIterator1, class _ForwardIterator2> | 259 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 260 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 260 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 261 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | 261 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { |
| 262 | return std::is_permutation(__first1, __last1, __first2, __equal_to()); | 262 | return std::is_permutation(__first1, __last1, __first2, __equal_to()); |
| 263 | } | 263 | } |
| ... | @@ -266,7 +266,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt | ... | @@ -266,7 +266,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt |
| 266 | 266 | ||
| 267 | // 2+2 iterators | 267 | // 2+2 iterators |
| 268 | template <class _ForwardIterator1, class _ForwardIterator2> | 268 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 269 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | 269 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( |
| 270 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | 270 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 271 | return std::__is_permutation<_ClassicAlgPolicy>( | 271 | return std::__is_permutation<_ClassicAlgPolicy>( |
| 272 | std::move(__first1), | 272 | std::move(__first1), |
| ... | @@ -280,7 +280,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ... | @@ -280,7 +280,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 280 | 280 | ||
| 281 | // 2+2 iterators, predicate | 281 | // 2+2 iterators, predicate |
| 282 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 282 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 283 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | 283 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( |
| 284 | _ForwardIterator1 __first1, | 284 | _ForwardIterator1 __first1, |
| 285 | _ForwardIterator1 __last1, | 285 | _ForwardIterator1 __last1, |
| 286 | _ForwardIterator2 __first2, | 286 | _ForwardIterator2 __first2, |
lib/libcxx/include/__algorithm/is_sorted.h+2-2| ... | @@ -22,13 +22,13 @@ | ... | @@ -22,13 +22,13 @@ |
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | template <class _ForwardIterator, class _Compare> | 24 | template <class _ForwardIterator, class _Compare> |
| 25 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 25 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 26 | is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { | 26 | is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 27 | return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last; | 27 | return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | template <class _ForwardIterator> | 30 | template <class _ForwardIterator> |
| 31 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 31 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 32 | is_sorted(_ForwardIterator __first, _ForwardIterator __last) { | 32 | is_sorted(_ForwardIterator __first, _ForwardIterator __last) { |
| 33 | return std::is_sorted(__first, __last, __less<>()); | 33 | return std::is_sorted(__first, __last, __less<>()); |
| 34 | } | 34 | } |
lib/libcxx/include/__algorithm/is_sorted_until.h+2-2| ... | @@ -35,13 +35,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __ | ... | @@ -35,13 +35,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __ |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | template <class _ForwardIterator, class _Compare> | 37 | template <class _ForwardIterator, class _Compare> |
| 38 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 39 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { | 39 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 40 | return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp); | 40 | return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | template <class _ForwardIterator> | 43 | template <class _ForwardIterator> |
| 44 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 44 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 45 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { | 45 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { |
| 46 | return std::is_sorted_until(__first, __last, __less<>()); | 46 | return std::is_sorted_until(__first, __last, __less<>()); |
| 47 | } | 47 | } |
lib/libcxx/include/__algorithm/iterator_operations.h+54| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/iter_swap.h> | 12 | #include <__algorithm/iter_swap.h> |
| 13 | #include <__algorithm/ranges_iterator_concept.h> | 13 | #include <__algorithm/ranges_iterator_concept.h> |
| 14 | #include <__assert> | ||
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__iterator/advance.h> | 16 | #include <__iterator/advance.h> |
| 16 | #include <__iterator/distance.h> | 17 | #include <__iterator/distance.h> |
| ... | @@ -160,6 +161,59 @@ struct _IterOps<_ClassicAlgPolicy> { | ... | @@ -160,6 +161,59 @@ struct _IterOps<_ClassicAlgPolicy> { |
| 160 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 void __advance_to(_Iter& __first, _Iter __last) { | 161 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 void __advance_to(_Iter& __first, _Iter __last) { |
| 161 | __first = __last; | 162 | __first = __last; |
| 162 | } | 163 | } |
| 164 | |||
| 165 | // advance with sentinel, a la std::ranges::advance | ||
| 166 | template <class _Iter> | ||
| 167 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_Iter> | ||
| 168 | __advance_to(_Iter& __iter, __difference_type<_Iter> __count, const _Iter& __sentinel) { | ||
| 169 | return _IterOps::__advance_to(__iter, __count, __sentinel, typename iterator_traits<_Iter>::iterator_category()); | ||
| 170 | } | ||
| 171 | |||
| 172 | private: | ||
| 173 | // advance with sentinel, a la std::ranges::advance -- InputIterator specialization | ||
| 174 | template <class _InputIter> | ||
| 175 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_InputIter> __advance_to( | ||
| 176 | _InputIter& __iter, __difference_type<_InputIter> __count, const _InputIter& __sentinel, input_iterator_tag) { | ||
| 177 | __difference_type<_InputIter> __dist = 0; | ||
| 178 | for (; __dist < __count && __iter != __sentinel; ++__dist) | ||
| 179 | ++__iter; | ||
| 180 | return __count - __dist; | ||
| 181 | } | ||
| 182 | |||
| 183 | // advance with sentinel, a la std::ranges::advance -- BidirectionalIterator specialization | ||
| 184 | template <class _BiDirIter> | ||
| 185 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_BiDirIter> | ||
| 186 | __advance_to(_BiDirIter& __iter, | ||
| 187 | __difference_type<_BiDirIter> __count, | ||
| 188 | const _BiDirIter& __sentinel, | ||
| 189 | bidirectional_iterator_tag) { | ||
| 190 | __difference_type<_BiDirIter> __dist = 0; | ||
| 191 | if (__count >= 0) | ||
| 192 | for (; __dist < __count && __iter != __sentinel; ++__dist) | ||
| 193 | ++__iter; | ||
| 194 | else | ||
| 195 | for (__count = -__count; __dist < __count && __iter != __sentinel; ++__dist) | ||
| 196 | --__iter; | ||
| 197 | return __count - __dist; | ||
| 198 | } | ||
| 199 | |||
| 200 | // advance with sentinel, a la std::ranges::advance -- RandomIterator specialization | ||
| 201 | template <class _RandIter> | ||
| 202 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_RandIter> | ||
| 203 | __advance_to(_RandIter& __iter, | ||
| 204 | __difference_type<_RandIter> __count, | ||
| 205 | const _RandIter& __sentinel, | ||
| 206 | random_access_iterator_tag) { | ||
| 207 | auto __dist = _IterOps::distance(__iter, __sentinel); | ||
| 208 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | ||
| 209 | __count == 0 || (__dist < 0) == (__count < 0), "__sentinel must precede __iter when __count < 0"); | ||
| 210 | if (__count < 0) | ||
| 211 | __dist = __dist > __count ? __dist : __count; | ||
| 212 | else | ||
| 213 | __dist = __dist < __count ? __dist : __count; | ||
| 214 | __iter += __dist; | ||
| 215 | return __count - __dist; | ||
| 216 | } | ||
| 163 | }; | 217 | }; |
| 164 | 218 | ||
| 165 | _LIBCPP_END_NAMESPACE_STD | 219 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/lexicographical_compare.h+2-2| ... | @@ -37,7 +37,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compa | ... | @@ -37,7 +37,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compa |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | template <class _InputIterator1, class _InputIterator2, class _Compare> | 39 | template <class _InputIterator1, class _InputIterator2, class _Compare> |
| 40 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( | 40 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( |
| 41 | _InputIterator1 __first1, | 41 | _InputIterator1 __first1, |
| 42 | _InputIterator1 __last1, | 42 | _InputIterator1 __last1, |
| 43 | _InputIterator2 __first2, | 43 | _InputIterator2 __first2, |
| ... | @@ -47,7 +47,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ... | @@ -47,7 +47,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | template <class _InputIterator1, class _InputIterator2> | 49 | template <class _InputIterator1, class _InputIterator2> |
| 50 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( | 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( |
| 51 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | 51 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 52 | return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>()); | 52 | return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>()); |
| 53 | } | 53 | } |
lib/libcxx/include/__algorithm/lexicographical_compare_three_way.h+3-3| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__type_traits/common_type.h> | 19 | #include <__type_traits/common_type.h> |
| 20 | #include <__type_traits/is_copy_constructible.h> | 20 | #include <__type_traits/is_constructible.h> |
| 21 | #include <__utility/move.h> | 21 | #include <__utility/move.h> |
| 22 | 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -90,7 +90,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __lexicographical_compare_three_way_slow_pa | ... | @@ -90,7 +90,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __lexicographical_compare_three_way_slow_pa |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | template <class _InputIterator1, class _InputIterator2, class _Cmp> | 92 | template <class _InputIterator1, class _InputIterator2, class _Cmp> |
| 93 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way( | 93 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way( |
| 94 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Cmp __comp) | 94 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Cmp __comp) |
| 95 | -> decltype(__comp(*__first1, *__first2)) { | 95 | -> decltype(__comp(*__first1, *__first2)) { |
| 96 | static_assert(__comparison_category<decltype(__comp(*__first1, *__first2))>, | 96 | static_assert(__comparison_category<decltype(__comp(*__first1, *__first2))>, |
| ... | @@ -110,7 +110,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compa | ... | @@ -110,7 +110,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compa |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | template <class _InputIterator1, class _InputIterator2> | 112 | template <class _InputIterator1, class _InputIterator2> |
| 113 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way( | 113 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way( |
| 114 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | 114 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 115 | return std::lexicographical_compare_three_way( | 115 | return std::lexicographical_compare_three_way( |
| 116 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::compare_three_way()); | 116 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::compare_three_way()); |
lib/libcxx/include/__algorithm/lower_bound.h+51-7| ... | @@ -27,11 +27,13 @@ | ... | @@ -27,11 +27,13 @@ |
| 27 | 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | ||
| 30 | template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp> | 30 | template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp> |
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter | 31 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting( |
| 32 | __lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { | 32 | _Iter __first, |
| 33 | auto __len = _IterOps<_AlgPolicy>::distance(__first, __last); | 33 | const _Type& __value, |
| 34 | 34 | typename iterator_traits<_Iter>::difference_type __len, | |
| 35 | _Comp& __comp, | ||
| 36 | _Proj& __proj) { | ||
| 35 | while (__len != 0) { | 37 | while (__len != 0) { |
| 36 | auto __l2 = std::__half_positive(__len); | 38 | auto __l2 = std::__half_positive(__len); |
| 37 | _Iter __m = __first; | 39 | _Iter __m = __first; |
| ... | @@ -46,8 +48,50 @@ __lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, | ... | @@ -46,8 +48,50 @@ __lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, |
| 46 | return __first; | 48 | return __first; |
| 47 | } | 49 | } |
| 48 | 50 | ||
| 51 | // One-sided binary search, aka meta binary search, has been in the public domain for decades, and has the general | ||
| 52 | // advantage of being \Omega(1) rather than the classic algorithm's \Omega(log(n)), with the downside of executing at | ||
| 53 | // most 2*log(n) comparisons vs the classic algorithm's exact log(n). There are two scenarios in which it really shines: | ||
| 54 | // the first one is when operating over non-random-access iterators, because the classic algorithm requires knowing the | ||
| 55 | // container's size upfront, which adds \Omega(n) iterator increments to the complexity. The second one is when you're | ||
| 56 | // traversing the container in order, trying to fast-forward to the next value: in that case, the classic algorithm | ||
| 57 | // would yield \Omega(n*log(n)) comparisons and, for non-random-access iterators, \Omega(n^2) iterator increments, | ||
| 58 | // whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of | ||
| 59 | // comparisons. | ||
| 60 | template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp> | ||
| 61 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | ||
| 62 | __lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { | ||
| 63 | // step = 0, ensuring we can always short-circuit when distance is 1 later on | ||
| 64 | if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value)) | ||
| 65 | return __first; | ||
| 66 | |||
| 67 | using _Distance = typename iterator_traits<_ForwardIterator>::difference_type; | ||
| 68 | for (_Distance __step = 1; __first != __last; __step <<= 1) { | ||
| 69 | auto __it = __first; | ||
| 70 | auto __dist = __step - _IterOps<_AlgPolicy>::__advance_to(__it, __step, __last); | ||
| 71 | // once we reach the last range where needle can be we must start | ||
| 72 | // looking inwards, bisecting that range | ||
| 73 | if (__it == __last || !std::__invoke(__comp, std::__invoke(__proj, *__it), __value)) { | ||
| 74 | // we've already checked the previous value and it was less, we can save | ||
| 75 | // one comparison by skipping bisection | ||
| 76 | if (__dist == 1) | ||
| 77 | return __it; | ||
| 78 | return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj); | ||
| 79 | } | ||
| 80 | // range not found, move forward! | ||
| 81 | __first = __it; | ||
| 82 | } | ||
| 83 | return __first; | ||
| 84 | } | ||
| 85 | |||
| 86 | template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp> | ||
| 87 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | ||
| 88 | __lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { | ||
| 89 | const auto __dist = _IterOps<_AlgPolicy>::distance(__first, __last); | ||
| 90 | return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj); | ||
| 91 | } | ||
| 92 | |||
| 49 | template <class _ForwardIterator, class _Tp, class _Compare> | 93 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 50 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 94 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 51 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | 95 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 52 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); | 96 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); |
| 53 | auto __proj = std::__identity(); | 97 | auto __proj = std::__identity(); |
| ... | @@ -55,7 +99,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu | ... | @@ -55,7 +99,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 55 | } | 99 | } |
| 56 | 100 | ||
| 57 | template <class _ForwardIterator, class _Tp> | 101 | template <class _ForwardIterator, class _Tp> |
| 58 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 102 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 59 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 103 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 60 | return std::lower_bound(__first, __last, __value, __less<>()); | 104 | return std::lower_bound(__first, __last, __value, __less<>()); |
| 61 | } | 105 | } |
lib/libcxx/include/__algorithm/make_projected.h+4-4| ... | @@ -36,8 +36,8 @@ struct _ProjectedPred { | ... | @@ -36,8 +36,8 @@ struct _ProjectedPred { |
| 36 | : __pred(__pred_arg), __proj(__proj_arg) {} | 36 | : __pred(__pred_arg), __proj(__proj_arg) {} |
| 37 | 37 | ||
| 38 | template <class _Tp> | 38 | template <class _Tp> |
| 39 | typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>())) >:: | 39 | typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))>::type |
| 40 | type _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI | 40 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI |
| 41 | operator()(_Tp&& __v) const { | 41 | operator()(_Tp&& __v) const { |
| 42 | return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v))); | 42 | return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v))); |
| 43 | } | 43 | } |
| ... | @@ -45,8 +45,8 @@ struct _ProjectedPred { | ... | @@ -45,8 +45,8 @@ struct _ProjectedPred { |
| 45 | template <class _T1, class _T2> | 45 | template <class _T1, class _T2> |
| 46 | typename __invoke_of<_Pred&, | 46 | typename __invoke_of<_Pred&, |
| 47 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())), | 47 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())), |
| 48 | decltype(std::__invoke(std::declval<_Proj&>(), | 48 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))>::type _LIBCPP_CONSTEXPR |
| 49 | std::declval<_T2>())) >::type _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI | 49 | _LIBCPP_HIDE_FROM_ABI |
| 50 | operator()(_T1&& __lhs, _T2&& __rhs) const { | 50 | operator()(_T1&& __lhs, _T2&& __rhs) const { |
| 51 | return std::__invoke( | 51 | return std::__invoke( |
| 52 | __pred, std::__invoke(__proj, std::forward<_T1>(__lhs)), std::__invoke(__proj, std::forward<_T2>(__rhs))); | 52 | __pred, std::__invoke(__proj, std::forward<_T1>(__lhs)), std::__invoke(__proj, std::forward<_T2>(__rhs))); |
lib/libcxx/include/__algorithm/max.h+4-4| ... | @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _Tp, class _Compare> | 27 | template <class _Tp, class _Compare> |
| 28 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& |
| 29 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { | 29 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { |
| 30 | return __comp(__a, __b) ? __b : __a; | 30 | return __comp(__a, __b) ? __b : __a; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | template <class _Tp> | 33 | template <class _Tp> |
| 34 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | 34 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& |
| 35 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { | 35 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { |
| 36 | return std::max(__a, __b, __less<>()); | 36 | return std::max(__a, __b, __less<>()); |
| 37 | } | 37 | } |
| ... | @@ -39,13 +39,13 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) | ... | @@ -39,13 +39,13 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) |
| 39 | #ifndef _LIBCPP_CXX03_LANG | 39 | #ifndef _LIBCPP_CXX03_LANG |
| 40 | 40 | ||
| 41 | template <class _Tp, class _Compare> | 41 | template <class _Tp, class _Compare> |
| 42 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp | 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp |
| 43 | max(initializer_list<_Tp> __t, _Compare __comp) { | 43 | max(initializer_list<_Tp> __t, _Compare __comp) { |
| 44 | return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); | 44 | return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | template <class _Tp> | 47 | template <class _Tp> |
| 48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) { | 48 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) { |
| 49 | return *std::max_element(__t.begin(), __t.end(), __less<>()); | 49 | return *std::max_element(__t.begin(), __t.end(), __less<>()); |
| 50 | } | 50 | } |
| 51 | 51 |
lib/libcxx/include/__algorithm/max_element.h+2-2| ... | @@ -35,13 +35,13 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp | ... | @@ -35,13 +35,13 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | template <class _ForwardIterator, class _Compare> | 37 | template <class _ForwardIterator, class _Compare> |
| 38 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator |
| 39 | max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { | 39 | max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 40 | return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp); | 40 | return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | template <class _ForwardIterator> | 43 | template <class _ForwardIterator> |
| 44 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | 44 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator |
| 45 | max_element(_ForwardIterator __first, _ForwardIterator __last) { | 45 | max_element(_ForwardIterator __first, _ForwardIterator __last) { |
| 46 | return std::max_element(__first, __last, __less<>()); | 46 | return std::max_element(__first, __last, __less<>()); |
| 47 | } | 47 | } |
lib/libcxx/include/__algorithm/min.h+4-4| ... | @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _Tp, class _Compare> | 27 | template <class _Tp, class _Compare> |
| 28 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& |
| 29 | min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { | 29 | min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { |
| 30 | return __comp(__b, __a) ? __b : __a; | 30 | return __comp(__b, __a) ? __b : __a; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | template <class _Tp> | 33 | template <class _Tp> |
| 34 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | 34 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& |
| 35 | min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { | 35 | min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { |
| 36 | return std::min(__a, __b, __less<>()); | 36 | return std::min(__a, __b, __less<>()); |
| 37 | } | 37 | } |
| ... | @@ -39,13 +39,13 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) | ... | @@ -39,13 +39,13 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) |
| 39 | #ifndef _LIBCPP_CXX03_LANG | 39 | #ifndef _LIBCPP_CXX03_LANG |
| 40 | 40 | ||
| 41 | template <class _Tp, class _Compare> | 41 | template <class _Tp, class _Compare> |
| 42 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp | 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp |
| 43 | min(initializer_list<_Tp> __t, _Compare __comp) { | 43 | min(initializer_list<_Tp> __t, _Compare __comp) { |
| 44 | return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); | 44 | return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | template <class _Tp> | 47 | template <class _Tp> |
| 48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) { | 48 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) { |
| 49 | return *std::min_element(__t.begin(), __t.end(), __less<>()); | 49 | return *std::min_element(__t.begin(), __t.end(), __less<>()); |
| 50 | } | 50 | } |
| 51 | 51 |
lib/libcxx/include/__algorithm/min_element.h+2-2| ... | @@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __ | ... | @@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __ |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | template <class _ForwardIterator, class _Compare> | 50 | template <class _ForwardIterator, class _Compare> |
| 51 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | 51 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator |
| 52 | min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { | 52 | min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 53 | static_assert( | 53 | static_assert( |
| 54 | __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator"); | 54 | __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator"); |
| ... | @@ -59,7 +59,7 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | ... | @@ -59,7 +59,7 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | template <class _ForwardIterator> | 61 | template <class _ForwardIterator> |
| 62 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | 62 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator |
| 63 | min_element(_ForwardIterator __first, _ForwardIterator __last) { | 63 | min_element(_ForwardIterator __first, _ForwardIterator __last) { |
| 64 | return std::min_element(__first, __last, __less<>()); | 64 | return std::min_element(__first, __last, __less<>()); |
| 65 | } | 65 | } |
lib/libcxx/include/__algorithm/minmax.h+4-4| ... | @@ -24,13 +24,13 @@ | ... | @@ -24,13 +24,13 @@ |
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | template <class _Tp, class _Compare> | 26 | template <class _Tp, class _Compare> |
| 27 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> | 27 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> |
| 28 | minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { | 28 | minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { |
| 29 | return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b); | 29 | return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | template <class _Tp> | 32 | template <class _Tp> |
| 33 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> | 33 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> |
| 34 | minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { | 34 | minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { |
| 35 | return std::minmax(__a, __b, __less<>()); | 35 | return std::minmax(__a, __b, __less<>()); |
| 36 | } | 36 | } |
| ... | @@ -38,7 +38,7 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __ | ... | @@ -38,7 +38,7 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __ |
| 38 | #ifndef _LIBCPP_CXX03_LANG | 38 | #ifndef _LIBCPP_CXX03_LANG |
| 39 | 39 | ||
| 40 | template <class _Tp, class _Compare> | 40 | template <class _Tp, class _Compare> |
| 41 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> | 41 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> |
| 42 | minmax(initializer_list<_Tp> __t, _Compare __comp) { | 42 | minmax(initializer_list<_Tp> __t, _Compare __comp) { |
| 43 | static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable"); | 43 | static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable"); |
| 44 | __identity __proj; | 44 | __identity __proj; |
| ... | @@ -47,7 +47,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp) { | ... | @@ -47,7 +47,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp) { |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | template <class _Tp> | 49 | template <class _Tp> |
| 50 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> | 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> |
| 51 | minmax(initializer_list<_Tp> __t) { | 51 | minmax(initializer_list<_Tp> __t) { |
| 52 | return std::minmax(__t, __less<>()); | 52 | return std::minmax(__t, __less<>()); |
| 53 | } | 53 | } |
lib/libcxx/include/__algorithm/minmax_element.h+3-4| ... | @@ -79,7 +79,7 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) | ... | @@ -79,7 +79,7 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | template <class _ForwardIterator, class _Compare> | 81 | template <class _ForwardIterator, class _Compare> |
| 82 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> | 82 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> |
| 83 | minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { | 83 | minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 84 | static_assert( | 84 | static_assert( |
| 85 | __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator"); | 85 | __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator"); |
| ... | @@ -90,9 +90,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com | ... | @@ -90,9 +90,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | template <class _ForwardIterator> | 92 | template <class _ForwardIterator> |
| 93 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 93 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> |
| 94 | pair<_ForwardIterator, _ForwardIterator> | 94 | minmax_element(_ForwardIterator __first, _ForwardIterator __last) { |
| 95 | minmax_element(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 96 | return std::minmax_element(__first, __last, __less<>()); | 95 | return std::minmax_element(__first, __last, __less<>()); |
| 97 | } | 96 | } |
| 98 | 97 |
lib/libcxx/include/__algorithm/mismatch.h+168-13| ... | @@ -11,47 +11,200 @@ | ... | @@ -11,47 +11,200 @@ |
| 11 | #define _LIBCPP___ALGORITHM_MISMATCH_H | 11 | #define _LIBCPP___ALGORITHM_MISMATCH_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/comp.h> | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/min.h> | ||
| 15 | #include <__algorithm/simd_utils.h> | ||
| 16 | #include <__algorithm/unwrap_iter.h> | ||
| 14 | #include <__config> | 17 | #include <__config> |
| 15 | #include <__iterator/iterator_traits.h> | 18 | #include <__functional/identity.h> |
| 19 | #include <__iterator/aliasing_iterator.h> | ||
| 20 | #include <__type_traits/desugars_to.h> | ||
| 21 | #include <__type_traits/invoke.h> | ||
| 22 | #include <__type_traits/is_constant_evaluated.h> | ||
| 23 | #include <__type_traits/is_equality_comparable.h> | ||
| 24 | #include <__type_traits/is_integral.h> | ||
| 25 | #include <__utility/move.h> | ||
| 16 | #include <__utility/pair.h> | 26 | #include <__utility/pair.h> |
| 27 | #include <__utility/unreachable.h> | ||
| 28 | #include <cstddef> | ||
| 17 | 29 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header | 31 | # pragma GCC system_header |
| 20 | #endif | 32 | #endif |
| 21 | 33 | ||
| 34 | _LIBCPP_PUSH_MACROS | ||
| 35 | #include <__undef_macros> | ||
| 36 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 38 | ||
| 39 | template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2> | ||
| 40 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> | ||
| 41 | __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 42 | while (__first1 != __last1) { | ||
| 43 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | ||
| 44 | break; | ||
| 45 | ++__first1; | ||
| 46 | ++__first2; | ||
| 47 | } | ||
| 48 | return std::make_pair(std::move(__first1), std::move(__first2)); | ||
| 49 | } | ||
| 50 | |||
| 51 | template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2> | ||
| 52 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> | ||
| 53 | __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 54 | return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2); | ||
| 55 | } | ||
| 56 | |||
| 57 | #if _LIBCPP_VECTORIZE_ALGORITHMS | ||
| 58 | |||
| 59 | template <class _Iter> | ||
| 60 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> | ||
| 61 | __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { | ||
| 62 | using __value_type = __iter_value_type<_Iter>; | ||
| 63 | constexpr size_t __unroll_count = 4; | ||
| 64 | constexpr size_t __vec_size = __native_vector_size<__value_type>; | ||
| 65 | using __vec = __simd_vector<__value_type, __vec_size>; | ||
| 66 | |||
| 67 | if (!__libcpp_is_constant_evaluated()) { | ||
| 68 | auto __orig_first1 = __first1; | ||
| 69 | auto __last2 = __first2 + (__last1 - __first1); | ||
| 70 | while (static_cast<size_t>(__last1 - __first1) >= __unroll_count * __vec_size) [[__unlikely__]] { | ||
| 71 | __vec __lhs[__unroll_count]; | ||
| 72 | __vec __rhs[__unroll_count]; | ||
| 73 | |||
| 74 | for (size_t __i = 0; __i != __unroll_count; ++__i) { | ||
| 75 | __lhs[__i] = std::__load_vector<__vec>(__first1 + __i * __vec_size); | ||
| 76 | __rhs[__i] = std::__load_vector<__vec>(__first2 + __i * __vec_size); | ||
| 77 | } | ||
| 78 | |||
| 79 | for (size_t __i = 0; __i != __unroll_count; ++__i) { | ||
| 80 | if (auto __cmp_res = __lhs[__i] == __rhs[__i]; !std::__all_of(__cmp_res)) { | ||
| 81 | auto __offset = __i * __vec_size + std::__find_first_not_set(__cmp_res); | ||
| 82 | return {__first1 + __offset, __first2 + __offset}; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | __first1 += __unroll_count * __vec_size; | ||
| 87 | __first2 += __unroll_count * __vec_size; | ||
| 88 | } | ||
| 89 | |||
| 90 | // check the remaining 0-3 vectors | ||
| 91 | while (static_cast<size_t>(__last1 - __first1) >= __vec_size) { | ||
| 92 | if (auto __cmp_res = std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2); | ||
| 93 | !std::__all_of(__cmp_res)) { | ||
| 94 | auto __offset = std::__find_first_not_set(__cmp_res); | ||
| 95 | return {__first1 + __offset, __first2 + __offset}; | ||
| 96 | } | ||
| 97 | __first1 += __vec_size; | ||
| 98 | __first2 += __vec_size; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (__last1 - __first1 == 0) | ||
| 102 | return {__first1, __first2}; | ||
| 103 | |||
| 104 | // Check if we can load elements in front of the current pointer. If that's the case load a vector at | ||
| 105 | // (last - vector_size) to check the remaining elements | ||
| 106 | if (static_cast<size_t>(__first1 - __orig_first1) >= __vec_size) { | ||
| 107 | __first1 = __last1 - __vec_size; | ||
| 108 | __first2 = __last2 - __vec_size; | ||
| 109 | auto __offset = | ||
| 110 | std::__find_first_not_set(std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2)); | ||
| 111 | return {__first1 + __offset, __first2 + __offset}; | ||
| 112 | } // else loop over the elements individually | ||
| 113 | } | ||
| 114 | |||
| 115 | __equal_to __pred; | ||
| 116 | __identity __proj; | ||
| 117 | return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj, __proj); | ||
| 118 | } | ||
| 119 | |||
| 120 | template <class _Tp, | ||
| 121 | class _Pred, | ||
| 122 | class _Proj1, | ||
| 123 | class _Proj2, | ||
| 124 | __enable_if_t<is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> && | ||
| 125 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value, | ||
| 126 | int> = 0> | ||
| 127 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | ||
| 128 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred&, _Proj1&, _Proj2&) { | ||
| 129 | return std::__mismatch_vectorized(__first1, __last1, __first2); | ||
| 130 | } | ||
| 131 | |||
| 132 | template <class _Tp, | ||
| 133 | class _Pred, | ||
| 134 | class _Proj1, | ||
| 135 | class _Proj2, | ||
| 136 | __enable_if_t<!is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> && | ||
| 137 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value && | ||
| 138 | __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, | ||
| 139 | int> = 0> | ||
| 140 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | ||
| 141 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 142 | if (__libcpp_is_constant_evaluated()) { | ||
| 143 | return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2); | ||
| 144 | } else { | ||
| 145 | using _Iter = __aliasing_iterator<_Tp*, __get_as_integer_type_t<_Tp>>; | ||
| 146 | auto __ret = std::__mismatch_vectorized(_Iter(__first1), _Iter(__last1), _Iter(__first2)); | ||
| 147 | return {__ret.first.__base(), __ret.second.__base()}; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | #endif // _LIBCPP_VECTORIZE_ALGORITHMS | ||
| 151 | |||
| 24 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 152 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 25 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | 153 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> |
| 26 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { | 154 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { |
| 27 | for (; __first1 != __last1; ++__first1, (void)++__first2) | 155 | __identity __proj; |
| 28 | if (!__pred(*__first1, *__first2)) | 156 | auto __res = std::__mismatch( |
| 29 | break; | 157 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred, __proj, __proj); |
| 30 | return pair<_InputIterator1, _InputIterator2>(__first1, __first2); | 158 | return std::make_pair(std::__rewrap_iter(__first1, __res.first), std::__rewrap_iter(__first2, __res.second)); |
| 31 | } | 159 | } |
| 32 | 160 | ||
| 33 | template <class _InputIterator1, class _InputIterator2> | 161 | template <class _InputIterator1, class _InputIterator2> |
| 34 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | 162 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> |
| 35 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { | 163 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { |
| 36 | return std::mismatch(__first1, __last1, __first2, __equal_to()); | 164 | return std::mismatch(__first1, __last1, __first2, __equal_to()); |
| 37 | } | 165 | } |
| 38 | 166 | ||
| 39 | #if _LIBCPP_STD_VER >= 14 | 167 | #if _LIBCPP_STD_VER >= 14 |
| 168 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | ||
| 169 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch( | ||
| 170 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 171 | while (__first1 != __last1 && __first2 != __last2) { | ||
| 172 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | ||
| 173 | break; | ||
| 174 | ++__first1; | ||
| 175 | ++__first2; | ||
| 176 | } | ||
| 177 | return {std::move(__first1), std::move(__first2)}; | ||
| 178 | } | ||
| 179 | |||
| 180 | template <class _Tp, class _Pred, class _Proj1, class _Proj2> | ||
| 181 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | ||
| 182 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 183 | auto __len = std::min(__last1 - __first1, __last2 - __first2); | ||
| 184 | return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2); | ||
| 185 | } | ||
| 186 | |||
| 40 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 187 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 41 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | 188 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> |
| 42 | mismatch(_InputIterator1 __first1, | 189 | mismatch(_InputIterator1 __first1, |
| 43 | _InputIterator1 __last1, | 190 | _InputIterator1 __last1, |
| 44 | _InputIterator2 __first2, | 191 | _InputIterator2 __first2, |
| 45 | _InputIterator2 __last2, | 192 | _InputIterator2 __last2, |
| 46 | _BinaryPredicate __pred) { | 193 | _BinaryPredicate __pred) { |
| 47 | for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) | 194 | __identity __proj; |
| 48 | if (!__pred(*__first1, *__first2)) | 195 | auto __res = std::__mismatch( |
| 49 | break; | 196 | std::__unwrap_iter(__first1), |
| 50 | return pair<_InputIterator1, _InputIterator2>(__first1, __first2); | 197 | std::__unwrap_iter(__last1), |
| 198 | std::__unwrap_iter(__first2), | ||
| 199 | std::__unwrap_iter(__last2), | ||
| 200 | __pred, | ||
| 201 | __proj, | ||
| 202 | __proj); | ||
| 203 | return {std::__rewrap_iter(__first1, __res.first), std::__rewrap_iter(__first2, __res.second)}; | ||
| 51 | } | 204 | } |
| 52 | 205 | ||
| 53 | template <class _InputIterator1, class _InputIterator2> | 206 | template <class _InputIterator1, class _InputIterator2> |
| 54 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | 207 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> |
| 55 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | 208 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 56 | return std::mismatch(__first1, __last1, __first2, __last2, __equal_to()); | 209 | return std::mismatch(__first1, __last1, __first2, __last2, __equal_to()); |
| 57 | } | 210 | } |
| ... | @@ -59,4 +212,6 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi | ... | @@ -59,4 +212,6 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi |
| 59 | 212 | ||
| 60 | _LIBCPP_END_NAMESPACE_STD | 213 | _LIBCPP_END_NAMESPACE_STD |
| 61 | 214 | ||
| 215 | _LIBCPP_POP_MACROS | ||
| 216 | |||
| 62 | #endif // _LIBCPP___ALGORITHM_MISMATCH_H | 217 | #endif // _LIBCPP___ALGORITHM_MISMATCH_H |
lib/libcxx/include/__algorithm/move.h+3-5| ... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__iterator/segmented_iterator.h> | 17 | #include <__iterator/segmented_iterator.h> |
| 18 | #include <__type_traits/common_type.h> | 18 | #include <__type_traits/common_type.h> |
| 19 | #include <__type_traits/is_copy_constructible.h> | 19 | #include <__type_traits/is_constructible.h> |
| 20 | #include <__utility/move.h> | 20 | #include <__utility/move.h> |
| 21 | #include <__utility/pair.h> | 21 | #include <__utility/pair.h> |
| 22 | 22 | ||
| ... | @@ -34,7 +34,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIte | ... | @@ -34,7 +34,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIte |
| 34 | __move(_InIter __first, _Sent __last, _OutIter __result); | 34 | __move(_InIter __first, _Sent __last, _OutIter __result); |
| 35 | 35 | ||
| 36 | template <class _AlgPolicy> | 36 | template <class _AlgPolicy> |
| 37 | struct __move_loop { | 37 | struct __move_impl { |
| 38 | template <class _InIter, class _Sent, class _OutIter> | 38 | template <class _InIter, class _Sent, class _OutIter> |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 40 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { | 40 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { |
| ... | @@ -95,9 +95,7 @@ struct __move_loop { | ... | @@ -95,9 +95,7 @@ struct __move_loop { |
| 95 | __local_first = _Traits::__begin(++__segment_iterator); | 95 | __local_first = _Traits::__begin(++__segment_iterator); |
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | }; | ||
| 99 | 98 | ||
| 100 | struct __move_trivial { | ||
| 101 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 99 | // 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> | 100 | 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*> | 101 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
| ... | @@ -109,7 +107,7 @@ struct __move_trivial { | ... | @@ -109,7 +107,7 @@ struct __move_trivial { |
| 109 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> | 107 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> |
| 110 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 108 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 111 | __move(_InIter __first, _Sent __last, _OutIter __result) { | 109 | __move(_InIter __first, _Sent __last, _OutIter __result) { |
| 112 | return std::__dispatch_copy_or_move<_AlgPolicy, __move_loop<_AlgPolicy>, __move_trivial>( | 110 | return std::__copy_move_unwrap_iters<__move_impl<_AlgPolicy> >( |
| 113 | std::move(__first), std::move(__last), std::move(__result)); | 111 | std::move(__first), std::move(__last), std::move(__result)); |
| 114 | } | 112 | } |
| 115 | 113 |
lib/libcxx/include/__algorithm/move_backward.h+3-5| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__iterator/segmented_iterator.h> | 16 | #include <__iterator/segmented_iterator.h> |
| 17 | #include <__type_traits/common_type.h> | 17 | #include <__type_traits/common_type.h> |
| 18 | #include <__type_traits/is_copy_constructible.h> | 18 | #include <__type_traits/is_constructible.h> |
| 19 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| 20 | #include <__utility/pair.h> | 20 | #include <__utility/pair.h> |
| 21 | 21 | ||
| ... | @@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1 | ... | @@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1 |
| 33 | __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result); | 33 | __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result); |
| 34 | 34 | ||
| 35 | template <class _AlgPolicy> | 35 | template <class _AlgPolicy> |
| 36 | struct __move_backward_loop { | 36 | struct __move_backward_impl { |
| 37 | template <class _InIter, class _Sent, class _OutIter> | 37 | template <class _InIter, class _Sent, class _OutIter> |
| 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 39 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { | 39 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { |
| ... | @@ -104,9 +104,7 @@ struct __move_backward_loop { | ... | @@ -104,9 +104,7 @@ struct __move_backward_loop { |
| 104 | __local_last = _Traits::__end(--__segment_iterator); | 104 | __local_last = _Traits::__end(--__segment_iterator); |
| 105 | } | 105 | } |
| 106 | } | 106 | } |
| 107 | }; | ||
| 108 | 107 | ||
| 109 | struct __move_backward_trivial { | ||
| 110 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 108 | // 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> | 109 | 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*> | 110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
| ... | @@ -122,7 +120,7 @@ __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _Bidirectiona | ... | @@ -122,7 +120,7 @@ __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _Bidirectiona |
| 122 | std::is_copy_constructible<_BidirectionalIterator1>::value, | 120 | std::is_copy_constructible<_BidirectionalIterator1>::value, |
| 123 | "Iterators must be copy constructible."); | 121 | "Iterators must be copy constructible."); |
| 124 | 122 | ||
| 125 | return std::__dispatch_copy_or_move<_AlgPolicy, __move_backward_loop<_AlgPolicy>, __move_backward_trivial>( | 123 | return std::__copy_move_unwrap_iters<__move_backward_impl<_AlgPolicy> >( |
| 126 | std::move(__first), std::move(__last), std::move(__result)); | 124 | std::move(__first), std::move(__last), std::move(__result)); |
| 127 | } | 125 | } |
| 128 | 126 |
lib/libcxx/include/__algorithm/none_of.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 _InputIterator, class _Predicate> | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 23 | none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 23 | none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | for (; __first != __last; ++__first) | 24 | for (; __first != __last; ++__first) |
| 25 | if (__pred(*__first)) | 25 | if (__pred(*__first)) |
lib/libcxx/include/__algorithm/partial_sort.h+2-2| ... | @@ -18,8 +18,8 @@ | ... | @@ -18,8 +18,8 @@ |
| 18 | #include <__config> | 18 | #include <__config> |
| 19 | #include <__debug_utils/randomize_range.h> | 19 | #include <__debug_utils/randomize_range.h> |
| 20 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__type_traits/is_copy_assignable.h> | 21 | #include <__type_traits/is_assignable.h> |
| 22 | #include <__type_traits/is_copy_constructible.h> | 22 | #include <__type_traits/is_constructible.h> |
| 23 | #include <__utility/move.h> | 23 | #include <__utility/move.h> |
| 24 | 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__algorithm/pop_heap.h+2-2| ... | @@ -17,8 +17,8 @@ | ... | @@ -17,8 +17,8 @@ |
| 17 | #include <__assert> | 17 | #include <__assert> |
| 18 | #include <__config> | 18 | #include <__config> |
| 19 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__type_traits/is_copy_assignable.h> | 20 | #include <__type_traits/is_assignable.h> |
| 21 | #include <__type_traits/is_copy_constructible.h> | 21 | #include <__type_traits/is_constructible.h> |
| 22 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 23 | 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__algorithm/pstl.h created+663| ... | @@ -0,0 +1,663 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_PUSH_MACROS | ||
| 19 | #include <__undef_macros> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 22 | |||
| 23 | # include <__functional/operations.h> | ||
| 24 | # include <__iterator/cpp17_iterator_concepts.h> | ||
| 25 | # include <__iterator/iterator_traits.h> | ||
| 26 | # include <__pstl/backend.h> | ||
| 27 | # include <__pstl/dispatch.h> | ||
| 28 | # include <__pstl/handle_exception.h> | ||
| 29 | # include <__type_traits/enable_if.h> | ||
| 30 | # include <__type_traits/is_execution_policy.h> | ||
| 31 | # include <__type_traits/remove_cvref.h> | ||
| 32 | # include <__utility/forward.h> | ||
| 33 | # include <__utility/move.h> | ||
| 34 | |||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 36 | |||
| 37 | template <class _ExecutionPolicy, | ||
| 38 | class _ForwardIterator, | ||
| 39 | class _Predicate, | ||
| 40 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 41 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 42 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool | ||
| 43 | any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 44 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "any_of requires a ForwardIterator"); | ||
| 45 | using _Implementation = __pstl::__dispatch<__pstl::__any_of, __pstl::__current_configuration, _RawPolicy>; | ||
| 46 | return __pstl::__handle_exception<_Implementation>( | ||
| 47 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 48 | } | ||
| 49 | |||
| 50 | template <class _ExecutionPolicy, | ||
| 51 | class _ForwardIterator, | ||
| 52 | class _Pred, | ||
| 53 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 54 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool | ||
| 56 | all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { | ||
| 57 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "all_of requires a ForwardIterator"); | ||
| 58 | using _Implementation = __pstl::__dispatch<__pstl::__all_of, __pstl::__current_configuration, _RawPolicy>; | ||
| 59 | return __pstl::__handle_exception<_Implementation>( | ||
| 60 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 61 | } | ||
| 62 | |||
| 63 | template <class _ExecutionPolicy, | ||
| 64 | class _ForwardIterator, | ||
| 65 | class _Pred, | ||
| 66 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 67 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool | ||
| 69 | none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { | ||
| 70 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "none_of requires a ForwardIterator"); | ||
| 71 | using _Implementation = __pstl::__dispatch<__pstl::__none_of, __pstl::__current_configuration, _RawPolicy>; | ||
| 72 | return __pstl::__handle_exception<_Implementation>( | ||
| 73 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 74 | } | ||
| 75 | |||
| 76 | template <class _ExecutionPolicy, | ||
| 77 | class _ForwardIterator, | ||
| 78 | class _ForwardOutIterator, | ||
| 79 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 80 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 81 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 82 | copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) { | ||
| 83 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | ||
| 84 | _ForwardIterator, "copy(first, last, result) requires [first, last) to be ForwardIterators"); | ||
| 85 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | ||
| 86 | _ForwardOutIterator, "copy(first, last, result) requires result to be a ForwardIterator"); | ||
| 87 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 88 | _ForwardOutIterator, decltype(*__first), "copy(first, last, result) requires result to be an OutputIterator"); | ||
| 89 | using _Implementation = __pstl::__dispatch<__pstl::__copy, __pstl::__current_configuration, _RawPolicy>; | ||
| 90 | return __pstl::__handle_exception<_Implementation>( | ||
| 91 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result)); | ||
| 92 | } | ||
| 93 | |||
| 94 | template <class _ExecutionPolicy, | ||
| 95 | class _ForwardIterator, | ||
| 96 | class _ForwardOutIterator, | ||
| 97 | class _Size, | ||
| 98 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 99 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 100 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 101 | copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) { | ||
| 102 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | ||
| 103 | _ForwardIterator, "copy_n(first, n, result) requires first to be a ForwardIterator"); | ||
| 104 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | ||
| 105 | _ForwardOutIterator, "copy_n(first, n, result) requires result to be a ForwardIterator"); | ||
| 106 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 107 | _ForwardOutIterator, decltype(*__first), "copy_n(first, n, result) requires result to be an OutputIterator"); | ||
| 108 | using _Implementation = __pstl::__dispatch<__pstl::__copy_n, __pstl::__current_configuration, _RawPolicy>; | ||
| 109 | return __pstl::__handle_exception<_Implementation>( | ||
| 110 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__result)); | ||
| 111 | } | ||
| 112 | |||
| 113 | template <class _ExecutionPolicy, | ||
| 114 | class _ForwardIterator, | ||
| 115 | class _Predicate, | ||
| 116 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 117 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 118 | _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> | ||
| 119 | count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 120 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | ||
| 121 | _ForwardIterator, "count_if(first, last, pred) requires [first, last) to be ForwardIterators"); | ||
| 122 | using _Implementation = __pstl::__dispatch<__pstl::__count_if, __pstl::__current_configuration, _RawPolicy>; | ||
| 123 | return __pstl::__handle_exception<_Implementation>( | ||
| 124 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 125 | } | ||
| 126 | |||
| 127 | template <class _ExecutionPolicy, | ||
| 128 | class _ForwardIterator, | ||
| 129 | class _Tp, | ||
| 130 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 131 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 132 | _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> | ||
| 133 | count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 134 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | ||
| 135 | _ForwardIterator, "count(first, last, val) requires [first, last) to be ForwardIterators"); | ||
| 136 | using _Implementation = __pstl::__dispatch<__pstl::__count, __pstl::__current_configuration, _RawPolicy>; | ||
| 137 | return __pstl::__handle_exception<_Implementation>( | ||
| 138 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value); | ||
| 139 | } | ||
| 140 | |||
| 141 | template <class _ExecutionPolicy, | ||
| 142 | class _ForwardIterator1, | ||
| 143 | class _ForwardIterator2, | ||
| 144 | class _Pred, | ||
| 145 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 146 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 147 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 148 | equal(_ExecutionPolicy&& __policy, | ||
| 149 | _ForwardIterator1 __first1, | ||
| 150 | _ForwardIterator1 __last1, | ||
| 151 | _ForwardIterator2 __first2, | ||
| 152 | _Pred __pred) { | ||
| 153 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators"); | ||
| 154 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators"); | ||
| 155 | using _Implementation = __pstl::__dispatch<__pstl::__equal_3leg, __pstl::__current_configuration, _RawPolicy>; | ||
| 156 | return __pstl::__handle_exception<_Implementation>( | ||
| 157 | std::forward<_ExecutionPolicy>(__policy), | ||
| 158 | std::move(__first1), | ||
| 159 | std::move(__last1), | ||
| 160 | std::move(__first2), | ||
| 161 | std::move(__pred)); | ||
| 162 | } | ||
| 163 | |||
| 164 | template <class _ExecutionPolicy, | ||
| 165 | class _ForwardIterator1, | ||
| 166 | class _ForwardIterator2, | ||
| 167 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 168 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 169 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 170 | equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | ||
| 171 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators"); | ||
| 172 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators"); | ||
| 173 | using _Implementation = __pstl::__dispatch<__pstl::__equal_3leg, __pstl::__current_configuration, _RawPolicy>; | ||
| 174 | return __pstl::__handle_exception<_Implementation>( | ||
| 175 | std::forward<_ExecutionPolicy>(__policy), | ||
| 176 | std::move(__first1), | ||
| 177 | std::move(__last1), | ||
| 178 | std::move(__first2), | ||
| 179 | equal_to{}); | ||
| 180 | } | ||
| 181 | |||
| 182 | template <class _ExecutionPolicy, | ||
| 183 | class _ForwardIterator1, | ||
| 184 | class _ForwardIterator2, | ||
| 185 | class _Pred, | ||
| 186 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 187 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 188 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 189 | equal(_ExecutionPolicy&& __policy, | ||
| 190 | _ForwardIterator1 __first1, | ||
| 191 | _ForwardIterator1 __last1, | ||
| 192 | _ForwardIterator2 __first2, | ||
| 193 | _ForwardIterator2 __last2, | ||
| 194 | _Pred __pred) { | ||
| 195 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators"); | ||
| 196 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators"); | ||
| 197 | using _Implementation = __pstl::__dispatch<__pstl::__equal, __pstl::__current_configuration, _RawPolicy>; | ||
| 198 | return __pstl::__handle_exception<_Implementation>( | ||
| 199 | std::forward<_ExecutionPolicy>(__policy), | ||
| 200 | std::move(__first1), | ||
| 201 | std::move(__last1), | ||
| 202 | std::move(__first2), | ||
| 203 | std::move(__last2), | ||
| 204 | std::move(__pred)); | ||
| 205 | } | ||
| 206 | |||
| 207 | template <class _ExecutionPolicy, | ||
| 208 | class _ForwardIterator1, | ||
| 209 | class _ForwardIterator2, | ||
| 210 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 211 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 212 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 213 | equal(_ExecutionPolicy&& __policy, | ||
| 214 | _ForwardIterator1 __first1, | ||
| 215 | _ForwardIterator1 __last1, | ||
| 216 | _ForwardIterator2 __first2, | ||
| 217 | _ForwardIterator2 __last2) { | ||
| 218 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators"); | ||
| 219 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators"); | ||
| 220 | using _Implementation = __pstl::__dispatch<__pstl::__equal, __pstl::__current_configuration, _RawPolicy>; | ||
| 221 | return __pstl::__handle_exception<_Implementation>( | ||
| 222 | std::forward<_ExecutionPolicy>(__policy), | ||
| 223 | std::move(__first1), | ||
| 224 | std::move(__last1), | ||
| 225 | std::move(__first2), | ||
| 226 | std::move(__last2), | ||
| 227 | equal_to{}); | ||
| 228 | } | ||
| 229 | |||
| 230 | template <class _ExecutionPolicy, | ||
| 231 | class _ForwardIterator, | ||
| 232 | class _Tp, | ||
| 233 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 234 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 235 | _LIBCPP_HIDE_FROM_ABI void | ||
| 236 | fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 237 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "fill requires ForwardIterators"); | ||
| 238 | using _Implementation = __pstl::__dispatch<__pstl::__fill, __pstl::__current_configuration, _RawPolicy>; | ||
| 239 | __pstl::__handle_exception<_Implementation>( | ||
| 240 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value); | ||
| 241 | } | ||
| 242 | |||
| 243 | template <class _ExecutionPolicy, | ||
| 244 | class _ForwardIterator, | ||
| 245 | class _Size, | ||
| 246 | class _Tp, | ||
| 247 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 248 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 249 | _LIBCPP_HIDE_FROM_ABI void | ||
| 250 | fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, const _Tp& __value) { | ||
| 251 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "fill_n requires a ForwardIterator"); | ||
| 252 | using _Implementation = __pstl::__dispatch<__pstl::__fill_n, __pstl::__current_configuration, _RawPolicy>; | ||
| 253 | __pstl::__handle_exception<_Implementation>( | ||
| 254 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), __value); | ||
| 255 | } | ||
| 256 | |||
| 257 | template <class _ExecutionPolicy, | ||
| 258 | class _ForwardIterator, | ||
| 259 | class _Predicate, | ||
| 260 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 261 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 262 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | ||
| 263 | find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 264 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if requires ForwardIterators"); | ||
| 265 | using _Implementation = __pstl::__dispatch<__pstl::__find_if, __pstl::__current_configuration, _RawPolicy>; | ||
| 266 | return __pstl::__handle_exception<_Implementation>( | ||
| 267 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 268 | } | ||
| 269 | |||
| 270 | template <class _ExecutionPolicy, | ||
| 271 | class _ForwardIterator, | ||
| 272 | class _Predicate, | ||
| 273 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 274 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 275 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | ||
| 276 | find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 277 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if_not requires ForwardIterators"); | ||
| 278 | using _Implementation = __pstl::__dispatch<__pstl::__find_if_not, __pstl::__current_configuration, _RawPolicy>; | ||
| 279 | return __pstl::__handle_exception<_Implementation>( | ||
| 280 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 281 | } | ||
| 282 | |||
| 283 | template <class _ExecutionPolicy, | ||
| 284 | class _ForwardIterator, | ||
| 285 | class _Tp, | ||
| 286 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 287 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 288 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | ||
| 289 | find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 290 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find requires ForwardIterators"); | ||
| 291 | using _Implementation = __pstl::__dispatch<__pstl::__find, __pstl::__current_configuration, _RawPolicy>; | ||
| 292 | return __pstl::__handle_exception<_Implementation>( | ||
| 293 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value); | ||
| 294 | } | ||
| 295 | |||
| 296 | template <class _ExecutionPolicy, | ||
| 297 | class _ForwardIterator, | ||
| 298 | class _Function, | ||
| 299 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 300 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 301 | _LIBCPP_HIDE_FROM_ABI void | ||
| 302 | for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) { | ||
| 303 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "for_each requires ForwardIterators"); | ||
| 304 | using _Implementation = __pstl::__dispatch<__pstl::__for_each, __pstl::__current_configuration, _RawPolicy>; | ||
| 305 | __pstl::__handle_exception<_Implementation>( | ||
| 306 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__func)); | ||
| 307 | } | ||
| 308 | |||
| 309 | template <class _ExecutionPolicy, | ||
| 310 | class _ForwardIterator, | ||
| 311 | class _Size, | ||
| 312 | class _Function, | ||
| 313 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 314 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 315 | _LIBCPP_HIDE_FROM_ABI void | ||
| 316 | for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) { | ||
| 317 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "for_each_n requires a ForwardIterator"); | ||
| 318 | using _Implementation = __pstl::__dispatch<__pstl::__for_each_n, __pstl::__current_configuration, _RawPolicy>; | ||
| 319 | __pstl::__handle_exception<_Implementation>( | ||
| 320 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__size), std::move(__func)); | ||
| 321 | } | ||
| 322 | |||
| 323 | template <class _ExecutionPolicy, | ||
| 324 | class _ForwardIterator, | ||
| 325 | class _Generator, | ||
| 326 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 327 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 328 | _LIBCPP_HIDE_FROM_ABI void | ||
| 329 | generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { | ||
| 330 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "generate requires ForwardIterators"); | ||
| 331 | using _Implementation = __pstl::__dispatch<__pstl::__generate, __pstl::__current_configuration, _RawPolicy>; | ||
| 332 | __pstl::__handle_exception<_Implementation>( | ||
| 333 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__gen)); | ||
| 334 | } | ||
| 335 | |||
| 336 | template <class _ExecutionPolicy, | ||
| 337 | class _ForwardIterator, | ||
| 338 | class _Size, | ||
| 339 | class _Generator, | ||
| 340 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 341 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 342 | _LIBCPP_HIDE_FROM_ABI void | ||
| 343 | generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) { | ||
| 344 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "generate_n requires a ForwardIterator"); | ||
| 345 | using _Implementation = __pstl::__dispatch<__pstl::__generate_n, __pstl::__current_configuration, _RawPolicy>; | ||
| 346 | __pstl::__handle_exception<_Implementation>( | ||
| 347 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__gen)); | ||
| 348 | } | ||
| 349 | |||
| 350 | template <class _ExecutionPolicy, | ||
| 351 | class _ForwardIterator, | ||
| 352 | class _Predicate, | ||
| 353 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 354 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 355 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool | ||
| 356 | is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 357 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators"); | ||
| 358 | using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>; | ||
| 359 | return __pstl::__handle_exception<_Implementation>( | ||
| 360 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred)); | ||
| 361 | } | ||
| 362 | |||
| 363 | template <class _ExecutionPolicy, | ||
| 364 | class _ForwardIterator1, | ||
| 365 | class _ForwardIterator2, | ||
| 366 | class _ForwardOutIterator, | ||
| 367 | class _Comp, | ||
| 368 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 369 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 370 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 371 | merge(_ExecutionPolicy&& __policy, | ||
| 372 | _ForwardIterator1 __first1, | ||
| 373 | _ForwardIterator1 __last1, | ||
| 374 | _ForwardIterator2 __first2, | ||
| 375 | _ForwardIterator2 __last2, | ||
| 376 | _ForwardOutIterator __result, | ||
| 377 | _Comp __comp) { | ||
| 378 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "merge requires ForwardIterators"); | ||
| 379 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "merge requires ForwardIterators"); | ||
| 380 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first1), "merge requires an OutputIterator"); | ||
| 381 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first2), "merge requires an OutputIterator"); | ||
| 382 | using _Implementation = __pstl::__dispatch<__pstl::__merge, __pstl::__current_configuration, _RawPolicy>; | ||
| 383 | return __pstl::__handle_exception<_Implementation>( | ||
| 384 | std::forward<_ExecutionPolicy>(__policy), | ||
| 385 | std::move(__first1), | ||
| 386 | std::move(__last1), | ||
| 387 | std::move(__first2), | ||
| 388 | std::move(__last2), | ||
| 389 | std::move(__result), | ||
| 390 | std::move(__comp)); | ||
| 391 | } | ||
| 392 | |||
| 393 | template <class _ExecutionPolicy, | ||
| 394 | class _ForwardIterator1, | ||
| 395 | class _ForwardIterator2, | ||
| 396 | class _ForwardOutIterator, | ||
| 397 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 398 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 399 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 400 | merge(_ExecutionPolicy&& __policy, | ||
| 401 | _ForwardIterator1 __first1, | ||
| 402 | _ForwardIterator1 __last1, | ||
| 403 | _ForwardIterator2 __first2, | ||
| 404 | _ForwardIterator2 __last2, | ||
| 405 | _ForwardOutIterator __result) { | ||
| 406 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "merge requires ForwardIterators"); | ||
| 407 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "merge requires ForwardIterators"); | ||
| 408 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first1), "merge requires an OutputIterator"); | ||
| 409 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first2), "merge requires an OutputIterator"); | ||
| 410 | using _Implementation = __pstl::__dispatch<__pstl::__merge, __pstl::__current_configuration, _RawPolicy>; | ||
| 411 | return __pstl::__handle_exception<_Implementation>( | ||
| 412 | std::forward<_ExecutionPolicy>(__policy), | ||
| 413 | std::move(__first1), | ||
| 414 | std::move(__last1), | ||
| 415 | std::move(__first2), | ||
| 416 | std::move(__last2), | ||
| 417 | std::move(__result), | ||
| 418 | less{}); | ||
| 419 | } | ||
| 420 | |||
| 421 | template <class _ExecutionPolicy, | ||
| 422 | class _ForwardIterator, | ||
| 423 | class _ForwardOutIterator, | ||
| 424 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 425 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 426 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 427 | move(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) { | ||
| 428 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "move requires ForwardIterators"); | ||
| 429 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "move requires an OutputIterator"); | ||
| 430 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 431 | _ForwardOutIterator, decltype(std::move(*__first)), "move requires an OutputIterator"); | ||
| 432 | using _Implementation = __pstl::__dispatch<__pstl::__move, __pstl::__current_configuration, _RawPolicy>; | ||
| 433 | return __pstl::__handle_exception<_Implementation>( | ||
| 434 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result)); | ||
| 435 | } | ||
| 436 | |||
| 437 | template <class _ExecutionPolicy, | ||
| 438 | class _ForwardIterator, | ||
| 439 | class _Pred, | ||
| 440 | class _Tp, | ||
| 441 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 442 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 443 | _LIBCPP_HIDE_FROM_ABI void | ||
| 444 | replace_if(_ExecutionPolicy&& __policy, | ||
| 445 | _ForwardIterator __first, | ||
| 446 | _ForwardIterator __last, | ||
| 447 | _Pred __pred, | ||
| 448 | const _Tp& __new_value) { | ||
| 449 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_if requires ForwardIterators"); | ||
| 450 | using _Implementation = __pstl::__dispatch<__pstl::__replace_if, __pstl::__current_configuration, _RawPolicy>; | ||
| 451 | __pstl::__handle_exception<_Implementation>( | ||
| 452 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred), __new_value); | ||
| 453 | } | ||
| 454 | |||
| 455 | template <class _ExecutionPolicy, | ||
| 456 | class _ForwardIterator, | ||
| 457 | class _Tp, | ||
| 458 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 459 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 460 | _LIBCPP_HIDE_FROM_ABI void | ||
| 461 | replace(_ExecutionPolicy&& __policy, | ||
| 462 | _ForwardIterator __first, | ||
| 463 | _ForwardIterator __last, | ||
| 464 | const _Tp& __old_value, | ||
| 465 | const _Tp& __new_value) { | ||
| 466 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace requires ForwardIterators"); | ||
| 467 | using _Implementation = __pstl::__dispatch<__pstl::__replace, __pstl::__current_configuration, _RawPolicy>; | ||
| 468 | __pstl::__handle_exception<_Implementation>( | ||
| 469 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __old_value, __new_value); | ||
| 470 | } | ||
| 471 | |||
| 472 | template <class _ExecutionPolicy, | ||
| 473 | class _ForwardIterator, | ||
| 474 | class _ForwardOutIterator, | ||
| 475 | class _Pred, | ||
| 476 | class _Tp, | ||
| 477 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 478 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 479 | _LIBCPP_HIDE_FROM_ABI void replace_copy_if( | ||
| 480 | _ExecutionPolicy&& __policy, | ||
| 481 | _ForwardIterator __first, | ||
| 482 | _ForwardIterator __last, | ||
| 483 | _ForwardOutIterator __result, | ||
| 484 | _Pred __pred, | ||
| 485 | const _Tp& __new_value) { | ||
| 486 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_copy_if requires ForwardIterators"); | ||
| 487 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "replace_copy_if requires ForwardIterators"); | ||
| 488 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 489 | _ForwardOutIterator, decltype(*__first), "replace_copy_if requires an OutputIterator"); | ||
| 490 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, const _Tp&, "replace_copy requires an OutputIterator"); | ||
| 491 | using _Implementation = __pstl::__dispatch<__pstl::__replace_copy_if, __pstl::__current_configuration, _RawPolicy>; | ||
| 492 | __pstl::__handle_exception<_Implementation>( | ||
| 493 | std::forward<_ExecutionPolicy>(__policy), | ||
| 494 | std::move(__first), | ||
| 495 | std::move(__last), | ||
| 496 | std::move(__result), | ||
| 497 | std::move(__pred), | ||
| 498 | __new_value); | ||
| 499 | } | ||
| 500 | |||
| 501 | template <class _ExecutionPolicy, | ||
| 502 | class _ForwardIterator, | ||
| 503 | class _ForwardOutIterator, | ||
| 504 | class _Tp, | ||
| 505 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 506 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 507 | _LIBCPP_HIDE_FROM_ABI void replace_copy( | ||
| 508 | _ExecutionPolicy&& __policy, | ||
| 509 | _ForwardIterator __first, | ||
| 510 | _ForwardIterator __last, | ||
| 511 | _ForwardOutIterator __result, | ||
| 512 | const _Tp& __old_value, | ||
| 513 | const _Tp& __new_value) { | ||
| 514 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_copy requires ForwardIterators"); | ||
| 515 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "replace_copy requires ForwardIterators"); | ||
| 516 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 517 | _ForwardOutIterator, decltype(*__first), "replace_copy requires an OutputIterator"); | ||
| 518 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, const _Tp&, "replace_copy requires an OutputIterator"); | ||
| 519 | using _Implementation = __pstl::__dispatch<__pstl::__replace_copy, __pstl::__current_configuration, _RawPolicy>; | ||
| 520 | __pstl::__handle_exception<_Implementation>( | ||
| 521 | std::forward<_ExecutionPolicy>(__policy), | ||
| 522 | std::move(__first), | ||
| 523 | std::move(__last), | ||
| 524 | std::move(__result), | ||
| 525 | __old_value, | ||
| 526 | __new_value); | ||
| 527 | } | ||
| 528 | |||
| 529 | template <class _ExecutionPolicy, | ||
| 530 | class _ForwardIterator, | ||
| 531 | class _ForwardOutIterator, | ||
| 532 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 533 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 534 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator rotate_copy( | ||
| 535 | _ExecutionPolicy&& __policy, | ||
| 536 | _ForwardIterator __first, | ||
| 537 | _ForwardIterator __middle, | ||
| 538 | _ForwardIterator __last, | ||
| 539 | _ForwardOutIterator __result) { | ||
| 540 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "rotate_copy requires ForwardIterators"); | ||
| 541 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "rotate_copy requires ForwardIterators"); | ||
| 542 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 543 | _ForwardOutIterator, decltype(*__first), "rotate_copy requires an OutputIterator"); | ||
| 544 | using _Implementation = __pstl::__dispatch<__pstl::__rotate_copy, __pstl::__current_configuration, _RawPolicy>; | ||
| 545 | return __pstl::__handle_exception<_Implementation>( | ||
| 546 | std::forward<_ExecutionPolicy>(__policy), | ||
| 547 | std::move(__first), | ||
| 548 | std::move(__middle), | ||
| 549 | std::move(__last), | ||
| 550 | std::move(__result)); | ||
| 551 | } | ||
| 552 | |||
| 553 | template <class _ExecutionPolicy, | ||
| 554 | class _RandomAccessIterator, | ||
| 555 | class _Comp, | ||
| 556 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 557 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 558 | _LIBCPP_HIDE_FROM_ABI void | ||
| 559 | sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { | ||
| 560 | _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "sort requires RandomAccessIterators"); | ||
| 561 | using _Implementation = __pstl::__dispatch<__pstl::__sort, __pstl::__current_configuration, _RawPolicy>; | ||
| 562 | __pstl::__handle_exception<_Implementation>( | ||
| 563 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp)); | ||
| 564 | } | ||
| 565 | |||
| 566 | template <class _ExecutionPolicy, | ||
| 567 | class _RandomAccessIterator, | ||
| 568 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 569 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 570 | _LIBCPP_HIDE_FROM_ABI void | ||
| 571 | sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) { | ||
| 572 | _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "sort requires RandomAccessIterators"); | ||
| 573 | using _Implementation = __pstl::__dispatch<__pstl::__sort, __pstl::__current_configuration, _RawPolicy>; | ||
| 574 | __pstl::__handle_exception<_Implementation>( | ||
| 575 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{}); | ||
| 576 | } | ||
| 577 | |||
| 578 | template <class _ExecutionPolicy, | ||
| 579 | class _RandomAccessIterator, | ||
| 580 | class _Comp, | ||
| 581 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 582 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 583 | _LIBCPP_HIDE_FROM_ABI void | ||
| 584 | stable_sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { | ||
| 585 | _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "stable_sort requires RandomAccessIterators"); | ||
| 586 | using _Implementation = __pstl::__dispatch<__pstl::__stable_sort, __pstl::__current_configuration, _RawPolicy>; | ||
| 587 | __pstl::__handle_exception<_Implementation>( | ||
| 588 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp)); | ||
| 589 | } | ||
| 590 | |||
| 591 | template <class _ExecutionPolicy, | ||
| 592 | class _RandomAccessIterator, | ||
| 593 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 594 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 595 | _LIBCPP_HIDE_FROM_ABI void | ||
| 596 | stable_sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) { | ||
| 597 | _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "stable_sort requires RandomAccessIterators"); | ||
| 598 | using _Implementation = __pstl::__dispatch<__pstl::__stable_sort, __pstl::__current_configuration, _RawPolicy>; | ||
| 599 | __pstl::__handle_exception<_Implementation>( | ||
| 600 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{}); | ||
| 601 | } | ||
| 602 | |||
| 603 | template <class _ExecutionPolicy, | ||
| 604 | class _ForwardIterator, | ||
| 605 | class _ForwardOutIterator, | ||
| 606 | class _UnaryOperation, | ||
| 607 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 608 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 609 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( | ||
| 610 | _ExecutionPolicy&& __policy, | ||
| 611 | _ForwardIterator __first, | ||
| 612 | _ForwardIterator __last, | ||
| 613 | _ForwardOutIterator __result, | ||
| 614 | _UnaryOperation __op) { | ||
| 615 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "transform requires ForwardIterators"); | ||
| 616 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "transform requires an OutputIterator"); | ||
| 617 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 618 | _ForwardOutIterator, decltype(__op(*__first)), "transform requires an OutputIterator"); | ||
| 619 | using _Implementation = __pstl::__dispatch<__pstl::__transform, __pstl::__current_configuration, _RawPolicy>; | ||
| 620 | return __pstl::__handle_exception<_Implementation>( | ||
| 621 | std::forward<_ExecutionPolicy>(__policy), | ||
| 622 | std::move(__first), | ||
| 623 | std::move(__last), | ||
| 624 | std::move(__result), | ||
| 625 | std::move(__op)); | ||
| 626 | } | ||
| 627 | |||
| 628 | template <class _ExecutionPolicy, | ||
| 629 | class _ForwardIterator1, | ||
| 630 | class _ForwardIterator2, | ||
| 631 | class _ForwardOutIterator, | ||
| 632 | class _BinaryOperation, | ||
| 633 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 634 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 635 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( | ||
| 636 | _ExecutionPolicy&& __policy, | ||
| 637 | _ForwardIterator1 __first1, | ||
| 638 | _ForwardIterator1 __last1, | ||
| 639 | _ForwardIterator2 __first2, | ||
| 640 | _ForwardOutIterator __result, | ||
| 641 | _BinaryOperation __op) { | ||
| 642 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform requires ForwardIterators"); | ||
| 643 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform requires ForwardIterators"); | ||
| 644 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "transform requires an OutputIterator"); | ||
| 645 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR( | ||
| 646 | _ForwardOutIterator, decltype(__op(*__first1, *__first2)), "transform requires an OutputIterator"); | ||
| 647 | using _Implementation = __pstl::__dispatch<__pstl::__transform_binary, __pstl::__current_configuration, _RawPolicy>; | ||
| 648 | return __pstl::__handle_exception<_Implementation>( | ||
| 649 | std::forward<_ExecutionPolicy>(__policy), | ||
| 650 | std::move(__first1), | ||
| 651 | std::move(__last1), | ||
| 652 | std::move(__first2), | ||
| 653 | std::move(__result), | ||
| 654 | std::move(__op)); | ||
| 655 | } | ||
| 656 | |||
| 657 | _LIBCPP_END_NAMESPACE_STD | ||
| 658 | |||
| 659 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 660 | |||
| 661 | _LIBCPP_POP_MACROS | ||
| 662 | |||
| 663 | #endif // _LIBCPP___ALGORITHM_PSTL_H | ||
lib/libcxx/include/__algorithm/pstl_any_all_none_of.h deleted-152| ... | @@ -1,152 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_ANY_ALL_NONE_OF_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_ANY_ALL_NONE_OF_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_find.h> | ||
| 13 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/cpp17_iterator_concepts.h> | ||
| 16 | #include <__type_traits/enable_if.h> | ||
| 17 | #include <__type_traits/is_execution_policy.h> | ||
| 18 | #include <__type_traits/remove_cvref.h> | ||
| 19 | #include <__utility/move.h> | ||
| 20 | #include <optional> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | #include <__undef_macros> | ||
| 28 | |||
| 29 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | template <class> | ||
| 34 | void __pstl_any_of(); // declaration needed for the frontend dispatch below | ||
| 35 | |||
| 36 | template <class _ExecutionPolicy, | ||
| 37 | class _ForwardIterator, | ||
| 38 | class _Predicate, | ||
| 39 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 40 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __any_of( | ||
| 42 | _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept { | ||
| 43 | return std::__pstl_frontend_dispatch( | ||
| 44 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_any_of, _RawPolicy), | ||
| 45 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<bool> { | ||
| 46 | auto __res = std::__find_if(__policy, __g_first, __g_last, __g_pred); | ||
| 47 | if (!__res) | ||
| 48 | return nullopt; | ||
| 49 | return *__res != __g_last; | ||
| 50 | }, | ||
| 51 | std::move(__first), | ||
| 52 | std::move(__last), | ||
| 53 | std::move(__pred)); | ||
| 54 | } | ||
| 55 | |||
| 56 | template <class _ExecutionPolicy, | ||
| 57 | class _ForwardIterator, | ||
| 58 | class _Predicate, | ||
| 59 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 60 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 61 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool | ||
| 62 | any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 63 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 64 | auto __res = std::__any_of(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 65 | if (!__res) | ||
| 66 | std::__throw_bad_alloc(); | ||
| 67 | return *std::move(__res); | ||
| 68 | } | ||
| 69 | |||
| 70 | template <class> | ||
| 71 | void __pstl_all_of(); // declaration needed for the frontend dispatch below | ||
| 72 | |||
| 73 | template <class _ExecutionPolicy, | ||
| 74 | class _ForwardIterator, | ||
| 75 | class _Pred, | ||
| 76 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 77 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 78 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 79 | __all_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept { | ||
| 80 | return std::__pstl_frontend_dispatch( | ||
| 81 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_all_of, _RawPolicy), | ||
| 82 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> { | ||
| 83 | auto __res = std::__any_of(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) { | ||
| 84 | return !__g_pred(__value); | ||
| 85 | }); | ||
| 86 | if (!__res) | ||
| 87 | return nullopt; | ||
| 88 | return !*__res; | ||
| 89 | }, | ||
| 90 | std::move(__first), | ||
| 91 | std::move(__last), | ||
| 92 | std::move(__pred)); | ||
| 93 | } | ||
| 94 | |||
| 95 | template <class _ExecutionPolicy, | ||
| 96 | class _ForwardIterator, | ||
| 97 | class _Pred, | ||
| 98 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 99 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 100 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool | ||
| 101 | all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { | ||
| 102 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 103 | auto __res = std::__all_of(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 104 | if (!__res) | ||
| 105 | std::__throw_bad_alloc(); | ||
| 106 | return *std::move(__res); | ||
| 107 | } | ||
| 108 | |||
| 109 | template <class> | ||
| 110 | void __pstl_none_of(); // declaration needed for the frontend dispatch below | ||
| 111 | |||
| 112 | template <class _ExecutionPolicy, | ||
| 113 | class _ForwardIterator, | ||
| 114 | class _Pred, | ||
| 115 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 116 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 118 | __none_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept { | ||
| 119 | return std::__pstl_frontend_dispatch( | ||
| 120 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_none_of, _RawPolicy), | ||
| 121 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> { | ||
| 122 | auto __res = std::__any_of(__policy, __g_first, __g_last, __g_pred); | ||
| 123 | if (!__res) | ||
| 124 | return nullopt; | ||
| 125 | return !*__res; | ||
| 126 | }, | ||
| 127 | std::move(__first), | ||
| 128 | std::move(__last), | ||
| 129 | std::move(__pred)); | ||
| 130 | } | ||
| 131 | |||
| 132 | template <class _ExecutionPolicy, | ||
| 133 | class _ForwardIterator, | ||
| 134 | class _Pred, | ||
| 135 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 136 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 137 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool | ||
| 138 | none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { | ||
| 139 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 140 | auto __res = std::__none_of(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 141 | if (!__res) | ||
| 142 | std::__throw_bad_alloc(); | ||
| 143 | return *std::move(__res); | ||
| 144 | } | ||
| 145 | |||
| 146 | _LIBCPP_END_NAMESPACE_STD | ||
| 147 | |||
| 148 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 149 | |||
| 150 | _LIBCPP_POP_MACROS | ||
| 151 | |||
| 152 | #endif // _LIBCPP___ALGORITHM_PSTL_ANY_ALL_NONE_OF_H | ||
lib/libcxx/include/__algorithm/pstl_backend.h deleted-232| ... | @@ -1,232 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKEND_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKEND_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backends/cpu_backend.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <execution> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | /* | ||
| 25 | TODO: Documentation of how backends work | ||
| 26 | |||
| 27 | A PSTL parallel backend is a tag type to which the following functions are associated, at minimum: | ||
| 28 | |||
| 29 | template <class _ExecutionPolicy, class _Iterator, class _Func> | ||
| 30 | optional<__empty> __pstl_for_each(_Backend, _ExecutionPolicy&&, _Iterator __first, _Iterator __last, _Func __f); | ||
| 31 | |||
| 32 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 33 | optional<_Iterator> __pstl_find_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); | ||
| 34 | |||
| 35 | template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp> | ||
| 36 | optional<__empty> | ||
| 37 | __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp); | ||
| 38 | |||
| 39 | template <class _ExecutionPolicy, | ||
| 40 | class _ForwardIterator1, | ||
| 41 | class _ForwardIterator2, | ||
| 42 | class _ForwardOutIterator, | ||
| 43 | class _Comp> | ||
| 44 | optional<_ForwardOutIterator> __pstl_merge(_Backend, | ||
| 45 | _ForwardIterator1 __first1, | ||
| 46 | _ForwardIterator1 __last1, | ||
| 47 | _ForwardIterator2 __first2, | ||
| 48 | _ForwardIterator2 __last2, | ||
| 49 | _ForwardOutIterator __result, | ||
| 50 | _Comp __comp); | ||
| 51 | |||
| 52 | template <class _ExecutionPolicy, class _InIterator, class _OutIterator, class _UnaryOperation> | ||
| 53 | optional<_OutIterator> | ||
| 54 | __pstl_transform(_Backend, _InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op); | ||
| 55 | |||
| 56 | template <class _ExecutionPolicy, class _InIterator1, class _InIterator2, class _OutIterator, class _BinaryOperation> | ||
| 57 | optional<_OutIterator> __pstl_transform(_InIterator1 __first1, | ||
| 58 | _InIterator2 __first2, | ||
| 59 | _InIterator1 __last1, | ||
| 60 | _OutIterator __result, | ||
| 61 | _BinaryOperation __op); | ||
| 62 | |||
| 63 | template <class _ExecutionPolicy, | ||
| 64 | class _Iterator1, | ||
| 65 | class _Iterator2, | ||
| 66 | class _Tp, | ||
| 67 | class _BinaryOperation1, | ||
| 68 | class _BinaryOperation2> | ||
| 69 | optional<_Tp> __pstl_transform_reduce(_Backend, | ||
| 70 | _Iterator1 __first1, | ||
| 71 | _Iterator1 __last1, | ||
| 72 | _Iterator2 __first2, | ||
| 73 | _Iterator2 __last2, | ||
| 74 | _Tp __init, | ||
| 75 | _BinaryOperation1 __reduce, | ||
| 76 | _BinaryOperation2 __transform); | ||
| 77 | |||
| 78 | template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation, class _UnaryOperation> | ||
| 79 | optional<_Tp> __pstl_transform_reduce(_Backend, | ||
| 80 | _Iterator __first, | ||
| 81 | _Iterator __last, | ||
| 82 | _Tp __init, | ||
| 83 | _BinaryOperation __reduce, | ||
| 84 | _UnaryOperation __transform); | ||
| 85 | |||
| 86 | // TODO: Complete this list | ||
| 87 | |||
| 88 | The following functions are optional but can be provided. If provided, they are used by the corresponding | ||
| 89 | algorithms, otherwise they are implemented in terms of other algorithms. If none of the optional algorithms are | ||
| 90 | implemented, all the algorithms will eventually forward to the basis algorithms listed above: | ||
| 91 | |||
| 92 | template <class _ExecutionPolicy, class _Iterator, class _Size, class _Func> | ||
| 93 | optional<__empty> __pstl_for_each_n(_Backend, _Iterator __first, _Size __n, _Func __f); | ||
| 94 | |||
| 95 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 96 | optional<bool> __pstl_any_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); | ||
| 97 | |||
| 98 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 99 | optional<bool> __pstl_all_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); | ||
| 100 | |||
| 101 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 102 | optional<bool> __pstl_none_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); | ||
| 103 | |||
| 104 | template <class _ExecutionPolicy, class _Iterator, class _Tp> | ||
| 105 | optional<_Iterator> __pstl_find(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); | ||
| 106 | |||
| 107 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 108 | optional<_Iterator> __pstl_find_if_not(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); | ||
| 109 | |||
| 110 | template <class _ExecutionPolicy, class _Iterator, class _Tp> | ||
| 111 | optional<__empty> __pstl_fill(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); | ||
| 112 | |||
| 113 | template <class _ExecutionPolicy, class _Iterator, class _SizeT, class _Tp> | ||
| 114 | optional<__empty> __pstl_fill_n(_Backend, _Iterator __first, _SizeT __n, const _Tp& __value); | ||
| 115 | |||
| 116 | template <class _ExecutionPolicy, class _Iterator, class _Generator> | ||
| 117 | optional<__empty> __pstl_generate(_Backend, _Iterator __first, _Iterator __last, _Generator __gen); | ||
| 118 | |||
| 119 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 120 | optional<__empty> __pstl_is_partitioned(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); | ||
| 121 | |||
| 122 | template <class _ExecutionPolicy, class _Iterator, class _Size, class _Generator> | ||
| 123 | optional<__empty> __pstl_generator_n(_Backend, _Iterator __first, _Size __n, _Generator __gen); | ||
| 124 | |||
| 125 | template <class _ExecutionPolicy, class _terator1, class _Iterator2, class _OutIterator, class _Comp> | ||
| 126 | optional<_OutIterator> __pstl_merge(_Backend, | ||
| 127 | _Iterator1 __first1, | ||
| 128 | _Iterator1 __last1, | ||
| 129 | _Iterator2 __first2, | ||
| 130 | _Iterator2 __last2, | ||
| 131 | _OutIterator __result, | ||
| 132 | _Comp __comp); | ||
| 133 | |||
| 134 | template <class _ExecutionPolicy, class _Iterator, class _OutIterator> | ||
| 135 | optional<_OutIterator> __pstl_move(_Backend, _Iterator __first, _Iterator __last, _OutIterator __result); | ||
| 136 | |||
| 137 | template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation> | ||
| 138 | optional<_Tp> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last, _Tp __init, _BinaryOperation __op); | ||
| 139 | |||
| 140 | temlate <class _ExecutionPolicy, class _Iterator> | ||
| 141 | optional<__iter_value_type<_Iterator>> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last); | ||
| 142 | |||
| 143 | template <class _ExecutionPolicy, class _Iterator, class _Tp> | ||
| 144 | optional<__iter_diff_t<_Iterator>> __pstl_count(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); | ||
| 145 | |||
| 146 | template <class _ExecutionPolicy, class _Iterator, class _Predicate> | ||
| 147 | optional<__iter_diff_t<_Iterator>> __pstl_count_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); | ||
| 148 | |||
| 149 | template <class _ExecutionPolicy, class _Iterator, class _Tp> | ||
| 150 | optional<__empty> | ||
| 151 | __pstl_replace(_Backend, _Iterator __first, _Iterator __last, const _Tp& __old_value, const _Tp& __new_value); | ||
| 152 | |||
| 153 | template <class _ExecutionPolicy, class _Iterator, class _Pred, class _Tp> | ||
| 154 | optional<__empty> | ||
| 155 | __pstl_replace_if(_Backend, _Iterator __first, _Iterator __last, _Pred __pred, const _Tp& __new_value); | ||
| 156 | |||
| 157 | template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Tp> | ||
| 158 | optional<__empty> __pstl_replace_copy(_Backend, | ||
| 159 | _Iterator __first, | ||
| 160 | _Iterator __last, | ||
| 161 | _OutIterator __result, | ||
| 162 | const _Tp& __old_value, | ||
| 163 | const _Tp& __new_value); | ||
| 164 | |||
| 165 | template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Pred, class _Tp> | ||
| 166 | optional<__empty> __pstl_replace_copy_if(_Backend, | ||
| 167 | _Iterator __first, | ||
| 168 | _Iterator __last, | ||
| 169 | _OutIterator __result, | ||
| 170 | _Pred __pred, | ||
| 171 | const _Tp& __new_value); | ||
| 172 | |||
| 173 | template <class _ExecutionPolicy, class _Iterator, class _OutIterator> | ||
| 174 | optional<_Iterator> __pstl_rotate_copy( | ||
| 175 | _Backend, _Iterator __first, _Iterator __middle, _Iterator __last, _OutIterator __result); | ||
| 176 | |||
| 177 | template <class _ExecutionPolicy, class _Iterator, class _Comp> | ||
| 178 | optional<__empty> __pstl_sort(_Backend, _Iterator __first, _Iterator __last, _Comp __comp); | ||
| 179 | |||
| 180 | template <class _ExecutionPolicy, class _Iterator1, class _Iterator2, class _Comp> | ||
| 181 | optional<bool> __pstl_equal(_Backend, _Iterator1 first1, _Iterator1 last1, _Iterator2 first2, _Comp __comp); | ||
| 182 | |||
| 183 | // TODO: Complete this list | ||
| 184 | |||
| 185 | Exception handling | ||
| 186 | ================== | ||
| 187 | |||
| 188 | PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their | ||
| 189 | implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned | ||
| 190 | into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the | ||
| 191 | frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user. | ||
| 192 | */ | ||
| 193 | |||
| 194 | template <class _ExecutionPolicy> | ||
| 195 | struct __select_backend; | ||
| 196 | |||
| 197 | template <> | ||
| 198 | struct __select_backend<std::execution::sequenced_policy> { | ||
| 199 | using type = __cpu_backend_tag; | ||
| 200 | }; | ||
| 201 | |||
| 202 | # if _LIBCPP_STD_VER >= 20 | ||
| 203 | template <> | ||
| 204 | struct __select_backend<std::execution::unsequenced_policy> { | ||
| 205 | using type = __cpu_backend_tag; | ||
| 206 | }; | ||
| 207 | # endif | ||
| 208 | |||
| 209 | # if defined(_LIBCPP_PSTL_CPU_BACKEND_SERIAL) || defined(_LIBCPP_PSTL_CPU_BACKEND_THREAD) || \ | ||
| 210 | defined(_LIBCPP_PSTL_CPU_BACKEND_LIBDISPATCH) | ||
| 211 | template <> | ||
| 212 | struct __select_backend<std::execution::parallel_policy> { | ||
| 213 | using type = __cpu_backend_tag; | ||
| 214 | }; | ||
| 215 | |||
| 216 | template <> | ||
| 217 | struct __select_backend<std::execution::parallel_unsequenced_policy> { | ||
| 218 | using type = __cpu_backend_tag; | ||
| 219 | }; | ||
| 220 | |||
| 221 | # else | ||
| 222 | |||
| 223 | // ...New vendors can add parallel backends here... | ||
| 224 | |||
| 225 | # error "Invalid choice of a PSTL parallel backend" | ||
| 226 | # endif | ||
| 227 | |||
| 228 | _LIBCPP_END_NAMESPACE_STD | ||
| 229 | |||
| 230 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 231 | |||
| 232 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKEND_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backend.h deleted-68| ... | @@ -1,68 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | /* | ||
| 15 | |||
| 16 | // _Functor takes a subrange for [__first, __last) that should be executed in serial | ||
| 17 | template <class _RandomAccessIterator, class _Functor> | ||
| 18 | optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func); | ||
| 19 | |||
| 20 | template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction> | ||
| 21 | optional<_Tp> | ||
| 22 | __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction); | ||
| 23 | |||
| 24 | // Cancel the execution of other jobs - they aren't needed anymore | ||
| 25 | void __cancel_execution(); | ||
| 26 | |||
| 27 | template <class _RandomAccessIterator1, | ||
| 28 | class _RandomAccessIterator2, | ||
| 29 | class _RandomAccessIterator3, | ||
| 30 | class _Compare, | ||
| 31 | class _LeafMerge> | ||
| 32 | optional<void> __parallel_merge( | ||
| 33 | _RandomAccessIterator1 __first1, | ||
| 34 | _RandomAccessIterator1 __last1, | ||
| 35 | _RandomAccessIterator2 __first2, | ||
| 36 | _RandomAccessIterator2 __last2, | ||
| 37 | _RandomAccessIterator3 __outit, | ||
| 38 | _Compare __comp, | ||
| 39 | _LeafMerge __leaf_merge); | ||
| 40 | |||
| 41 | template <class _RandomAccessIterator, class _Comp, class _LeafSort> | ||
| 42 | void __parallel_stable_sort(_RandomAccessIterator __first, | ||
| 43 | _RandomAccessIterator __last, | ||
| 44 | _Comp __comp, | ||
| 45 | _LeafSort __leaf_sort); | ||
| 46 | |||
| 47 | TODO: Document the parallel backend | ||
| 48 | |||
| 49 | Exception handling | ||
| 50 | ================== | ||
| 51 | |||
| 52 | CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their | ||
| 53 | implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned | ||
| 54 | into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the | ||
| 55 | frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user. | ||
| 56 | */ | ||
| 57 | |||
| 58 | #include <__algorithm/pstl_backends/cpu_backends/any_of.h> | ||
| 59 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 60 | #include <__algorithm/pstl_backends/cpu_backends/fill.h> | ||
| 61 | #include <__algorithm/pstl_backends/cpu_backends/find_if.h> | ||
| 62 | #include <__algorithm/pstl_backends/cpu_backends/for_each.h> | ||
| 63 | #include <__algorithm/pstl_backends/cpu_backends/merge.h> | ||
| 64 | #include <__algorithm/pstl_backends/cpu_backends/stable_sort.h> | ||
| 65 | #include <__algorithm/pstl_backends/cpu_backends/transform.h> | ||
| 66 | #include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h> | ||
| 67 | |||
| 68 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h deleted-98| ... | @@ -1,98 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H | ||
| 11 | |||
| 12 | #include <__algorithm/any_of.h> | ||
| 13 | #include <__algorithm/find_if.h> | ||
| 14 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 15 | #include <__atomic/atomic.h> | ||
| 16 | #include <__atomic/memory_order.h> | ||
| 17 | #include <__config> | ||
| 18 | #include <__functional/operations.h> | ||
| 19 | #include <__iterator/concepts.h> | ||
| 20 | #include <__type_traits/is_execution_policy.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | #include <__utility/pair.h> | ||
| 23 | #include <cstdint> | ||
| 24 | #include <optional> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | # include <__undef_macros> | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | template <class _Index, class _Brick> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) { | ||
| 35 | std::atomic<bool> __found(false); | ||
| 36 | auto __ret = __par_backend::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) { | ||
| 37 | if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) { | ||
| 38 | __found.store(true, std::memory_order_relaxed); | ||
| 39 | __par_backend::__cancel_execution(); | ||
| 40 | } | ||
| 41 | }); | ||
| 42 | if (!__ret) | ||
| 43 | return nullopt; | ||
| 44 | return static_cast<bool>(__found); | ||
| 45 | } | ||
| 46 | |||
| 47 | // TODO: check whether __simd_first() can be used here | ||
| 48 | template <class _Index, class _DifferenceType, class _Pred> | ||
| 49 | _LIBCPP_HIDE_FROM_ABI bool __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept { | ||
| 50 | _DifferenceType __block_size = 4 < __n ? 4 : __n; | ||
| 51 | const _Index __last = __first + __n; | ||
| 52 | while (__last != __first) { | ||
| 53 | int32_t __flag = 1; | ||
| 54 | _PSTL_PRAGMA_SIMD_REDUCTION(& : __flag) | ||
| 55 | for (_DifferenceType __i = 0; __i < __block_size; ++__i) | ||
| 56 | if (__pred(*(__first + __i))) | ||
| 57 | __flag = 0; | ||
| 58 | if (!__flag) | ||
| 59 | return true; | ||
| 60 | |||
| 61 | __first += __block_size; | ||
| 62 | if (__last - __first >= __block_size << 1) { | ||
| 63 | // Double the block _Size. Any unnecessary iterations can be amortized against work done so far. | ||
| 64 | __block_size <<= 1; | ||
| 65 | } else { | ||
| 66 | __block_size = __last - __first; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | return false; | ||
| 70 | } | ||
| 71 | |||
| 72 | template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate> | ||
| 73 | _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 74 | __pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 75 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 76 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 77 | return std::__parallel_or( | ||
| 78 | __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 79 | auto __res = std::__pstl_any_of<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 80 | __cpu_backend_tag{}, __brick_first, __brick_last, __pred); | ||
| 81 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 82 | return *std::move(__res); | ||
| 83 | }); | ||
| 84 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 85 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 86 | return std::__simd_or(__first, __last - __first, __pred); | ||
| 87 | } else { | ||
| 88 | return std::any_of(__first, __last, __pred); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | _LIBCPP_END_NAMESPACE_STD | ||
| 93 | |||
| 94 | _LIBCPP_POP_MACROS | ||
| 95 | |||
| 96 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 97 | |||
| 98 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h deleted-41| ... | @@ -1,41 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_BACKEND_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_BACKEND_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <cstddef> | ||
| 14 | |||
| 15 | #if defined(_LIBCPP_PSTL_CPU_BACKEND_SERIAL) | ||
| 16 | # include <__algorithm/pstl_backends/cpu_backends/serial.h> | ||
| 17 | #elif defined(_LIBCPP_PSTL_CPU_BACKEND_THREAD) | ||
| 18 | # include <__algorithm/pstl_backends/cpu_backends/thread.h> | ||
| 19 | #elif defined(_LIBCPP_PSTL_CPU_BACKEND_LIBDISPATCH) | ||
| 20 | # include <__algorithm/pstl_backends/cpu_backends/libdispatch.h> | ||
| 21 | #else | ||
| 22 | # error "Invalid CPU backend choice" | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 26 | # pragma GCC system_header | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | struct __cpu_backend_tag {}; | ||
| 34 | |||
| 35 | inline constexpr size_t __lane_size = 64; | ||
| 36 | |||
| 37 | _LIBCPP_END_NAMESPACE_STD | ||
| 38 | |||
| 39 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 40 | |||
| 41 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_BACKEND_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h deleted-62| ... | @@ -1,62 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H | ||
| 11 | |||
| 12 | #include <__algorithm/fill.h> | ||
| 13 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__utility/empty.h> | ||
| 18 | #include <optional> | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | |||
| 28 | template <class _Index, class _DifferenceType, class _Tp> | ||
| 29 | _LIBCPP_HIDE_FROM_ABI _Index __simd_fill_n(_Index __first, _DifferenceType __n, const _Tp& __value) noexcept { | ||
| 30 | _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED | ||
| 31 | _PSTL_PRAGMA_SIMD | ||
| 32 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 33 | __first[__i] = __value; | ||
| 34 | return __first + __n; | ||
| 35 | } | ||
| 36 | |||
| 37 | template <class _ExecutionPolicy, class _ForwardIterator, class _Tp> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 39 | __pstl_fill(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 40 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 41 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 42 | return __par_backend::__parallel_for( | ||
| 43 | __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 44 | [[maybe_unused]] auto __res = std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 45 | __cpu_backend_tag{}, __brick_first, __brick_last, __value); | ||
| 46 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 47 | }); | ||
| 48 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 49 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 50 | std::__simd_fill_n(__first, __last - __first, __value); | ||
| 51 | return __empty{}; | ||
| 52 | } else { | ||
| 53 | std::fill(__first, __last, __value); | ||
| 54 | return __empty{}; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | _LIBCPP_END_NAMESPACE_STD | ||
| 59 | |||
| 60 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 61 | |||
| 62 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h deleted-133| ... | @@ -1,133 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H | ||
| 11 | |||
| 12 | #include <__algorithm/find_if.h> | ||
| 13 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 14 | #include <__atomic/atomic.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__functional/operations.h> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__iterator/iterator_traits.h> | ||
| 19 | #include <__type_traits/is_execution_policy.h> | ||
| 20 | #include <__utility/move.h> | ||
| 21 | #include <__utility/pair.h> | ||
| 22 | #include <cstddef> | ||
| 23 | #include <optional> | ||
| 24 | |||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 26 | # pragma GCC system_header | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 30 | |||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | # include <__undef_macros> | ||
| 33 | |||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 35 | |||
| 36 | template <class _Index, class _Brick, class _Compare> | ||
| 37 | _LIBCPP_HIDE_FROM_ABI optional<_Index> | ||
| 38 | __parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool __b_first) { | ||
| 39 | typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType; | ||
| 40 | const _DifferenceType __n = __last - __first; | ||
| 41 | _DifferenceType __initial_dist = __b_first ? __n : -1; | ||
| 42 | std::atomic<_DifferenceType> __extremum(__initial_dist); | ||
| 43 | // TODO: find out what is better here: parallel_for or parallel_reduce | ||
| 44 | auto __res = | ||
| 45 | __par_backend::__parallel_for(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) { | ||
| 46 | // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of | ||
| 47 | // why using a shared variable scales fairly well in this situation. | ||
| 48 | if (__comp(__i - __first, __extremum)) { | ||
| 49 | _Index __result = __f(__i, __j); | ||
| 50 | // If not '__last' returned then we found what we want so put this to extremum | ||
| 51 | if (__result != __j) { | ||
| 52 | const _DifferenceType __k = __result - __first; | ||
| 53 | for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) { | ||
| 54 | __extremum.compare_exchange_weak(__old, __k); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
| 58 | }); | ||
| 59 | if (!__res) | ||
| 60 | return nullopt; | ||
| 61 | return __extremum.load() != __initial_dist ? __first + __extremum.load() : __last; | ||
| 62 | } | ||
| 63 | |||
| 64 | template <class _Index, class _DifferenceType, class _Compare> | ||
| 65 | _LIBCPP_HIDE_FROM_ABI _Index | ||
| 66 | __simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp) noexcept { | ||
| 67 | // Experiments show good block sizes like this | ||
| 68 | const _DifferenceType __block_size = 8; | ||
| 69 | alignas(__lane_size) _DifferenceType __lane[__block_size] = {0}; | ||
| 70 | while (__end - __begin >= __block_size) { | ||
| 71 | _DifferenceType __found = 0; | ||
| 72 | _PSTL_PRAGMA_SIMD_REDUCTION(| : __found) for (_DifferenceType __i = __begin; __i < __begin + __block_size; ++__i) { | ||
| 73 | const _DifferenceType __t = __comp(__first, __i); | ||
| 74 | __lane[__i - __begin] = __t; | ||
| 75 | __found |= __t; | ||
| 76 | } | ||
| 77 | if (__found) { | ||
| 78 | _DifferenceType __i; | ||
| 79 | // This will vectorize | ||
| 80 | for (__i = 0; __i < __block_size; ++__i) { | ||
| 81 | if (__lane[__i]) { | ||
| 82 | break; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | return __first + __begin + __i; | ||
| 86 | } | ||
| 87 | __begin += __block_size; | ||
| 88 | } | ||
| 89 | |||
| 90 | // Keep remainder scalar | ||
| 91 | while (__begin != __end) { | ||
| 92 | if (__comp(__first, __begin)) { | ||
| 93 | return __first + __begin; | ||
| 94 | } | ||
| 95 | ++__begin; | ||
| 96 | } | ||
| 97 | return __first + __end; | ||
| 98 | } | ||
| 99 | |||
| 100 | template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate> | ||
| 101 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator> | ||
| 102 | __pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 103 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 104 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 105 | return std::__parallel_find( | ||
| 106 | __first, | ||
| 107 | __last, | ||
| 108 | [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 109 | auto __res = std::__pstl_find_if<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 110 | __cpu_backend_tag{}, __brick_first, __brick_last, __pred); | ||
| 111 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 112 | return *std::move(__res); | ||
| 113 | }, | ||
| 114 | less<>{}, | ||
| 115 | true); | ||
| 116 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 117 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 118 | using __diff_t = __iter_diff_t<_ForwardIterator>; | ||
| 119 | return std::__simd_first(__first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) { | ||
| 120 | return __pred(__iter[__i]); | ||
| 121 | }); | ||
| 122 | } else { | ||
| 123 | return std::find_if(__first, __last, __pred); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | _LIBCPP_END_NAMESPACE_STD | ||
| 128 | |||
| 129 | _LIBCPP_POP_MACROS | ||
| 130 | |||
| 131 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 132 | |||
| 133 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h deleted-62| ... | @@ -1,62 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H | ||
| 11 | |||
| 12 | #include <__algorithm/for_each.h> | ||
| 13 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__utility/empty.h> | ||
| 18 | #include <optional> | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | |||
| 28 | template <class _Iterator, class _DifferenceType, class _Function> | ||
| 29 | _LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk(_Iterator __first, _DifferenceType __n, _Function __f) noexcept { | ||
| 30 | _PSTL_PRAGMA_SIMD | ||
| 31 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 32 | __f(__first[__i]); | ||
| 33 | |||
| 34 | return __first + __n; | ||
| 35 | } | ||
| 36 | |||
| 37 | template <class _ExecutionPolicy, class _ForwardIterator, class _Functor> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 39 | __pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Functor __func) { | ||
| 40 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 41 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 42 | return std::__par_backend::__parallel_for( | ||
| 43 | __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 44 | [[maybe_unused]] auto __res = std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 45 | __cpu_backend_tag{}, __brick_first, __brick_last, __func); | ||
| 46 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 47 | }); | ||
| 48 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 49 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 50 | std::__simd_walk(__first, __last - __first, __func); | ||
| 51 | return __empty{}; | ||
| 52 | } else { | ||
| 53 | std::for_each(__first, __last, __func); | ||
| 54 | return __empty{}; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | _LIBCPP_END_NAMESPACE_STD | ||
| 59 | |||
| 60 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 61 | |||
| 62 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h deleted-347| ... | @@ -1,347 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H | ||
| 11 | |||
| 12 | #include <__algorithm/inplace_merge.h> | ||
| 13 | #include <__algorithm/lower_bound.h> | ||
| 14 | #include <__algorithm/max.h> | ||
| 15 | #include <__algorithm/merge.h> | ||
| 16 | #include <__algorithm/upper_bound.h> | ||
| 17 | #include <__atomic/atomic.h> | ||
| 18 | #include <__config> | ||
| 19 | #include <__exception/terminate.h> | ||
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__iterator/move_iterator.h> | ||
| 22 | #include <__memory/allocator.h> | ||
| 23 | #include <__memory/construct_at.h> | ||
| 24 | #include <__memory/unique_ptr.h> | ||
| 25 | #include <__numeric/reduce.h> | ||
| 26 | #include <__utility/empty.h> | ||
| 27 | #include <__utility/exception_guard.h> | ||
| 28 | #include <__utility/move.h> | ||
| 29 | #include <__utility/pair.h> | ||
| 30 | #include <cstddef> | ||
| 31 | #include <new> | ||
| 32 | #include <optional> | ||
| 33 | |||
| 34 | _LIBCPP_PUSH_MACROS | ||
| 35 | #include <__undef_macros> | ||
| 36 | |||
| 37 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 38 | |||
| 39 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 40 | |||
| 41 | namespace __par_backend { | ||
| 42 | inline namespace __libdispatch { | ||
| 43 | |||
| 44 | // ::dispatch_apply is marked as __attribute__((nothrow)) because it doesn't let exceptions propagate, and neither do | ||
| 45 | // we. | ||
| 46 | // TODO: Do we want to add [[_Clang::__callback__(__func, __context, __)]]? | ||
| 47 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 48 | __dispatch_apply(size_t __chunk_count, void* __context, void (*__func)(void* __context, size_t __chunk)) noexcept; | ||
| 49 | |||
| 50 | template <class _Func> | ||
| 51 | _LIBCPP_HIDE_FROM_ABI void __dispatch_apply(size_t __chunk_count, _Func __func) noexcept { | ||
| 52 | __libdispatch::__dispatch_apply(__chunk_count, &__func, [](void* __context, size_t __chunk) { | ||
| 53 | (*static_cast<_Func*>(__context))(__chunk); | ||
| 54 | }); | ||
| 55 | } | ||
| 56 | |||
| 57 | struct __chunk_partitions { | ||
| 58 | ptrdiff_t __chunk_count_; // includes the first chunk | ||
| 59 | ptrdiff_t __chunk_size_; | ||
| 60 | ptrdiff_t __first_chunk_size_; | ||
| 61 | }; | ||
| 62 | |||
| 63 | [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept; | ||
| 64 | |||
| 65 | template <class _RandomAccessIterator, class _Functor> | ||
| 66 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 67 | __dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) { | ||
| 68 | // Perform the chunked execution. | ||
| 69 | __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) { | ||
| 70 | auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_; | ||
| 71 | auto __index = | ||
| 72 | __chunk == 0 | ||
| 73 | ? 0 | ||
| 74 | : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_); | ||
| 75 | __func(__first + __index, __first + __index + __this_chunk_size); | ||
| 76 | }); | ||
| 77 | |||
| 78 | return __empty{}; | ||
| 79 | } | ||
| 80 | |||
| 81 | template <class _RandomAccessIterator, class _Functor> | ||
| 82 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 83 | __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) { | ||
| 84 | return __libdispatch::__dispatch_parallel_for( | ||
| 85 | __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func)); | ||
| 86 | } | ||
| 87 | |||
| 88 | template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _RandomAccessIteratorOut> | ||
| 89 | struct __merge_range { | ||
| 90 | __merge_range(_RandomAccessIterator1 __mid1, _RandomAccessIterator2 __mid2, _RandomAccessIteratorOut __result) | ||
| 91 | : __mid1_(__mid1), __mid2_(__mid2), __result_(__result) {} | ||
| 92 | |||
| 93 | _RandomAccessIterator1 __mid1_; | ||
| 94 | _RandomAccessIterator2 __mid2_; | ||
| 95 | _RandomAccessIteratorOut __result_; | ||
| 96 | }; | ||
| 97 | |||
| 98 | template <typename _RandomAccessIterator1, | ||
| 99 | typename _RandomAccessIterator2, | ||
| 100 | typename _RandomAccessIterator3, | ||
| 101 | typename _Compare, | ||
| 102 | typename _LeafMerge> | ||
| 103 | _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge( | ||
| 104 | _RandomAccessIterator1 __first1, | ||
| 105 | _RandomAccessIterator1 __last1, | ||
| 106 | _RandomAccessIterator2 __first2, | ||
| 107 | _RandomAccessIterator2 __last2, | ||
| 108 | _RandomAccessIterator3 __result, | ||
| 109 | _Compare __comp, | ||
| 110 | _LeafMerge __leaf_merge) noexcept { | ||
| 111 | __chunk_partitions __partitions = | ||
| 112 | __libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2)); | ||
| 113 | |||
| 114 | if (__partitions.__chunk_count_ == 0) | ||
| 115 | return __empty{}; | ||
| 116 | |||
| 117 | if (__partitions.__chunk_count_ == 1) { | ||
| 118 | __leaf_merge(__first1, __last1, __first2, __last2, __result, __comp); | ||
| 119 | return __empty{}; | ||
| 120 | } | ||
| 121 | |||
| 122 | using __merge_range_t = __merge_range<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator3>; | ||
| 123 | auto const __n_ranges = __partitions.__chunk_count_ + 1; | ||
| 124 | |||
| 125 | // TODO: use __uninitialized_buffer | ||
| 126 | auto __destroy = [=](__merge_range_t* __ptr) { | ||
| 127 | std::destroy_n(__ptr, __n_ranges); | ||
| 128 | std::allocator<__merge_range_t>().deallocate(__ptr, __n_ranges); | ||
| 129 | }; | ||
| 130 | |||
| 131 | unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges( | ||
| 132 | [&]() -> __merge_range_t* { | ||
| 133 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 134 | try { | ||
| 135 | # endif | ||
| 136 | return std::allocator<__merge_range_t>().allocate(__n_ranges); | ||
| 137 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 138 | } catch (const std::bad_alloc&) { | ||
| 139 | return nullptr; | ||
| 140 | } | ||
| 141 | # endif | ||
| 142 | }(), | ||
| 143 | __destroy); | ||
| 144 | |||
| 145 | if (!__ranges) | ||
| 146 | return nullopt; | ||
| 147 | |||
| 148 | // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case | ||
| 149 | __merge_range_t* __r = __ranges.get(); | ||
| 150 | std::__construct_at(__r++, __first1, __first2, __result); | ||
| 151 | |||
| 152 | bool __iterate_first_range = __last1 - __first1 > __last2 - __first2; | ||
| 153 | |||
| 154 | auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t { | ||
| 155 | auto [__mid1, __mid2] = [&] { | ||
| 156 | if (__iterate_first_range) { | ||
| 157 | auto __m1 = __first1 + __chunk_size; | ||
| 158 | auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp); | ||
| 159 | return std::make_pair(__m1, __m2); | ||
| 160 | } else { | ||
| 161 | auto __m2 = __first2 + __chunk_size; | ||
| 162 | auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp); | ||
| 163 | return std::make_pair(__m1, __m2); | ||
| 164 | } | ||
| 165 | }(); | ||
| 166 | |||
| 167 | __result += (__mid1 - __first1) + (__mid2 - __first2); | ||
| 168 | __first1 = __mid1; | ||
| 169 | __first2 = __mid2; | ||
| 170 | return {std::move(__mid1), std::move(__mid2), __result}; | ||
| 171 | }; | ||
| 172 | |||
| 173 | // handle first chunk | ||
| 174 | std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_)); | ||
| 175 | |||
| 176 | // handle 2 -> N - 1 chunks | ||
| 177 | for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i) | ||
| 178 | std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_)); | ||
| 179 | |||
| 180 | // handle last chunk | ||
| 181 | std::__construct_at(__r, __last1, __last2, __result); | ||
| 182 | |||
| 183 | __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) { | ||
| 184 | auto __first_iters = __ranges[__index]; | ||
| 185 | auto __last_iters = __ranges[__index + 1]; | ||
| 186 | __leaf_merge( | ||
| 187 | __first_iters.__mid1_, | ||
| 188 | __last_iters.__mid1_, | ||
| 189 | __first_iters.__mid2_, | ||
| 190 | __last_iters.__mid2_, | ||
| 191 | __first_iters.__result_, | ||
| 192 | __comp); | ||
| 193 | }); | ||
| 194 | |||
| 195 | return __empty{}; | ||
| 196 | } | ||
| 197 | |||
| 198 | template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction> | ||
| 199 | _LIBCPP_HIDE_FROM_ABI optional<_Value> __parallel_transform_reduce( | ||
| 200 | _RandomAccessIterator __first, | ||
| 201 | _RandomAccessIterator __last, | ||
| 202 | _Transform __transform, | ||
| 203 | _Value __init, | ||
| 204 | _Combiner __combiner, | ||
| 205 | _Reduction __reduction) { | ||
| 206 | if (__first == __last) | ||
| 207 | return __init; | ||
| 208 | |||
| 209 | auto __partitions = __libdispatch::__partition_chunks(__last - __first); | ||
| 210 | |||
| 211 | auto __destroy = [__count = __partitions.__chunk_count_](_Value* __ptr) { | ||
| 212 | std::destroy_n(__ptr, __count); | ||
| 213 | std::allocator<_Value>().deallocate(__ptr, __count); | ||
| 214 | }; | ||
| 215 | |||
| 216 | // TODO: use __uninitialized_buffer | ||
| 217 | // TODO: allocate one element per worker instead of one element per chunk | ||
| 218 | unique_ptr<_Value[], decltype(__destroy)> __values( | ||
| 219 | std::allocator<_Value>().allocate(__partitions.__chunk_count_), __destroy); | ||
| 220 | |||
| 221 | // __dispatch_apply is noexcept | ||
| 222 | __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) { | ||
| 223 | auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_; | ||
| 224 | auto __index = | ||
| 225 | __chunk == 0 | ||
| 226 | ? 0 | ||
| 227 | : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_); | ||
| 228 | if (__this_chunk_size != 1) { | ||
| 229 | std::__construct_at( | ||
| 230 | __values.get() + __chunk, | ||
| 231 | __reduction(__first + __index + 2, | ||
| 232 | __first + __index + __this_chunk_size, | ||
| 233 | __combiner(__transform(__first + __index), __transform(__first + __index + 1)))); | ||
| 234 | } else { | ||
| 235 | std::__construct_at(__values.get() + __chunk, __transform(__first + __index)); | ||
| 236 | } | ||
| 237 | }); | ||
| 238 | |||
| 239 | return std::reduce( | ||
| 240 | std::make_move_iterator(__values.get()), | ||
| 241 | std::make_move_iterator(__values.get() + __partitions.__chunk_count_), | ||
| 242 | std::move(__init), | ||
| 243 | __combiner); | ||
| 244 | } | ||
| 245 | |||
| 246 | template <class _RandomAccessIterator, class _Comp, class _LeafSort> | ||
| 247 | _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort( | ||
| 248 | _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) { | ||
| 249 | const auto __size = __last - __first; | ||
| 250 | auto __partitions = __libdispatch::__partition_chunks(__size); | ||
| 251 | |||
| 252 | if (__partitions.__chunk_count_ == 0) | ||
| 253 | return __empty{}; | ||
| 254 | |||
| 255 | if (__partitions.__chunk_count_ == 1) { | ||
| 256 | __leaf_sort(__first, __last, __comp); | ||
| 257 | return __empty{}; | ||
| 258 | } | ||
| 259 | |||
| 260 | using _Value = __iter_value_type<_RandomAccessIterator>; | ||
| 261 | |||
| 262 | auto __destroy = [__size](_Value* __ptr) { | ||
| 263 | std::destroy_n(__ptr, __size); | ||
| 264 | std::allocator<_Value>().deallocate(__ptr, __size); | ||
| 265 | }; | ||
| 266 | |||
| 267 | // TODO: use __uninitialized_buffer | ||
| 268 | unique_ptr<_Value[], decltype(__destroy)> __values(std::allocator<_Value>().allocate(__size), __destroy); | ||
| 269 | |||
| 270 | // Initialize all elements to a moved-from state | ||
| 271 | // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928 | ||
| 272 | std::__construct_at(__values.get(), std::move(*__first)); | ||
| 273 | for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) { | ||
| 274 | std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1])); | ||
| 275 | } | ||
| 276 | *__first = std::move(__values.get()[__size - 1]); | ||
| 277 | |||
| 278 | __libdispatch::__dispatch_parallel_for( | ||
| 279 | __partitions, | ||
| 280 | __first, | ||
| 281 | [&__leaf_sort, &__comp](_RandomAccessIterator __chunk_first, _RandomAccessIterator __chunk_last) { | ||
| 282 | __leaf_sort(std::move(__chunk_first), std::move(__chunk_last), __comp); | ||
| 283 | }); | ||
| 284 | |||
| 285 | bool __objects_are_in_buffer = false; | ||
| 286 | do { | ||
| 287 | const auto __old_chunk_size = __partitions.__chunk_size_; | ||
| 288 | if (__partitions.__chunk_count_ % 2 == 1) { | ||
| 289 | auto __inplace_merge_chunks = [&__comp, &__partitions](auto __first_chunk_begin) { | ||
| 290 | std::inplace_merge( | ||
| 291 | __first_chunk_begin, | ||
| 292 | __first_chunk_begin + __partitions.__first_chunk_size_, | ||
| 293 | __first_chunk_begin + __partitions.__first_chunk_size_ + __partitions.__chunk_size_, | ||
| 294 | __comp); | ||
| 295 | }; | ||
| 296 | if (__objects_are_in_buffer) | ||
| 297 | __inplace_merge_chunks(__values.get()); | ||
| 298 | else | ||
| 299 | __inplace_merge_chunks(__first); | ||
| 300 | __partitions.__first_chunk_size_ += 2 * __partitions.__chunk_size_; | ||
| 301 | } else { | ||
| 302 | __partitions.__first_chunk_size_ += __partitions.__chunk_size_; | ||
| 303 | } | ||
| 304 | |||
| 305 | __partitions.__chunk_size_ *= 2; | ||
| 306 | __partitions.__chunk_count_ /= 2; | ||
| 307 | |||
| 308 | auto __merge_chunks = [__partitions, __old_chunk_size, &__comp](auto __from_first, auto __to_first) { | ||
| 309 | __libdispatch::__dispatch_parallel_for( | ||
| 310 | __partitions, | ||
| 311 | __from_first, | ||
| 312 | [__old_chunk_size, &__from_first, &__to_first, &__comp](auto __chunk_first, auto __chunk_last) { | ||
| 313 | std::merge(std::make_move_iterator(__chunk_first), | ||
| 314 | std::make_move_iterator(__chunk_last - __old_chunk_size), | ||
| 315 | std::make_move_iterator(__chunk_last - __old_chunk_size), | ||
| 316 | std::make_move_iterator(__chunk_last), | ||
| 317 | __to_first + (__chunk_first - __from_first), | ||
| 318 | __comp); | ||
| 319 | }); | ||
| 320 | }; | ||
| 321 | |||
| 322 | if (__objects_are_in_buffer) | ||
| 323 | __merge_chunks(__values.get(), __first); | ||
| 324 | else | ||
| 325 | __merge_chunks(__first, __values.get()); | ||
| 326 | __objects_are_in_buffer = !__objects_are_in_buffer; | ||
| 327 | } while (__partitions.__chunk_count_ > 1); | ||
| 328 | |||
| 329 | if (__objects_are_in_buffer) { | ||
| 330 | std::move(__values.get(), __values.get() + __size, __first); | ||
| 331 | } | ||
| 332 | |||
| 333 | return __empty{}; | ||
| 334 | } | ||
| 335 | |||
| 336 | _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {} | ||
| 337 | |||
| 338 | } // namespace __libdispatch | ||
| 339 | } // namespace __par_backend | ||
| 340 | |||
| 341 | _LIBCPP_END_NAMESPACE_STD | ||
| 342 | |||
| 343 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 344 | |||
| 345 | _LIBCPP_POP_MACROS | ||
| 346 | |||
| 347 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h deleted-85| ... | @@ -1,85 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H | ||
| 11 | |||
| 12 | #include <__algorithm/merge.h> | ||
| 13 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__utility/move.h> | ||
| 18 | #include <optional> | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | # include <__undef_macros> | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | |||
| 31 | template <class _ExecutionPolicy, | ||
| 32 | class _ForwardIterator1, | ||
| 33 | class _ForwardIterator2, | ||
| 34 | class _ForwardOutIterator, | ||
| 35 | class _Comp> | ||
| 36 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_merge( | ||
| 37 | __cpu_backend_tag, | ||
| 38 | _ForwardIterator1 __first1, | ||
| 39 | _ForwardIterator1 __last1, | ||
| 40 | _ForwardIterator2 __first2, | ||
| 41 | _ForwardIterator2 __last2, | ||
| 42 | _ForwardOutIterator __result, | ||
| 43 | _Comp __comp) { | ||
| 44 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 45 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 46 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && | ||
| 47 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 48 | auto __res = __par_backend::__parallel_merge( | ||
| 49 | __first1, | ||
| 50 | __last1, | ||
| 51 | __first2, | ||
| 52 | __last2, | ||
| 53 | __result, | ||
| 54 | __comp, | ||
| 55 | [](_ForwardIterator1 __g_first1, | ||
| 56 | _ForwardIterator1 __g_last1, | ||
| 57 | _ForwardIterator2 __g_first2, | ||
| 58 | _ForwardIterator2 __g_last2, | ||
| 59 | _ForwardOutIterator __g_result, | ||
| 60 | _Comp __g_comp) { | ||
| 61 | [[maybe_unused]] auto __g_res = std::__pstl_merge<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 62 | __cpu_backend_tag{}, | ||
| 63 | std::move(__g_first1), | ||
| 64 | std::move(__g_last1), | ||
| 65 | std::move(__g_first2), | ||
| 66 | std::move(__g_last2), | ||
| 67 | std::move(__g_result), | ||
| 68 | std::move(__g_comp)); | ||
| 69 | _LIBCPP_ASSERT_INTERNAL(__g_res, "unsed/sed should never try to allocate!"); | ||
| 70 | }); | ||
| 71 | if (!__res) | ||
| 72 | return nullopt; | ||
| 73 | return __result + (__last1 - __first1) + (__last2 - __first2); | ||
| 74 | } else { | ||
| 75 | return std::merge(__first1, __last1, __first2, __last2, __result, __comp); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | _LIBCPP_END_NAMESPACE_STD | ||
| 80 | |||
| 81 | _LIBCPP_POP_MACROS | ||
| 82 | |||
| 83 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 84 | |||
| 85 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h deleted-83| ... | @@ -1,83 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H | ||
| 11 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__utility/empty.h> | ||
| 15 | #include <__utility/move.h> | ||
| 16 | #include <cstddef> | ||
| 17 | #include <optional> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 24 | |||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | # include <__undef_macros> | ||
| 27 | |||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 29 | |||
| 30 | namespace __par_backend { | ||
| 31 | inline namespace __serial_cpu_backend { | ||
| 32 | |||
| 33 | template <class _RandomAccessIterator, class _Fp> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 35 | __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { | ||
| 36 | __f(__first, __last); | ||
| 37 | return __empty{}; | ||
| 38 | } | ||
| 39 | |||
| 40 | template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> | ||
| 42 | __parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) { | ||
| 43 | return __reduce(std::move(__first), std::move(__last), std::move(__init)); | ||
| 44 | } | ||
| 45 | |||
| 46 | template <class _RandomAccessIterator, class _Compare, class _LeafSort> | ||
| 47 | _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort( | ||
| 48 | _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) { | ||
| 49 | __leaf_sort(__first, __last, __comp); | ||
| 50 | return __empty{}; | ||
| 51 | } | ||
| 52 | |||
| 53 | _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {} | ||
| 54 | |||
| 55 | template <class _RandomAccessIterator1, | ||
| 56 | class _RandomAccessIterator2, | ||
| 57 | class _RandomAccessIterator3, | ||
| 58 | class _Compare, | ||
| 59 | class _LeafMerge> | ||
| 60 | _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge( | ||
| 61 | _RandomAccessIterator1 __first1, | ||
| 62 | _RandomAccessIterator1 __last1, | ||
| 63 | _RandomAccessIterator2 __first2, | ||
| 64 | _RandomAccessIterator2 __last2, | ||
| 65 | _RandomAccessIterator3 __outit, | ||
| 66 | _Compare __comp, | ||
| 67 | _LeafMerge __leaf_merge) { | ||
| 68 | __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp); | ||
| 69 | return __empty{}; | ||
| 70 | } | ||
| 71 | |||
| 72 | // TODO: Complete this list | ||
| 73 | |||
| 74 | } // namespace __serial_cpu_backend | ||
| 75 | } // namespace __par_backend | ||
| 76 | |||
| 77 | _LIBCPP_END_NAMESPACE_STD | ||
| 78 | |||
| 79 | _LIBCPP_POP_MACROS | ||
| 80 | |||
| 81 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17 | ||
| 82 | |||
| 83 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h deleted-45| ... | @@ -1,45 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 13 | #include <__algorithm/stable_sort.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__type_traits/is_execution_policy.h> | ||
| 16 | #include <__utility/empty.h> | ||
| 17 | #include <optional> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp> | ||
| 28 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 29 | __pstl_stable_sort(__cpu_backend_tag, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { | ||
| 30 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy>) { | ||
| 31 | return __par_backend::__parallel_stable_sort( | ||
| 32 | __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) { | ||
| 33 | std::stable_sort(__g_first, __g_last, __g_comp); | ||
| 34 | }); | ||
| 35 | } else { | ||
| 36 | std::stable_sort(__first, __last, __comp); | ||
| 37 | return __empty{}; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | _LIBCPP_END_NAMESPACE_STD | ||
| 42 | |||
| 43 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 44 | |||
| 45 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h deleted-84| ... | @@ -1,84 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H | ||
| 11 | |||
| 12 | #include <__assert> | ||
| 13 | #include <__config> | ||
| 14 | #include <__utility/empty.h> | ||
| 15 | #include <__utility/move.h> | ||
| 16 | #include <cstddef> | ||
| 17 | #include <optional> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | _LIBCPP_PUSH_MACROS | ||
| 24 | #include <__undef_macros> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 27 | |||
| 28 | // This backend implementation is for testing purposes only and not meant for production use. This will be replaced | ||
| 29 | // by a proper implementation once the PSTL implementation is somewhat stable. | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | namespace __par_backend { | ||
| 34 | inline namespace __thread_cpu_backend { | ||
| 35 | |||
| 36 | template <class _RandomAccessIterator, class _Fp> | ||
| 37 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 38 | __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { | ||
| 39 | __f(__first, __last); | ||
| 40 | return __empty{}; | ||
| 41 | } | ||
| 42 | |||
| 43 | template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce> | ||
| 44 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> | ||
| 45 | __parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) { | ||
| 46 | return __reduce(std::move(__first), std::move(__last), std::move(__init)); | ||
| 47 | } | ||
| 48 | |||
| 49 | template <class _RandomAccessIterator, class _Compare, class _LeafSort> | ||
| 50 | _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort( | ||
| 51 | _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) { | ||
| 52 | __leaf_sort(__first, __last, __comp); | ||
| 53 | return __empty{}; | ||
| 54 | } | ||
| 55 | |||
| 56 | _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {} | ||
| 57 | |||
| 58 | template <class _RandomAccessIterator1, | ||
| 59 | class _RandomAccessIterator2, | ||
| 60 | class _RandomAccessIterator3, | ||
| 61 | class _Compare, | ||
| 62 | class _LeafMerge> | ||
| 63 | _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge( | ||
| 64 | _RandomAccessIterator1 __first1, | ||
| 65 | _RandomAccessIterator1 __last1, | ||
| 66 | _RandomAccessIterator2 __first2, | ||
| 67 | _RandomAccessIterator2 __last2, | ||
| 68 | _RandomAccessIterator3 __outit, | ||
| 69 | _Compare __comp, | ||
| 70 | _LeafMerge __leaf_merge) { | ||
| 71 | __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp); | ||
| 72 | return __empty{}; | ||
| 73 | } | ||
| 74 | |||
| 75 | } // namespace __thread_cpu_backend | ||
| 76 | } // namespace __par_backend | ||
| 77 | |||
| 78 | _LIBCPP_END_NAMESPACE_STD | ||
| 79 | |||
| 80 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17 | ||
| 81 | |||
| 82 | _LIBCPP_POP_MACROS | ||
| 83 | |||
| 84 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h deleted-138| ... | @@ -1,138 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 13 | #include <__algorithm/transform.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | ||
| 17 | #include <__type_traits/enable_if.h> | ||
| 18 | #include <__type_traits/is_execution_policy.h> | ||
| 19 | #include <__type_traits/remove_cvref.h> | ||
| 20 | #include <optional> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | # include <__undef_macros> | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Function> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI _Iterator2 | ||
| 35 | __simd_walk(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept { | ||
| 36 | _PSTL_PRAGMA_SIMD | ||
| 37 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 38 | __f(__first1[__i], __first2[__i]); | ||
| 39 | return __first2 + __n; | ||
| 40 | } | ||
| 41 | |||
| 42 | template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform( | ||
| 44 | __cpu_backend_tag, | ||
| 45 | _ForwardIterator __first, | ||
| 46 | _ForwardIterator __last, | ||
| 47 | _ForwardOutIterator __result, | ||
| 48 | _UnaryOperation __op) { | ||
| 49 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 50 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && | ||
| 51 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 52 | std::__par_backend::__parallel_for( | ||
| 53 | __first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 54 | auto __res = std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 55 | __cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op); | ||
| 56 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 57 | return *std::move(__res); | ||
| 58 | }); | ||
| 59 | return __result + (__last - __first); | ||
| 60 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 61 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && | ||
| 62 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 63 | return std::__simd_walk( | ||
| 64 | __first, | ||
| 65 | __last - __first, | ||
| 66 | __result, | ||
| 67 | [&](__iter_reference<_ForwardIterator> __in_value, __iter_reference<_ForwardOutIterator> __out_value) { | ||
| 68 | __out_value = __op(__in_value); | ||
| 69 | }); | ||
| 70 | } else { | ||
| 71 | return std::transform(__first, __last, __result, __op); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Iterator3, class _Function> | ||
| 76 | _LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_walk( | ||
| 77 | _Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3, _Function __f) noexcept { | ||
| 78 | _PSTL_PRAGMA_SIMD | ||
| 79 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 80 | __f(__first1[__i], __first2[__i], __first3[__i]); | ||
| 81 | return __first3 + __n; | ||
| 82 | } | ||
| 83 | template <class _ExecutionPolicy, | ||
| 84 | class _ForwardIterator1, | ||
| 85 | class _ForwardIterator2, | ||
| 86 | class _ForwardOutIterator, | ||
| 87 | class _BinaryOperation, | ||
| 88 | enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> | ||
| 89 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform( | ||
| 90 | __cpu_backend_tag, | ||
| 91 | _ForwardIterator1 __first1, | ||
| 92 | _ForwardIterator1 __last1, | ||
| 93 | _ForwardIterator2 __first2, | ||
| 94 | _ForwardOutIterator __result, | ||
| 95 | _BinaryOperation __op) { | ||
| 96 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 97 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 98 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && | ||
| 99 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 100 | auto __res = std::__par_backend::__parallel_for( | ||
| 101 | __first1, | ||
| 102 | __last1, | ||
| 103 | [__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) { | ||
| 104 | return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 105 | __cpu_backend_tag{}, | ||
| 106 | __brick_first, | ||
| 107 | __brick_last, | ||
| 108 | __first2 + (__brick_first - __first1), | ||
| 109 | __result + (__brick_first - __first1), | ||
| 110 | __op); | ||
| 111 | }); | ||
| 112 | if (!__res) | ||
| 113 | return nullopt; | ||
| 114 | return __result + (__last1 - __first1); | ||
| 115 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 116 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 117 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && | ||
| 118 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 119 | return std::__simd_walk( | ||
| 120 | __first1, | ||
| 121 | __last1 - __first1, | ||
| 122 | __first2, | ||
| 123 | __result, | ||
| 124 | [&](__iter_reference<_ForwardIterator1> __in1, | ||
| 125 | __iter_reference<_ForwardIterator2> __in2, | ||
| 126 | __iter_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in1, __in2); }); | ||
| 127 | } else { | ||
| 128 | return std::transform(__first1, __last1, __first2, __result, __op); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | _LIBCPP_END_NAMESPACE_STD | ||
| 133 | |||
| 134 | _LIBCPP_POP_MACROS | ||
| 135 | |||
| 136 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 137 | |||
| 138 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H | ||
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h deleted-202| ... | @@ -1,202 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backends/cpu_backends/backend.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__iterator/concepts.h> | ||
| 15 | #include <__iterator/iterator_traits.h> | ||
| 16 | #include <__numeric/transform_reduce.h> | ||
| 17 | #include <__type_traits/is_arithmetic.h> | ||
| 18 | #include <__type_traits/is_execution_policy.h> | ||
| 19 | #include <__type_traits/operation_traits.h> | ||
| 20 | #include <__utility/move.h> | ||
| 21 | #include <new> | ||
| 22 | #include <optional> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 31 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | |||
| 35 | template <typename _DifferenceType, | ||
| 36 | typename _Tp, | ||
| 37 | typename _BinaryOperation, | ||
| 38 | typename _UnaryOperation, | ||
| 39 | typename _UnaryResult = invoke_result_t<_UnaryOperation, _DifferenceType>, | ||
| 40 | __enable_if_t<__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value && is_arithmetic_v<_Tp> && | ||
| 41 | is_arithmetic_v<_UnaryResult>, | ||
| 42 | int> = 0> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 44 | __simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _UnaryOperation __f) noexcept { | ||
| 45 | _PSTL_PRAGMA_SIMD_REDUCTION(+ : __init) | ||
| 46 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 47 | __init += __f(__i); | ||
| 48 | return __init; | ||
| 49 | } | ||
| 50 | |||
| 51 | template <typename _Size, | ||
| 52 | typename _Tp, | ||
| 53 | typename _BinaryOperation, | ||
| 54 | typename _UnaryOperation, | ||
| 55 | typename _UnaryResult = invoke_result_t<_UnaryOperation, _Size>, | ||
| 56 | __enable_if_t<!(__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value && | ||
| 57 | is_arithmetic_v<_Tp> && is_arithmetic_v<_UnaryResult>), | ||
| 58 | int> = 0> | ||
| 59 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 60 | __simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _UnaryOperation __f) noexcept { | ||
| 61 | const _Size __block_size = __lane_size / sizeof(_Tp); | ||
| 62 | if (__n > 2 * __block_size && __block_size > 1) { | ||
| 63 | alignas(__lane_size) char __lane_buffer[__lane_size]; | ||
| 64 | _Tp* __lane = reinterpret_cast<_Tp*>(__lane_buffer); | ||
| 65 | |||
| 66 | // initializer | ||
| 67 | _PSTL_PRAGMA_SIMD | ||
| 68 | for (_Size __i = 0; __i < __block_size; ++__i) { | ||
| 69 | ::new (__lane + __i) _Tp(__binary_op(__f(__i), __f(__block_size + __i))); | ||
| 70 | } | ||
| 71 | // main loop | ||
| 72 | _Size __i = 2 * __block_size; | ||
| 73 | const _Size __last_iteration = __block_size * (__n / __block_size); | ||
| 74 | for (; __i < __last_iteration; __i += __block_size) { | ||
| 75 | _PSTL_PRAGMA_SIMD | ||
| 76 | for (_Size __j = 0; __j < __block_size; ++__j) { | ||
| 77 | __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__i + __j)); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | // remainder | ||
| 81 | _PSTL_PRAGMA_SIMD | ||
| 82 | for (_Size __j = 0; __j < __n - __last_iteration; ++__j) { | ||
| 83 | __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__last_iteration + __j)); | ||
| 84 | } | ||
| 85 | // combiner | ||
| 86 | for (_Size __j = 0; __j < __block_size; ++__j) { | ||
| 87 | __init = __binary_op(std::move(__init), std::move(__lane[__j])); | ||
| 88 | } | ||
| 89 | // destroyer | ||
| 90 | _PSTL_PRAGMA_SIMD | ||
| 91 | for (_Size __j = 0; __j < __block_size; ++__j) { | ||
| 92 | __lane[__j].~_Tp(); | ||
| 93 | } | ||
| 94 | } else { | ||
| 95 | for (_Size __i = 0; __i < __n; ++__i) { | ||
| 96 | __init = __binary_op(std::move(__init), __f(__i)); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | return __init; | ||
| 100 | } | ||
| 101 | |||
| 102 | template <class _ExecutionPolicy, | ||
| 103 | class _ForwardIterator1, | ||
| 104 | class _ForwardIterator2, | ||
| 105 | class _Tp, | ||
| 106 | class _BinaryOperation1, | ||
| 107 | class _BinaryOperation2> | ||
| 108 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce( | ||
| 109 | __cpu_backend_tag, | ||
| 110 | _ForwardIterator1 __first1, | ||
| 111 | _ForwardIterator1 __last1, | ||
| 112 | _ForwardIterator2 __first2, | ||
| 113 | _Tp __init, | ||
| 114 | _BinaryOperation1 __reduce, | ||
| 115 | _BinaryOperation2 __transform) { | ||
| 116 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 117 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 118 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { | ||
| 119 | return __par_backend::__parallel_transform_reduce( | ||
| 120 | __first1, | ||
| 121 | std::move(__last1), | ||
| 122 | [__first1, __first2, __transform](_ForwardIterator1 __iter) { | ||
| 123 | return __transform(*__iter, *(__first2 + (__iter - __first1))); | ||
| 124 | }, | ||
| 125 | std::move(__init), | ||
| 126 | std::move(__reduce), | ||
| 127 | [__first1, __first2, __reduce, __transform]( | ||
| 128 | _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) { | ||
| 129 | return *std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 130 | __cpu_backend_tag{}, | ||
| 131 | __brick_first, | ||
| 132 | std::move(__brick_last), | ||
| 133 | __first2 + (__brick_first - __first1), | ||
| 134 | std::move(__brick_init), | ||
| 135 | std::move(__reduce), | ||
| 136 | std::move(__transform)); | ||
| 137 | }); | ||
| 138 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 139 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 140 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { | ||
| 141 | return std::__simd_transform_reduce( | ||
| 142 | __last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) { | ||
| 143 | return __transform(__first1[__i], __first2[__i]); | ||
| 144 | }); | ||
| 145 | } else { | ||
| 146 | return std::transform_reduce( | ||
| 147 | std::move(__first1), | ||
| 148 | std::move(__last1), | ||
| 149 | std::move(__first2), | ||
| 150 | std::move(__init), | ||
| 151 | std::move(__reduce), | ||
| 152 | std::move(__transform)); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> | ||
| 157 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce( | ||
| 158 | __cpu_backend_tag, | ||
| 159 | _ForwardIterator __first, | ||
| 160 | _ForwardIterator __last, | ||
| 161 | _Tp __init, | ||
| 162 | _BinaryOperation __reduce, | ||
| 163 | _UnaryOperation __transform) { | ||
| 164 | if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && | ||
| 165 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 166 | return __par_backend::__parallel_transform_reduce( | ||
| 167 | std::move(__first), | ||
| 168 | std::move(__last), | ||
| 169 | [__transform](_ForwardIterator __iter) { return __transform(*__iter); }, | ||
| 170 | std::move(__init), | ||
| 171 | __reduce, | ||
| 172 | [__transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) { | ||
| 173 | auto __res = std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( | ||
| 174 | __cpu_backend_tag{}, | ||
| 175 | std::move(__brick_first), | ||
| 176 | std::move(__brick_last), | ||
| 177 | std::move(__brick_init), | ||
| 178 | std::move(__reduce), | ||
| 179 | std::move(__transform)); | ||
| 180 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 181 | return *std::move(__res); | ||
| 182 | }); | ||
| 183 | } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && | ||
| 184 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 185 | return std::__simd_transform_reduce( | ||
| 186 | __last - __first, | ||
| 187 | std::move(__init), | ||
| 188 | std::move(__reduce), | ||
| 189 | [=, &__transform](__iter_diff_t<_ForwardIterator> __i) { return __transform(__first[__i]); }); | ||
| 190 | } else { | ||
| 191 | return std::transform_reduce( | ||
| 192 | std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | _LIBCPP_END_NAMESPACE_STD | ||
| 197 | |||
| 198 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 199 | |||
| 200 | _LIBCPP_POP_MACROS | ||
| 201 | |||
| 202 | #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H | ||
lib/libcxx/include/__algorithm/pstl_copy.h deleted-121| ... | @@ -1,121 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_COPY_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_COPY_H | ||
| 11 | |||
| 12 | #include <__algorithm/copy_n.h> | ||
| 13 | #include <__algorithm/pstl_backend.h> | ||
| 14 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 15 | #include <__algorithm/pstl_transform.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__functional/identity.h> | ||
| 18 | #include <__iterator/concepts.h> | ||
| 19 | #include <__type_traits/enable_if.h> | ||
| 20 | #include <__type_traits/is_constant_evaluated.h> | ||
| 21 | #include <__type_traits/is_execution_policy.h> | ||
| 22 | #include <__type_traits/is_trivially_copyable.h> | ||
| 23 | #include <__type_traits/remove_cvref.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | #include <optional> | ||
| 26 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | #include <__undef_macros> | ||
| 33 | |||
| 34 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 35 | |||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 37 | |||
| 38 | // TODO: Use the std::copy/move shenanigans to forward to std::memmove | ||
| 39 | |||
| 40 | template <class> | ||
| 41 | void __pstl_copy(); | ||
| 42 | |||
| 43 | template <class _ExecutionPolicy, | ||
| 44 | class _ForwardIterator, | ||
| 45 | class _ForwardOutIterator, | ||
| 46 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 47 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 49 | __copy(_ExecutionPolicy&& __policy, | ||
| 50 | _ForwardIterator&& __first, | ||
| 51 | _ForwardIterator&& __last, | ||
| 52 | _ForwardOutIterator&& __result) noexcept { | ||
| 53 | return std::__pstl_frontend_dispatch( | ||
| 54 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy, _RawPolicy), | ||
| 55 | [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) { | ||
| 56 | return std::__transform(__policy, __g_first, __g_last, __g_result, __identity()); | ||
| 57 | }, | ||
| 58 | std::move(__first), | ||
| 59 | std::move(__last), | ||
| 60 | std::move(__result)); | ||
| 61 | } | ||
| 62 | |||
| 63 | template <class _ExecutionPolicy, | ||
| 64 | class _ForwardIterator, | ||
| 65 | class _ForwardOutIterator, | ||
| 66 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 67 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 68 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 69 | copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) { | ||
| 70 | auto __res = std::__copy(__policy, std::move(__first), std::move(__last), std::move(__result)); | ||
| 71 | if (!__res) | ||
| 72 | std::__throw_bad_alloc(); | ||
| 73 | return *std::move(__res); | ||
| 74 | } | ||
| 75 | |||
| 76 | template <class> | ||
| 77 | void __pstl_copy_n(); | ||
| 78 | |||
| 79 | template <class _ExecutionPolicy, | ||
| 80 | class _ForwardIterator, | ||
| 81 | class _ForwardOutIterator, | ||
| 82 | class _Size, | ||
| 83 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 84 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 85 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __copy_n( | ||
| 86 | _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _ForwardOutIterator&& __result) noexcept { | ||
| 87 | return std::__pstl_frontend_dispatch( | ||
| 88 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy_n, _RawPolicy), | ||
| 89 | [&__policy]( | ||
| 90 | _ForwardIterator __g_first, _Size __g_n, _ForwardOutIterator __g_result) -> optional<_ForwardIterator> { | ||
| 91 | if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) | ||
| 92 | return std::__copy(__policy, std::move(__g_first), std::move(__g_first + __g_n), std::move(__g_result)); | ||
| 93 | else | ||
| 94 | return std::copy_n(__g_first, __g_n, __g_result); | ||
| 95 | }, | ||
| 96 | std::move(__first), | ||
| 97 | std::move(__n), | ||
| 98 | std::move(__result)); | ||
| 99 | } | ||
| 100 | |||
| 101 | template <class _ExecutionPolicy, | ||
| 102 | class _ForwardIterator, | ||
| 103 | class _ForwardOutIterator, | ||
| 104 | class _Size, | ||
| 105 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 106 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 107 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 108 | copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) { | ||
| 109 | auto __res = std::__copy_n(__policy, std::move(__first), std::move(__n), std::move(__result)); | ||
| 110 | if (!__res) | ||
| 111 | std::__throw_bad_alloc(); | ||
| 112 | return *std::move(__res); | ||
| 113 | } | ||
| 114 | |||
| 115 | _LIBCPP_END_NAMESPACE_STD | ||
| 116 | |||
| 117 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 118 | |||
| 119 | _LIBCPP_POP_MACROS | ||
| 120 | |||
| 121 | #endif // _LIBCPP___ALGORITHM_PSTL_COPY_H | ||
lib/libcxx/include/__algorithm/pstl_count.h deleted-121| ... | @@ -1,121 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_COUNT_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_COUNT_H | ||
| 11 | |||
| 12 | #include <__algorithm/count.h> | ||
| 13 | #include <__algorithm/for_each.h> | ||
| 14 | #include <__algorithm/pstl_backend.h> | ||
| 15 | #include <__algorithm/pstl_for_each.h> | ||
| 16 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 17 | #include <__atomic/atomic.h> | ||
| 18 | #include <__config> | ||
| 19 | #include <__functional/operations.h> | ||
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__numeric/pstl_transform_reduce.h> | ||
| 22 | #include <__type_traits/enable_if.h> | ||
| 23 | #include <__type_traits/is_execution_policy.h> | ||
| 24 | #include <__type_traits/remove_cvref.h> | ||
| 25 | #include <__utility/move.h> | ||
| 26 | #include <optional> | ||
| 27 | |||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 29 | # pragma GCC system_header | ||
| 30 | #endif | ||
| 31 | |||
| 32 | _LIBCPP_PUSH_MACROS | ||
| 33 | #include <__undef_macros> | ||
| 34 | |||
| 35 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 36 | |||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 38 | |||
| 39 | template <class> | ||
| 40 | void __pstl_count_if(); // declaration needed for the frontend dispatch below | ||
| 41 | |||
| 42 | template <class _ExecutionPolicy, | ||
| 43 | class _ForwardIterator, | ||
| 44 | class _Predicate, | ||
| 45 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 46 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> __count_if( | ||
| 48 | _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept { | ||
| 49 | using __diff_t = __iter_diff_t<_ForwardIterator>; | ||
| 50 | return std::__pstl_frontend_dispatch( | ||
| 51 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if, _RawPolicy), | ||
| 52 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<__diff_t> { | ||
| 53 | return std::__transform_reduce( | ||
| 54 | __policy, | ||
| 55 | std::move(__g_first), | ||
| 56 | std::move(__g_last), | ||
| 57 | __diff_t(), | ||
| 58 | std::plus{}, | ||
| 59 | [&](__iter_reference<_ForwardIterator> __element) -> bool { return __g_pred(__element); }); | ||
| 60 | }, | ||
| 61 | std::move(__first), | ||
| 62 | std::move(__last), | ||
| 63 | std::move(__pred)); | ||
| 64 | } | ||
| 65 | |||
| 66 | template <class _ExecutionPolicy, | ||
| 67 | class _ForwardIterator, | ||
| 68 | class _Predicate, | ||
| 69 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 70 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 71 | _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> | ||
| 72 | count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 73 | auto __res = std::__count_if(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 74 | if (!__res) | ||
| 75 | std::__throw_bad_alloc(); | ||
| 76 | return *std::move(__res); | ||
| 77 | } | ||
| 78 | |||
| 79 | template <class> | ||
| 80 | void __pstl_count(); // declaration needed for the frontend dispatch below | ||
| 81 | |||
| 82 | template <class _ExecutionPolicy, | ||
| 83 | class _ForwardIterator, | ||
| 84 | class _Tp, | ||
| 85 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 86 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 87 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> | ||
| 88 | __count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 89 | return std::__pstl_frontend_dispatch( | ||
| 90 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count, _RawPolicy), | ||
| 91 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) | ||
| 92 | -> optional<__iter_diff_t<_ForwardIterator>> { | ||
| 93 | return std::count_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __v) { | ||
| 94 | return __v == __g_value; | ||
| 95 | }); | ||
| 96 | }, | ||
| 97 | std::move(__first), | ||
| 98 | std::move(__last), | ||
| 99 | __value); | ||
| 100 | } | ||
| 101 | |||
| 102 | template <class _ExecutionPolicy, | ||
| 103 | class _ForwardIterator, | ||
| 104 | class _Tp, | ||
| 105 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 106 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 107 | _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> | ||
| 108 | count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 109 | auto __res = std::__count(__policy, std::move(__first), std::move(__last), __value); | ||
| 110 | if (!__res) | ||
| 111 | std::__throw_bad_alloc(); | ||
| 112 | return *__res; | ||
| 113 | } | ||
| 114 | |||
| 115 | _LIBCPP_END_NAMESPACE_STD | ||
| 116 | |||
| 117 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 118 | |||
| 119 | _LIBCPP_POP_MACROS | ||
| 120 | |||
| 121 | #endif // _LIBCPP___ALGORITHM_PSTL_COUNT_H | ||
lib/libcxx/include/__algorithm/pstl_equal.h deleted-175| ... | @@ -1,175 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_EQUAL_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_EQUAL_H | ||
| 11 | |||
| 12 | #include <__algorithm/equal.h> | ||
| 13 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__functional/operations.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | ||
| 17 | #include <__numeric/pstl_transform_reduce.h> | ||
| 18 | #include <__utility/move.h> | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | _LIBCPP_PUSH_MACROS | ||
| 25 | #include <__undef_macros> | ||
| 26 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | |||
| 31 | template <class> | ||
| 32 | void __pstl_equal(); | ||
| 33 | |||
| 34 | template <class _ExecutionPolicy, | ||
| 35 | class _ForwardIterator1, | ||
| 36 | class _ForwardIterator2, | ||
| 37 | class _Pred, | ||
| 38 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 39 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 41 | __equal(_ExecutionPolicy&& __policy, | ||
| 42 | _ForwardIterator1&& __first1, | ||
| 43 | _ForwardIterator1&& __last1, | ||
| 44 | _ForwardIterator2&& __first2, | ||
| 45 | _Pred&& __pred) noexcept { | ||
| 46 | return std::__pstl_frontend_dispatch( | ||
| 47 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_equal, _RawPolicy), | ||
| 48 | [&__policy]( | ||
| 49 | _ForwardIterator1 __g_first1, _ForwardIterator1 __g_last1, _ForwardIterator2 __g_first2, _Pred __g_pred) { | ||
| 50 | return std::__transform_reduce( | ||
| 51 | __policy, | ||
| 52 | std::move(__g_first1), | ||
| 53 | std::move(__g_last1), | ||
| 54 | std::move(__g_first2), | ||
| 55 | true, | ||
| 56 | std::logical_and{}, | ||
| 57 | std::move(__g_pred)); | ||
| 58 | }, | ||
| 59 | std::move(__first1), | ||
| 60 | std::move(__last1), | ||
| 61 | std::move(__first2), | ||
| 62 | std::move(__pred)); | ||
| 63 | } | ||
| 64 | |||
| 65 | template <class _ExecutionPolicy, | ||
| 66 | class _ForwardIterator1, | ||
| 67 | class _ForwardIterator2, | ||
| 68 | class _Pred, | ||
| 69 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 70 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 71 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 72 | equal(_ExecutionPolicy&& __policy, | ||
| 73 | _ForwardIterator1 __first1, | ||
| 74 | _ForwardIterator1 __last1, | ||
| 75 | _ForwardIterator2 __first2, | ||
| 76 | _Pred __pred) { | ||
| 77 | auto __res = std::__equal(__policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__pred)); | ||
| 78 | if (!__res) | ||
| 79 | std::__throw_bad_alloc(); | ||
| 80 | return *__res; | ||
| 81 | } | ||
| 82 | |||
| 83 | template <class _ExecutionPolicy, | ||
| 84 | class _ForwardIterator1, | ||
| 85 | class _ForwardIterator2, | ||
| 86 | enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> | ||
| 87 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 88 | equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | ||
| 89 | return std::equal(__policy, std::move(__first1), std::move(__last1), std::move(__first2), std::equal_to{}); | ||
| 90 | } | ||
| 91 | |||
| 92 | template <class _ExecutionPolicy, | ||
| 93 | class _ForwardIterator1, | ||
| 94 | class _ForwardIterator2, | ||
| 95 | class _Pred, | ||
| 96 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 97 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 98 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 99 | __equal(_ExecutionPolicy&& __policy, | ||
| 100 | _ForwardIterator1&& __first1, | ||
| 101 | _ForwardIterator1&& __last1, | ||
| 102 | _ForwardIterator2&& __first2, | ||
| 103 | _ForwardIterator2&& __last2, | ||
| 104 | _Pred&& __pred) noexcept { | ||
| 105 | return std::__pstl_frontend_dispatch( | ||
| 106 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_equal, _RawPolicy), | ||
| 107 | [&__policy](_ForwardIterator1 __g_first1, | ||
| 108 | _ForwardIterator1 __g_last1, | ||
| 109 | _ForwardIterator2 __g_first2, | ||
| 110 | _ForwardIterator2 __g_last2, | ||
| 111 | _Pred __g_pred) -> optional<bool> { | ||
| 112 | if constexpr (__has_random_access_iterator_category<_ForwardIterator1>::value && | ||
| 113 | __has_random_access_iterator_category<_ForwardIterator2>::value) { | ||
| 114 | if (__g_last1 - __g_first1 != __g_last2 - __g_first2) | ||
| 115 | return false; | ||
| 116 | return std::__equal( | ||
| 117 | __policy, std::move(__g_first1), std::move(__g_last1), std::move(__g_first2), std::move(__g_pred)); | ||
| 118 | } else { | ||
| 119 | (void)__policy; // Avoid unused lambda capture warning | ||
| 120 | return std::equal( | ||
| 121 | std::move(__g_first1), | ||
| 122 | std::move(__g_last1), | ||
| 123 | std::move(__g_first2), | ||
| 124 | std::move(__g_last2), | ||
| 125 | std::move(__g_pred)); | ||
| 126 | } | ||
| 127 | }, | ||
| 128 | std::move(__first1), | ||
| 129 | std::move(__last1), | ||
| 130 | std::move(__first2), | ||
| 131 | std::move(__last2), | ||
| 132 | std::move(__pred)); | ||
| 133 | } | ||
| 134 | |||
| 135 | template <class _ExecutionPolicy, | ||
| 136 | class _ForwardIterator1, | ||
| 137 | class _ForwardIterator2, | ||
| 138 | class _Pred, | ||
| 139 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 140 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 141 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 142 | equal(_ExecutionPolicy&& __policy, | ||
| 143 | _ForwardIterator1 __first1, | ||
| 144 | _ForwardIterator1 __last1, | ||
| 145 | _ForwardIterator2 __first2, | ||
| 146 | _ForwardIterator2 __last2, | ||
| 147 | _Pred __pred) { | ||
| 148 | auto __res = std::__equal( | ||
| 149 | __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::move(__pred)); | ||
| 150 | if (!__res) | ||
| 151 | std::__throw_bad_alloc(); | ||
| 152 | return *__res; | ||
| 153 | } | ||
| 154 | |||
| 155 | template <class _ExecutionPolicy, | ||
| 156 | class _ForwardIterator1, | ||
| 157 | class _ForwardIterator2, | ||
| 158 | enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> | ||
| 159 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 160 | equal(_ExecutionPolicy&& __policy, | ||
| 161 | _ForwardIterator1 __first1, | ||
| 162 | _ForwardIterator1 __last1, | ||
| 163 | _ForwardIterator2 __first2, | ||
| 164 | _ForwardIterator2 __last2) { | ||
| 165 | return std::equal( | ||
| 166 | __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::equal_to{}); | ||
| 167 | } | ||
| 168 | |||
| 169 | _LIBCPP_END_NAMESPACE_STD | ||
| 170 | |||
| 171 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 172 | |||
| 173 | _LIBCPP_POP_MACROS | ||
| 174 | |||
| 175 | #endif // _LIBCPP___ALGORITHM_PSTL_EQUAL_H | ||
lib/libcxx/include/__algorithm/pstl_fill.h deleted-116| ... | @@ -1,116 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_FILL_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_FILL_H | ||
| 11 | |||
| 12 | #include <__algorithm/fill_n.h> | ||
| 13 | #include <__algorithm/pstl_for_each.h> | ||
| 14 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__iterator/concepts.h> | ||
| 17 | #include <__iterator/cpp17_iterator_concepts.h> | ||
| 18 | #include <__iterator/iterator_traits.h> | ||
| 19 | #include <__type_traits/enable_if.h> | ||
| 20 | #include <__type_traits/is_execution_policy.h> | ||
| 21 | #include <__type_traits/remove_cvref.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | #include <optional> | ||
| 24 | |||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 26 | # pragma GCC system_header | ||
| 27 | #endif | ||
| 28 | |||
| 29 | _LIBCPP_PUSH_MACROS | ||
| 30 | #include <__undef_macros> | ||
| 31 | |||
| 32 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 33 | |||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 35 | |||
| 36 | template <class> | ||
| 37 | void __pstl_fill(); // declaration needed for the frontend dispatch below | ||
| 38 | |||
| 39 | template <class _ExecutionPolicy, | ||
| 40 | class _ForwardIterator, | ||
| 41 | class _Tp, | ||
| 42 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 43 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 44 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 45 | __fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept { | ||
| 46 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 47 | return std::__pstl_frontend_dispatch( | ||
| 48 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill, _RawPolicy), | ||
| 49 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) { | ||
| 50 | return std::__for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) { | ||
| 51 | __element = __g_value; | ||
| 52 | }); | ||
| 53 | }, | ||
| 54 | std::move(__first), | ||
| 55 | std::move(__last), | ||
| 56 | __value); | ||
| 57 | } | ||
| 58 | |||
| 59 | template <class _ExecutionPolicy, | ||
| 60 | class _ForwardIterator, | ||
| 61 | class _Tp, | ||
| 62 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 63 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 64 | _LIBCPP_HIDE_FROM_ABI void | ||
| 65 | fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 66 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 67 | if (!std::__fill(__policy, std::move(__first), std::move(__last), __value)) | ||
| 68 | std::__throw_bad_alloc(); | ||
| 69 | } | ||
| 70 | |||
| 71 | template <class> | ||
| 72 | void __pstl_fill_n(); // declaration needed for the frontend dispatch below | ||
| 73 | |||
| 74 | template <class _ExecutionPolicy, | ||
| 75 | class _ForwardIterator, | ||
| 76 | class _SizeT, | ||
| 77 | class _Tp, | ||
| 78 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 79 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 80 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 81 | __fill_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _SizeT&& __n, const _Tp& __value) noexcept { | ||
| 82 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 83 | return std::__pstl_frontend_dispatch( | ||
| 84 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill_n, _RawPolicy), | ||
| 85 | [&](_ForwardIterator __g_first, _SizeT __g_n, const _Tp& __g_value) { | ||
| 86 | if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) | ||
| 87 | std::fill(__policy, __g_first, __g_first + __g_n, __g_value); | ||
| 88 | else | ||
| 89 | std::fill_n(__g_first, __g_n, __g_value); | ||
| 90 | return optional<__empty>{__empty{}}; | ||
| 91 | }, | ||
| 92 | std::move(__first), | ||
| 93 | std::move(__n), | ||
| 94 | __value); | ||
| 95 | } | ||
| 96 | |||
| 97 | template <class _ExecutionPolicy, | ||
| 98 | class _ForwardIterator, | ||
| 99 | class _SizeT, | ||
| 100 | class _Tp, | ||
| 101 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 102 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 103 | _LIBCPP_HIDE_FROM_ABI void | ||
| 104 | fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) { | ||
| 105 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 106 | if (!std::__fill_n(__policy, std::move(__first), std::move(__n), __value)) | ||
| 107 | std::__throw_bad_alloc(); | ||
| 108 | } | ||
| 109 | |||
| 110 | _LIBCPP_END_NAMESPACE_STD | ||
| 111 | |||
| 112 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 113 | |||
| 114 | _LIBCPP_POP_MACROS | ||
| 115 | |||
| 116 | #endif // _LIBCPP___ALGORITHM_PSTL_FILL_H | ||
lib/libcxx/include/__algorithm/pstl_find.h deleted-141| ... | @@ -1,141 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_FIND_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_FIND_H | ||
| 11 | |||
| 12 | #include <__algorithm/comp.h> | ||
| 13 | #include <__algorithm/find.h> | ||
| 14 | #include <__algorithm/pstl_backend.h> | ||
| 15 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__iterator/cpp17_iterator_concepts.h> | ||
| 18 | #include <__type_traits/enable_if.h> | ||
| 19 | #include <__type_traits/is_execution_policy.h> | ||
| 20 | #include <__type_traits/remove_cvref.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | #include <optional> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 31 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | |||
| 35 | template <class _ExecutionPolicy, | ||
| 36 | class _ForwardIterator, | ||
| 37 | class _Predicate, | ||
| 38 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 39 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>> | ||
| 41 | __find_if(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept { | ||
| 42 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 43 | return std::__pstl_find_if<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 44 | } | ||
| 45 | |||
| 46 | template <class _ExecutionPolicy, | ||
| 47 | class _ForwardIterator, | ||
| 48 | class _Predicate, | ||
| 49 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 50 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 51 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | ||
| 52 | find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 53 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 54 | auto __res = std::__find_if(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 55 | if (!__res) | ||
| 56 | std::__throw_bad_alloc(); | ||
| 57 | return *std::move(__res); | ||
| 58 | } | ||
| 59 | |||
| 60 | template <class> | ||
| 61 | void __pstl_find_if_not(); | ||
| 62 | |||
| 63 | template <class _ExecutionPolicy, | ||
| 64 | class _ForwardIterator, | ||
| 65 | class _Predicate, | ||
| 66 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 67 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>> | ||
| 69 | __find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) { | ||
| 70 | return std::__pstl_frontend_dispatch( | ||
| 71 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find_if_not, _RawPolicy), | ||
| 72 | [&](_ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Predicate&& __g_pred) | ||
| 73 | -> optional<__remove_cvref_t<_ForwardIterator>> { | ||
| 74 | return std::__find_if( | ||
| 75 | __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __value) { | ||
| 76 | return !__g_pred(__value); | ||
| 77 | }); | ||
| 78 | }, | ||
| 79 | std::move(__first), | ||
| 80 | std::move(__last), | ||
| 81 | std::move(__pred)); | ||
| 82 | } | ||
| 83 | |||
| 84 | template <class _ExecutionPolicy, | ||
| 85 | class _ForwardIterator, | ||
| 86 | class _Predicate, | ||
| 87 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 88 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 89 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | ||
| 90 | find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 91 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 92 | auto __res = std::__find_if_not(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 93 | if (!__res) | ||
| 94 | std::__throw_bad_alloc(); | ||
| 95 | return *std::move(__res); | ||
| 96 | } | ||
| 97 | |||
| 98 | template <class> | ||
| 99 | void __pstl_find(); | ||
| 100 | |||
| 101 | template <class _ExecutionPolicy, | ||
| 102 | class _ForwardIterator, | ||
| 103 | class _Tp, | ||
| 104 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 105 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 106 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>> | ||
| 107 | __find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept { | ||
| 108 | return std::__pstl_frontend_dispatch( | ||
| 109 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find, _RawPolicy), | ||
| 110 | [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) -> optional<_ForwardIterator> { | ||
| 111 | return std::find_if( | ||
| 112 | __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __element) { | ||
| 113 | return __element == __g_value; | ||
| 114 | }); | ||
| 115 | }, | ||
| 116 | std::move(__first), | ||
| 117 | std::move(__last), | ||
| 118 | __value); | ||
| 119 | } | ||
| 120 | |||
| 121 | template <class _ExecutionPolicy, | ||
| 122 | class _ForwardIterator, | ||
| 123 | class _Tp, | ||
| 124 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 125 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 126 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | ||
| 127 | find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
| 128 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 129 | auto __res = std::__find(__policy, std::move(__first), std::move(__last), __value); | ||
| 130 | if (!__res) | ||
| 131 | std::__throw_bad_alloc(); | ||
| 132 | return *std::move(__res); | ||
| 133 | } | ||
| 134 | |||
| 135 | _LIBCPP_END_NAMESPACE_STD | ||
| 136 | |||
| 137 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 138 | |||
| 139 | _LIBCPP_POP_MACROS | ||
| 140 | |||
| 141 | #endif // _LIBCPP___ALGORITHM_PSTL_FIND_H | ||
lib/libcxx/include/__algorithm/pstl_for_each.h deleted-108| ... | @@ -1,108 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_FOR_EACH_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_FOR_EACH_H | ||
| 11 | |||
| 12 | #include <__algorithm/for_each.h> | ||
| 13 | #include <__algorithm/for_each_n.h> | ||
| 14 | #include <__algorithm/pstl_backend.h> | ||
| 15 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__iterator/cpp17_iterator_concepts.h> | ||
| 19 | #include <__type_traits/enable_if.h> | ||
| 20 | #include <__type_traits/is_execution_policy.h> | ||
| 21 | #include <__type_traits/remove_cvref.h> | ||
| 22 | #include <__type_traits/void_t.h> | ||
| 23 | #include <__utility/empty.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | #include <optional> | ||
| 26 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | #include <__undef_macros> | ||
| 33 | |||
| 34 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 35 | |||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 37 | |||
| 38 | template <class _ExecutionPolicy, | ||
| 39 | class _ForwardIterator, | ||
| 40 | class _Function, | ||
| 41 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 42 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 44 | __for_each(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Function&& __func) noexcept { | ||
| 45 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 46 | return std::__pstl_for_each<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__func)); | ||
| 47 | } | ||
| 48 | |||
| 49 | template <class _ExecutionPolicy, | ||
| 50 | class _ForwardIterator, | ||
| 51 | class _Function, | ||
| 52 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 53 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 54 | _LIBCPP_HIDE_FROM_ABI void | ||
| 55 | for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) { | ||
| 56 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 57 | if (!std::__for_each(__policy, std::move(__first), std::move(__last), std::move(__func))) | ||
| 58 | std::__throw_bad_alloc(); | ||
| 59 | } | ||
| 60 | |||
| 61 | template <class> | ||
| 62 | void __pstl_for_each_n(); // declaration needed for the frontend dispatch below | ||
| 63 | |||
| 64 | template <class _ExecutionPolicy, | ||
| 65 | class _ForwardIterator, | ||
| 66 | class _Size, | ||
| 67 | class _Function, | ||
| 68 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 69 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 71 | __for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __size, _Function&& __func) noexcept { | ||
| 72 | return std::__pstl_frontend_dispatch( | ||
| 73 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n, _RawPolicy), | ||
| 74 | [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) -> optional<__empty> { | ||
| 75 | if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 76 | std::for_each(__policy, std::move(__g_first), __g_first + __g_size, std::move(__g_func)); | ||
| 77 | return __empty{}; | ||
| 78 | } else { | ||
| 79 | std::for_each_n(std::move(__g_first), __g_size, std::move(__g_func)); | ||
| 80 | return __empty{}; | ||
| 81 | } | ||
| 82 | }, | ||
| 83 | std::move(__first), | ||
| 84 | std::move(__size), | ||
| 85 | std::move(__func)); | ||
| 86 | } | ||
| 87 | |||
| 88 | template <class _ExecutionPolicy, | ||
| 89 | class _ForwardIterator, | ||
| 90 | class _Size, | ||
| 91 | class _Function, | ||
| 92 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 93 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 94 | _LIBCPP_HIDE_FROM_ABI void | ||
| 95 | for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) { | ||
| 96 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 97 | auto __res = std::__for_each_n(__policy, std::move(__first), std::move(__size), std::move(__func)); | ||
| 98 | if (!__res) | ||
| 99 | std::__throw_bad_alloc(); | ||
| 100 | } | ||
| 101 | |||
| 102 | _LIBCPP_END_NAMESPACE_STD | ||
| 103 | |||
| 104 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 105 | |||
| 106 | _LIBCPP_POP_MACROS | ||
| 107 | |||
| 108 | #endif // _LIBCPP___ALGORITHM_PSTL_FOR_EACH_H | ||
lib/libcxx/include/__algorithm/pstl_frontend_dispatch.h deleted-44| ... | @@ -1,44 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/is_callable.h> | ||
| 14 | #include <__utility/forward.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if _LIBCPP_STD_VER >= 17 | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | # define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name, policy) \ | ||
| 25 | [](auto&&... __args) -> decltype(std::name<policy>( \ | ||
| 26 | typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...)) { \ | ||
| 27 | return std::name<policy>(typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...); \ | ||
| 28 | } | ||
| 29 | |||
| 30 | template <class _SpecializedImpl, class _GenericImpl, class... _Args> | ||
| 31 | _LIBCPP_HIDE_FROM_ABI decltype(auto) | ||
| 32 | __pstl_frontend_dispatch(_SpecializedImpl __specialized_impl, _GenericImpl __generic_impl, _Args&&... __args) { | ||
| 33 | if constexpr (__is_callable<_SpecializedImpl, _Args...>::value) { | ||
| 34 | return __specialized_impl(std::forward<_Args>(__args)...); | ||
| 35 | } else { | ||
| 36 | return __generic_impl(std::forward<_Args>(__args)...); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | _LIBCPP_END_NAMESPACE_STD | ||
| 41 | |||
| 42 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 43 | |||
| 44 | #endif // _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH | ||
lib/libcxx/include/__algorithm/pstl_generate.h deleted-114| ... | @@ -1,114 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_GENERATE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_GENERATE_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__algorithm/pstl_for_each.h> | ||
| 14 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__iterator/cpp17_iterator_concepts.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | ||
| 18 | #include <__type_traits/enable_if.h> | ||
| 19 | #include <__type_traits/is_execution_policy.h> | ||
| 20 | #include <__type_traits/remove_cvref.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | #include <optional> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 31 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | |||
| 35 | template <class> | ||
| 36 | void __pstl_generate(); | ||
| 37 | |||
| 38 | template <class _ExecutionPolicy, | ||
| 39 | class _ForwardIterator, | ||
| 40 | class _Generator, | ||
| 41 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 42 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 44 | __generate(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Generator&& __gen) { | ||
| 45 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 46 | return std::__pstl_frontend_dispatch( | ||
| 47 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate, _RawPolicy), | ||
| 48 | [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Generator __g_gen) { | ||
| 49 | return std::__for_each( | ||
| 50 | __policy, std::move(__g_first), std::move(__g_last), [&](__iter_reference<_ForwardIterator> __element) { | ||
| 51 | __element = __g_gen(); | ||
| 52 | }); | ||
| 53 | }, | ||
| 54 | std::move(__first), | ||
| 55 | std::move(__last), | ||
| 56 | std::move(__gen)); | ||
| 57 | } | ||
| 58 | |||
| 59 | template <class _ExecutionPolicy, | ||
| 60 | class _ForwardIterator, | ||
| 61 | class _Generator, | ||
| 62 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 63 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 64 | _LIBCPP_HIDE_FROM_ABI void | ||
| 65 | generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { | ||
| 66 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 67 | if (!std::__generate(__policy, std::move(__first), std::move(__last), std::move(__gen))) | ||
| 68 | std::__throw_bad_alloc(); | ||
| 69 | } | ||
| 70 | |||
| 71 | template <class> | ||
| 72 | void __pstl_generate_n(); | ||
| 73 | |||
| 74 | template <class _ExecutionPolicy, | ||
| 75 | class _ForwardIterator, | ||
| 76 | class _Size, | ||
| 77 | class _Generator, | ||
| 78 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 79 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 80 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 81 | __generate_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _Generator&& __gen) { | ||
| 82 | return std::__pstl_frontend_dispatch( | ||
| 83 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate_n, _RawPolicy), | ||
| 84 | [&__policy](_ForwardIterator __g_first, _Size __g_n, _Generator __g_gen) { | ||
| 85 | return std::__for_each_n( | ||
| 86 | __policy, std::move(__g_first), std::move(__g_n), [&](__iter_reference<_ForwardIterator> __element) { | ||
| 87 | __element = __g_gen(); | ||
| 88 | }); | ||
| 89 | }, | ||
| 90 | std::move(__first), | ||
| 91 | __n, | ||
| 92 | std::move(__gen)); | ||
| 93 | } | ||
| 94 | |||
| 95 | template <class _ExecutionPolicy, | ||
| 96 | class _ForwardIterator, | ||
| 97 | class _Size, | ||
| 98 | class _Generator, | ||
| 99 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 100 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 101 | _LIBCPP_HIDE_FROM_ABI void | ||
| 102 | generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) { | ||
| 103 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 104 | if (!std::__generate_n(__policy, std::move(__first), std::move(__n), std::move(__gen))) | ||
| 105 | std::__throw_bad_alloc(); | ||
| 106 | } | ||
| 107 | |||
| 108 | _LIBCPP_END_NAMESPACE_STD | ||
| 109 | |||
| 110 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 111 | |||
| 112 | _LIBCPP_POP_MACROS | ||
| 113 | |||
| 114 | #endif // _LIBCPP___ALGORITHM_PSTL_GENERATE_H | ||
lib/libcxx/include/__algorithm/pstl_is_partitioned.h deleted-77| ... | @@ -1,77 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_any_all_none_of.h> | ||
| 13 | #include <__algorithm/pstl_backend.h> | ||
| 14 | #include <__algorithm/pstl_find.h> | ||
| 15 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__type_traits/enable_if.h> | ||
| 18 | #include <__type_traits/is_execution_policy.h> | ||
| 19 | #include <__type_traits/remove_cvref.h> | ||
| 20 | #include <__utility/move.h> | ||
| 21 | #include <optional> | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 24 | # pragma GCC system_header | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_PUSH_MACROS | ||
| 28 | #include <__undef_macros> | ||
| 29 | |||
| 30 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | template <class> | ||
| 35 | void __pstl_is_partitioned(); | ||
| 36 | |||
| 37 | template <class _ExecutionPolicy, | ||
| 38 | class _ForwardIterator, | ||
| 39 | class _Predicate, | ||
| 40 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 41 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 42 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __is_partitioned( | ||
| 43 | _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) { | ||
| 44 | return std::__pstl_frontend_dispatch( | ||
| 45 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned, _RawPolicy), | ||
| 46 | [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { | ||
| 47 | __g_first = std::find_if_not(__policy, __g_first, __g_last, __g_pred); | ||
| 48 | if (__g_first == __g_last) | ||
| 49 | return true; | ||
| 50 | ++__g_first; | ||
| 51 | return std::none_of(__policy, __g_first, __g_last, __g_pred); | ||
| 52 | }, | ||
| 53 | std::move(__first), | ||
| 54 | std::move(__last), | ||
| 55 | std::move(__pred)); | ||
| 56 | } | ||
| 57 | |||
| 58 | template <class _ExecutionPolicy, | ||
| 59 | class _ForwardIterator, | ||
| 60 | class _Predicate, | ||
| 61 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 62 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 63 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool | ||
| 64 | is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | ||
| 65 | auto __res = std::__is_partitioned(__policy, std::move(__first), std::move(__last), std::move(__pred)); | ||
| 66 | if (!__res) | ||
| 67 | std::__throw_bad_alloc(); | ||
| 68 | return *std::move(__res); | ||
| 69 | } | ||
| 70 | |||
| 71 | _LIBCPP_END_NAMESPACE_STD | ||
| 72 | |||
| 73 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 74 | |||
| 75 | _LIBCPP_POP_MACROS | ||
| 76 | |||
| 77 | #endif // _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED | ||
lib/libcxx/include/__algorithm/pstl_merge.h deleted-92| ... | @@ -1,92 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_MERGE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_MERGE_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__functional/operations.h> | ||
| 15 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__type_traits/remove_cvref.h> | ||
| 18 | #include <__utility/move.h> | ||
| 19 | #include <optional> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | #include <__undef_macros> | ||
| 27 | |||
| 28 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | template <class _ExecutionPolicy, | ||
| 33 | class _ForwardIterator1, | ||
| 34 | class _ForwardIterator2, | ||
| 35 | class _ForwardOutIterator, | ||
| 36 | class _Comp = std::less<>, | ||
| 37 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 38 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 40 | __merge(_ExecutionPolicy&&, | ||
| 41 | _ForwardIterator1 __first1, | ||
| 42 | _ForwardIterator1 __last1, | ||
| 43 | _ForwardIterator2 __first2, | ||
| 44 | _ForwardIterator2 __last2, | ||
| 45 | _ForwardOutIterator __result, | ||
| 46 | _Comp __comp = {}) noexcept { | ||
| 47 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 48 | return std::__pstl_merge<_RawPolicy>( | ||
| 49 | _Backend{}, | ||
| 50 | std::move(__first1), | ||
| 51 | std::move(__last1), | ||
| 52 | std::move(__first2), | ||
| 53 | std::move(__last2), | ||
| 54 | std::move(__result), | ||
| 55 | std::move(__comp)); | ||
| 56 | } | ||
| 57 | |||
| 58 | template <class _ExecutionPolicy, | ||
| 59 | class _ForwardIterator1, | ||
| 60 | class _ForwardIterator2, | ||
| 61 | class _ForwardOutIterator, | ||
| 62 | class _Comp = std::less<>, | ||
| 63 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 64 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 65 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 66 | merge(_ExecutionPolicy&& __policy, | ||
| 67 | _ForwardIterator1 __first1, | ||
| 68 | _ForwardIterator1 __last1, | ||
| 69 | _ForwardIterator2 __first2, | ||
| 70 | _ForwardIterator2 __last2, | ||
| 71 | _ForwardOutIterator __result, | ||
| 72 | _Comp __comp = {}) { | ||
| 73 | auto __res = std::__merge( | ||
| 74 | __policy, | ||
| 75 | std::move(__first1), | ||
| 76 | std::move(__last1), | ||
| 77 | std::move(__first2), | ||
| 78 | std::move(__last2), | ||
| 79 | std::move(__result), | ||
| 80 | std::move(__comp)); | ||
| 81 | if (!__res) | ||
| 82 | std::__throw_bad_alloc(); | ||
| 83 | return *std::move(__res); | ||
| 84 | } | ||
| 85 | |||
| 86 | _LIBCPP_END_NAMESPACE_STD | ||
| 87 | |||
| 88 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 89 | |||
| 90 | _LIBCPP_POP_MACROS | ||
| 91 | |||
| 92 | #endif // _LIBCPP___ALGORITHM_PSTL_MERGE_H | ||
lib/libcxx/include/__algorithm/pstl_move.h deleted-84| ... | @@ -1,84 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_MOVE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_MOVE_H | ||
| 11 | |||
| 12 | #include <__algorithm/copy_n.h> | ||
| 13 | #include <__algorithm/pstl_backend.h> | ||
| 14 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 15 | #include <__algorithm/pstl_transform.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__functional/identity.h> | ||
| 18 | #include <__iterator/iterator_traits.h> | ||
| 19 | #include <__type_traits/enable_if.h> | ||
| 20 | #include <__type_traits/is_constant_evaluated.h> | ||
| 21 | #include <__type_traits/is_execution_policy.h> | ||
| 22 | #include <__type_traits/is_trivially_copyable.h> | ||
| 23 | #include <__type_traits/remove_cvref.h> | ||
| 24 | #include <optional> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_PUSH_MACROS | ||
| 31 | #include <__undef_macros> | ||
| 32 | |||
| 33 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 34 | |||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 36 | |||
| 37 | // TODO: Use the std::copy/move shenanigans to forward to std::memmove | ||
| 38 | // Investigate whether we want to still forward to std::transform(policy) | ||
| 39 | // in that case for the execution::par part, or whether we actually want | ||
| 40 | // to run everything serially in that case. | ||
| 41 | |||
| 42 | template <class> | ||
| 43 | void __pstl_move(); | ||
| 44 | |||
| 45 | template <class _ExecutionPolicy, | ||
| 46 | class _ForwardIterator, | ||
| 47 | class _ForwardOutIterator, | ||
| 48 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 49 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 51 | __move(_ExecutionPolicy&& __policy, | ||
| 52 | _ForwardIterator&& __first, | ||
| 53 | _ForwardIterator&& __last, | ||
| 54 | _ForwardOutIterator&& __result) noexcept { | ||
| 55 | return std::__pstl_frontend_dispatch( | ||
| 56 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_move, _RawPolicy), | ||
| 57 | [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) { | ||
| 58 | return std::__transform(__policy, __g_first, __g_last, __g_result, [](auto&& __v) { return std::move(__v); }); | ||
| 59 | }, | ||
| 60 | std::move(__first), | ||
| 61 | std::move(__last), | ||
| 62 | std::move(__result)); | ||
| 63 | } | ||
| 64 | |||
| 65 | template <class _ExecutionPolicy, | ||
| 66 | class _ForwardIterator, | ||
| 67 | class _ForwardOutIterator, | ||
| 68 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 69 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 70 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator | ||
| 71 | move(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) { | ||
| 72 | auto __res = std::__move(__policy, std::move(__first), std::move(__last), std::move(__result)); | ||
| 73 | if (!__res) | ||
| 74 | std::__throw_bad_alloc(); | ||
| 75 | return *__res; | ||
| 76 | } | ||
| 77 | |||
| 78 | _LIBCPP_END_NAMESPACE_STD | ||
| 79 | |||
| 80 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 81 | |||
| 82 | _LIBCPP_POP_MACROS | ||
| 83 | |||
| 84 | #endif // _LIBCPP___ALGORITHM_PSTL_MOVE_H | ||
lib/libcxx/include/__algorithm/pstl_replace.h deleted-247| ... | @@ -1,247 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_REPLACE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_REPLACE_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__algorithm/pstl_for_each.h> | ||
| 14 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 15 | #include <__algorithm/pstl_transform.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__iterator/iterator_traits.h> | ||
| 18 | #include <__type_traits/enable_if.h> | ||
| 19 | #include <__type_traits/remove_cvref.h> | ||
| 20 | #include <__utility/move.h> | ||
| 21 | #include <optional> | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 24 | # pragma GCC system_header | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_PUSH_MACROS | ||
| 28 | #include <__undef_macros> | ||
| 29 | |||
| 30 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | template <class> | ||
| 35 | void __pstl_replace_if(); | ||
| 36 | |||
| 37 | template <class _ExecutionPolicy, | ||
| 38 | class _ForwardIterator, | ||
| 39 | class _Pred, | ||
| 40 | class _Tp, | ||
| 41 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 42 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 44 | __replace_if(_ExecutionPolicy&& __policy, | ||
| 45 | _ForwardIterator&& __first, | ||
| 46 | _ForwardIterator&& __last, | ||
| 47 | _Pred&& __pred, | ||
| 48 | const _Tp& __new_value) noexcept { | ||
| 49 | return std::__pstl_frontend_dispatch( | ||
| 50 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if, _RawPolicy), | ||
| 51 | [&__policy]( | ||
| 52 | _ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Pred&& __g_pred, const _Tp& __g_new_value) { | ||
| 53 | std::for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) { | ||
| 54 | if (__g_pred(__element)) | ||
| 55 | __element = __g_new_value; | ||
| 56 | }); | ||
| 57 | return optional<__empty>{__empty{}}; | ||
| 58 | }, | ||
| 59 | std::move(__first), | ||
| 60 | std::move(__last), | ||
| 61 | std::move(__pred), | ||
| 62 | __new_value); | ||
| 63 | } | ||
| 64 | |||
| 65 | template <class _ExecutionPolicy, | ||
| 66 | class _ForwardIterator, | ||
| 67 | class _Pred, | ||
| 68 | class _Tp, | ||
| 69 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 70 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 71 | _LIBCPP_HIDE_FROM_ABI void | ||
| 72 | replace_if(_ExecutionPolicy&& __policy, | ||
| 73 | _ForwardIterator __first, | ||
| 74 | _ForwardIterator __last, | ||
| 75 | _Pred __pred, | ||
| 76 | const _Tp& __new_value) { | ||
| 77 | auto __res = std::__replace_if(__policy, std::move(__first), std::move(__last), std::move(__pred), __new_value); | ||
| 78 | if (!__res) | ||
| 79 | std::__throw_bad_alloc(); | ||
| 80 | } | ||
| 81 | |||
| 82 | template <class> | ||
| 83 | void __pstl_replace(); | ||
| 84 | |||
| 85 | template <class _ExecutionPolicy, | ||
| 86 | class _ForwardIterator, | ||
| 87 | class _Tp, | ||
| 88 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 89 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 90 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 91 | __replace(_ExecutionPolicy&& __policy, | ||
| 92 | _ForwardIterator __first, | ||
| 93 | _ForwardIterator __last, | ||
| 94 | const _Tp& __old_value, | ||
| 95 | const _Tp& __new_value) noexcept { | ||
| 96 | return std::__pstl_frontend_dispatch( | ||
| 97 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace, _RawPolicy), | ||
| 98 | [&__policy]( | ||
| 99 | _ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_old_value, const _Tp& __g_new_value) { | ||
| 100 | return std::__replace_if( | ||
| 101 | __policy, | ||
| 102 | std::move(__g_first), | ||
| 103 | std::move(__g_last), | ||
| 104 | [&](__iter_reference<_ForwardIterator> __element) { return __element == __g_old_value; }, | ||
| 105 | __g_new_value); | ||
| 106 | }, | ||
| 107 | std::move(__first), | ||
| 108 | std::move(__last), | ||
| 109 | __old_value, | ||
| 110 | __new_value); | ||
| 111 | } | ||
| 112 | |||
| 113 | template <class _ExecutionPolicy, | ||
| 114 | class _ForwardIterator, | ||
| 115 | class _Tp, | ||
| 116 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 117 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 118 | _LIBCPP_HIDE_FROM_ABI void | ||
| 119 | replace(_ExecutionPolicy&& __policy, | ||
| 120 | _ForwardIterator __first, | ||
| 121 | _ForwardIterator __last, | ||
| 122 | const _Tp& __old_value, | ||
| 123 | const _Tp& __new_value) { | ||
| 124 | if (!std::__replace(__policy, std::move(__first), std::move(__last), __old_value, __new_value)) | ||
| 125 | std::__throw_bad_alloc(); | ||
| 126 | } | ||
| 127 | |||
| 128 | template <class> | ||
| 129 | void __pstl_replace_copy_if(); | ||
| 130 | |||
| 131 | template <class _ExecutionPolicy, | ||
| 132 | class _ForwardIterator, | ||
| 133 | class _ForwardOutIterator, | ||
| 134 | class _Pred, | ||
| 135 | class _Tp, | ||
| 136 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 137 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 138 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy_if( | ||
| 139 | _ExecutionPolicy&& __policy, | ||
| 140 | _ForwardIterator&& __first, | ||
| 141 | _ForwardIterator&& __last, | ||
| 142 | _ForwardOutIterator&& __result, | ||
| 143 | _Pred&& __pred, | ||
| 144 | const _Tp& __new_value) { | ||
| 145 | return std::__pstl_frontend_dispatch( | ||
| 146 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if, _RawPolicy), | ||
| 147 | [&__policy](_ForwardIterator __g_first, | ||
| 148 | _ForwardIterator __g_last, | ||
| 149 | _ForwardOutIterator __g_result, | ||
| 150 | _Pred __g_pred, | ||
| 151 | const _Tp& __g_new_value) -> optional<__empty> { | ||
| 152 | if (!std::__transform( | ||
| 153 | __policy, __g_first, __g_last, __g_result, [&](__iter_reference<_ForwardIterator> __element) { | ||
| 154 | return __g_pred(__element) ? __g_new_value : __element; | ||
| 155 | })) | ||
| 156 | return nullopt; | ||
| 157 | return __empty{}; | ||
| 158 | }, | ||
| 159 | std::move(__first), | ||
| 160 | std::move(__last), | ||
| 161 | std::move(__result), | ||
| 162 | std::move(__pred), | ||
| 163 | __new_value); | ||
| 164 | } | ||
| 165 | |||
| 166 | template <class _ExecutionPolicy, | ||
| 167 | class _ForwardIterator, | ||
| 168 | class _ForwardOutIterator, | ||
| 169 | class _Pred, | ||
| 170 | class _Tp, | ||
| 171 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 172 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 173 | _LIBCPP_HIDE_FROM_ABI void replace_copy_if( | ||
| 174 | _ExecutionPolicy&& __policy, | ||
| 175 | _ForwardIterator __first, | ||
| 176 | _ForwardIterator __last, | ||
| 177 | _ForwardOutIterator __result, | ||
| 178 | _Pred __pred, | ||
| 179 | const _Tp& __new_value) { | ||
| 180 | if (!std::__replace_copy_if( | ||
| 181 | __policy, std::move(__first), std::move(__last), std::move(__result), std::move(__pred), __new_value)) | ||
| 182 | std::__throw_bad_alloc(); | ||
| 183 | } | ||
| 184 | |||
| 185 | template <class> | ||
| 186 | void __pstl_replace_copy(); | ||
| 187 | |||
| 188 | template <class _ExecutionPolicy, | ||
| 189 | class _ForwardIterator, | ||
| 190 | class _ForwardOutIterator, | ||
| 191 | class _Tp, | ||
| 192 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 193 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 194 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy( | ||
| 195 | _ExecutionPolicy&& __policy, | ||
| 196 | _ForwardIterator&& __first, | ||
| 197 | _ForwardIterator&& __last, | ||
| 198 | _ForwardOutIterator&& __result, | ||
| 199 | const _Tp& __old_value, | ||
| 200 | const _Tp& __new_value) noexcept { | ||
| 201 | return std::__pstl_frontend_dispatch( | ||
| 202 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy, _RawPolicy), | ||
| 203 | [&__policy](_ForwardIterator __g_first, | ||
| 204 | _ForwardIterator __g_last, | ||
| 205 | _ForwardOutIterator __g_result, | ||
| 206 | const _Tp& __g_old_value, | ||
| 207 | const _Tp& __g_new_value) { | ||
| 208 | return std::__replace_copy_if( | ||
| 209 | __policy, | ||
| 210 | std::move(__g_first), | ||
| 211 | std::move(__g_last), | ||
| 212 | std::move(__g_result), | ||
| 213 | [&](__iter_reference<_ForwardIterator> __element) { return __element == __g_old_value; }, | ||
| 214 | __g_new_value); | ||
| 215 | }, | ||
| 216 | std::move(__first), | ||
| 217 | std::move(__last), | ||
| 218 | std::move(__result), | ||
| 219 | __old_value, | ||
| 220 | __new_value); | ||
| 221 | } | ||
| 222 | |||
| 223 | template <class _ExecutionPolicy, | ||
| 224 | class _ForwardIterator, | ||
| 225 | class _ForwardOutIterator, | ||
| 226 | class _Tp, | ||
| 227 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 228 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 229 | _LIBCPP_HIDE_FROM_ABI void replace_copy( | ||
| 230 | _ExecutionPolicy&& __policy, | ||
| 231 | _ForwardIterator __first, | ||
| 232 | _ForwardIterator __last, | ||
| 233 | _ForwardOutIterator __result, | ||
| 234 | const _Tp& __old_value, | ||
| 235 | const _Tp& __new_value) { | ||
| 236 | if (!std::__replace_copy( | ||
| 237 | __policy, std::move(__first), std::move(__last), std::move(__result), __old_value, __new_value)) | ||
| 238 | std::__throw_bad_alloc(); | ||
| 239 | } | ||
| 240 | |||
| 241 | _LIBCPP_END_NAMESPACE_STD | ||
| 242 | |||
| 243 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 244 | |||
| 245 | _LIBCPP_POP_MACROS | ||
| 246 | |||
| 247 | #endif // _LIBCPP___ALGORITHM_PSTL_REPLACE_H | ||
lib/libcxx/include/__algorithm/pstl_rotate_copy.h deleted-85| ... | @@ -1,85 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__algorithm/pstl_copy.h> | ||
| 14 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 15 | #include <__type_traits/is_execution_policy.h> | ||
| 16 | #include <optional> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_PUSH_MACROS | ||
| 23 | #include <__undef_macros> | ||
| 24 | |||
| 25 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 26 | |||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 28 | |||
| 29 | template <class> | ||
| 30 | void __pstl_rotate_copy(); | ||
| 31 | |||
| 32 | template <class _ExecutionPolicy, | ||
| 33 | class _ForwardIterator, | ||
| 34 | class _ForwardOutIterator, | ||
| 35 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 36 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 38 | __rotate_copy(_ExecutionPolicy&& __policy, | ||
| 39 | _ForwardIterator&& __first, | ||
| 40 | _ForwardIterator&& __middle, | ||
| 41 | _ForwardIterator&& __last, | ||
| 42 | _ForwardOutIterator&& __result) noexcept { | ||
| 43 | return std::__pstl_frontend_dispatch( | ||
| 44 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_rotate_copy, _RawPolicy), | ||
| 45 | [&__policy](_ForwardIterator __g_first, | ||
| 46 | _ForwardIterator __g_middle, | ||
| 47 | _ForwardIterator __g_last, | ||
| 48 | _ForwardOutIterator __g_result) -> optional<_ForwardOutIterator> { | ||
| 49 | auto __result_mid = | ||
| 50 | std::__copy(__policy, _ForwardIterator(__g_middle), std::move(__g_last), std::move(__g_result)); | ||
| 51 | if (!__result_mid) | ||
| 52 | return nullopt; | ||
| 53 | return std::__copy(__policy, std::move(__g_first), std::move(__g_middle), *std::move(__result_mid)); | ||
| 54 | }, | ||
| 55 | std::move(__first), | ||
| 56 | std::move(__middle), | ||
| 57 | std::move(__last), | ||
| 58 | std::move(__result)); | ||
| 59 | } | ||
| 60 | |||
| 61 | template <class _ExecutionPolicy, | ||
| 62 | class _ForwardIterator, | ||
| 63 | class _ForwardOutIterator, | ||
| 64 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 65 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 66 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator rotate_copy( | ||
| 67 | _ExecutionPolicy&& __policy, | ||
| 68 | _ForwardIterator __first, | ||
| 69 | _ForwardIterator __middle, | ||
| 70 | _ForwardIterator __last, | ||
| 71 | _ForwardOutIterator __result) { | ||
| 72 | auto __res = | ||
| 73 | std::__rotate_copy(__policy, std::move(__first), std::move(__middle), std::move(__last), std::move(__result)); | ||
| 74 | if (!__res) | ||
| 75 | std::__throw_bad_alloc(); | ||
| 76 | return *__res; | ||
| 77 | } | ||
| 78 | |||
| 79 | _LIBCPP_END_NAMESPACE_STD | ||
| 80 | |||
| 81 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 82 | |||
| 83 | _LIBCPP_POP_MACROS | ||
| 84 | |||
| 85 | #endif // _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H | ||
lib/libcxx/include/__algorithm/pstl_sort.h deleted-82| ... | @@ -1,82 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_SORT_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_SORT_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 14 | #include <__algorithm/pstl_stable_sort.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__functional/operations.h> | ||
| 17 | #include <__type_traits/is_execution_policy.h> | ||
| 18 | #include <__type_traits/remove_cvref.h> | ||
| 19 | #include <__utility/empty.h> | ||
| 20 | #include <__utility/forward.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | #include <optional> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 31 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | |||
| 35 | template <class> | ||
| 36 | void __pstl_sort(); | ||
| 37 | |||
| 38 | template <class _ExecutionPolicy, | ||
| 39 | class _RandomAccessIterator, | ||
| 40 | class _Comp, | ||
| 41 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 42 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __sort( | ||
| 44 | _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) noexcept { | ||
| 45 | return std::__pstl_frontend_dispatch( | ||
| 46 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_sort, _RawPolicy), | ||
| 47 | [&__policy](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) { | ||
| 48 | std::stable_sort(__policy, std::move(__g_first), std::move(__g_last), std::move(__g_comp)); | ||
| 49 | return optional<__empty>{__empty{}}; | ||
| 50 | }, | ||
| 51 | std::move(__first), | ||
| 52 | std::move(__last), | ||
| 53 | std::move(__comp)); | ||
| 54 | } | ||
| 55 | |||
| 56 | template <class _ExecutionPolicy, | ||
| 57 | class _RandomAccessIterator, | ||
| 58 | class _Comp, | ||
| 59 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 60 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI void | ||
| 62 | sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { | ||
| 63 | if (!std::__sort(__policy, std::move(__first), std::move(__last), std::move(__comp))) | ||
| 64 | std::__throw_bad_alloc(); | ||
| 65 | } | ||
| 66 | |||
| 67 | template <class _ExecutionPolicy, | ||
| 68 | class _RandomAccessIterator, | ||
| 69 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 70 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 71 | _LIBCPP_HIDE_FROM_ABI void | ||
| 72 | sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) { | ||
| 73 | std::sort(std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{}); | ||
| 74 | } | ||
| 75 | |||
| 76 | _LIBCPP_END_NAMESPACE_STD | ||
| 77 | |||
| 78 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 79 | |||
| 80 | _LIBCPP_POP_MACROS | ||
| 81 | |||
| 82 | #endif // _LIBCPP___ALGORITHM_PSTL_SORT_H | ||
lib/libcxx/include/__algorithm/pstl_stable_sort.h deleted-61| ... | @@ -1,61 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_STABLE_SORT_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_STABLE_SORT_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__functional/operations.h> | ||
| 15 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__type_traits/remove_cvref.h> | ||
| 18 | #include <__utility/empty.h> | ||
| 19 | #include <__utility/move.h> | ||
| 20 | #include <optional> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | #include <__undef_macros> | ||
| 28 | |||
| 29 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | template <class _ExecutionPolicy, | ||
| 34 | class _RandomAccessIterator, | ||
| 35 | class _Comp = less<>, | ||
| 36 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 37 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __stable_sort( | ||
| 39 | _ExecutionPolicy&&, _RandomAccessIterator&& __first, _RandomAccessIterator&& __last, _Comp&& __comp = {}) noexcept { | ||
| 40 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 41 | return std::__pstl_stable_sort<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__comp)); | ||
| 42 | } | ||
| 43 | |||
| 44 | template <class _ExecutionPolicy, | ||
| 45 | class _RandomAccessIterator, | ||
| 46 | class _Comp = less<>, | ||
| 47 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 48 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 49 | _LIBCPP_HIDE_FROM_ABI void stable_sort( | ||
| 50 | _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp = {}) { | ||
| 51 | if (!std::__stable_sort(__policy, std::move(__first), std::move(__last), std::move(__comp))) | ||
| 52 | std::__throw_bad_alloc(); | ||
| 53 | } | ||
| 54 | |||
| 55 | _LIBCPP_END_NAMESPACE_STD | ||
| 56 | |||
| 57 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 58 | |||
| 59 | _LIBCPP_POP_MACROS | ||
| 60 | |||
| 61 | #endif // _LIBCPP___ALGORITHM_PSTL_STABLE_SORT_H | ||
lib/libcxx/include/__algorithm/pstl_transform.h deleted-120| ... | @@ -1,120 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_PSTL_TRANSFORM_H | ||
| 10 | #define _LIBCPP___ALGORITHM_PSTL_TRANSFORM_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__iterator/cpp17_iterator_concepts.h> | ||
| 15 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__type_traits/remove_cvref.h> | ||
| 18 | #include <__utility/move.h> | ||
| 19 | #include <optional> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | #include <__undef_macros> | ||
| 27 | |||
| 28 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | template <class _ExecutionPolicy, | ||
| 33 | class _ForwardIterator, | ||
| 34 | class _ForwardOutIterator, | ||
| 35 | class _UnaryOperation, | ||
| 36 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 37 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>> | ||
| 39 | __transform(_ExecutionPolicy&&, | ||
| 40 | _ForwardIterator&& __first, | ||
| 41 | _ForwardIterator&& __last, | ||
| 42 | _ForwardOutIterator&& __result, | ||
| 43 | _UnaryOperation&& __op) noexcept { | ||
| 44 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 45 | return std::__pstl_transform<_RawPolicy>( | ||
| 46 | _Backend{}, std::move(__first), std::move(__last), std::move(__result), std::move(__op)); | ||
| 47 | } | ||
| 48 | |||
| 49 | template <class _ExecutionPolicy, | ||
| 50 | class _ForwardIterator, | ||
| 51 | class _ForwardOutIterator, | ||
| 52 | class _UnaryOperation, | ||
| 53 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 54 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( | ||
| 56 | _ExecutionPolicy&& __policy, | ||
| 57 | _ForwardIterator __first, | ||
| 58 | _ForwardIterator __last, | ||
| 59 | _ForwardOutIterator __result, | ||
| 60 | _UnaryOperation __op) { | ||
| 61 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); | ||
| 62 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator); | ||
| 63 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first))); | ||
| 64 | auto __res = std::__transform(__policy, std::move(__first), std::move(__last), std::move(__result), std::move(__op)); | ||
| 65 | if (!__res) | ||
| 66 | std::__throw_bad_alloc(); | ||
| 67 | return *std::move(__res); | ||
| 68 | } | ||
| 69 | |||
| 70 | template <class _ExecutionPolicy, | ||
| 71 | class _ForwardIterator1, | ||
| 72 | class _ForwardIterator2, | ||
| 73 | class _ForwardOutIterator, | ||
| 74 | class _BinaryOperation, | ||
| 75 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 76 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 77 | _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>> | ||
| 78 | __transform(_ExecutionPolicy&&, | ||
| 79 | _ForwardIterator1&& __first1, | ||
| 80 | _ForwardIterator1&& __last1, | ||
| 81 | _ForwardIterator2&& __first2, | ||
| 82 | _ForwardOutIterator&& __result, | ||
| 83 | _BinaryOperation&& __op) noexcept { | ||
| 84 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 85 | return std::__pstl_transform<_RawPolicy>( | ||
| 86 | _Backend{}, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op)); | ||
| 87 | } | ||
| 88 | |||
| 89 | template <class _ExecutionPolicy, | ||
| 90 | class _ForwardIterator1, | ||
| 91 | class _ForwardIterator2, | ||
| 92 | class _ForwardOutIterator, | ||
| 93 | class _BinaryOperation, | ||
| 94 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 95 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 96 | _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( | ||
| 97 | _ExecutionPolicy&& __policy, | ||
| 98 | _ForwardIterator1 __first1, | ||
| 99 | _ForwardIterator1 __last1, | ||
| 100 | _ForwardIterator2 __first2, | ||
| 101 | _ForwardOutIterator __result, | ||
| 102 | _BinaryOperation __op) { | ||
| 103 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1); | ||
| 104 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2); | ||
| 105 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator); | ||
| 106 | _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first1, *__first2))); | ||
| 107 | auto __res = std::__transform( | ||
| 108 | __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op)); | ||
| 109 | if (!__res) | ||
| 110 | std::__throw_bad_alloc(); | ||
| 111 | return *std::move(__res); | ||
| 112 | } | ||
| 113 | |||
| 114 | _LIBCPP_END_NAMESPACE_STD | ||
| 115 | |||
| 116 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 117 | |||
| 118 | _LIBCPP_POP_MACROS | ||
| 119 | |||
| 120 | #endif // _LIBCPP___ALGORITHM_PSTL_TRANSFORM_H | ||
lib/libcxx/include/__algorithm/push_heap.h+2-2| ... | @@ -14,8 +14,8 @@ | ... | @@ -14,8 +14,8 @@ |
| 14 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__type_traits/is_copy_assignable.h> | 17 | #include <__type_traits/is_assignable.h> |
| 18 | #include <__type_traits/is_copy_constructible.h> | 18 | #include <__type_traits/is_constructible.h> |
| 19 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| 20 | 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__algorithm/ranges_adjacent_find.h+2-2| ... | @@ -53,7 +53,7 @@ struct __fn { | ... | @@ -53,7 +53,7 @@ struct __fn { |
| 53 | sentinel_for<_Iter> _Sent, | 53 | sentinel_for<_Iter> _Sent, |
| 54 | class _Proj = identity, | 54 | class _Proj = identity, |
| 55 | indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to> | 55 | indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to> |
| 56 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter | 56 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 57 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { | 57 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { |
| 58 | return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj); | 58 | return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 59 | } | 59 | } |
| ... | @@ -62,7 +62,7 @@ struct __fn { | ... | @@ -62,7 +62,7 @@ struct __fn { |
| 62 | class _Proj = identity, | 62 | class _Proj = identity, |
| 63 | indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>, projected<iterator_t<_Range>, _Proj>> | 63 | indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>, projected<iterator_t<_Range>, _Proj>> |
| 64 | _Pred = ranges::equal_to> | 64 | _Pred = ranges::equal_to> |
| 65 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> |
| 66 | operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const { | 66 | operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const { |
| 67 | return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 67 | return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 68 | } | 68 | } |
lib/libcxx/include/__algorithm/ranges_all_of.h+2-2| ... | @@ -45,7 +45,7 @@ struct __fn { | ... | @@ -45,7 +45,7 @@ struct __fn { |
| 45 | sentinel_for<_Iter> _Sent, | 45 | sentinel_for<_Iter> _Sent, |
| 46 | class _Proj = identity, | 46 | class _Proj = identity, |
| 47 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | 47 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 48 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 49 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | 49 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { |
| 50 | return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj); | 50 | return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 51 | } | 51 | } |
| ... | @@ -53,7 +53,7 @@ struct __fn { | ... | @@ -53,7 +53,7 @@ struct __fn { |
| 53 | template <input_range _Range, | 53 | template <input_range _Range, |
| 54 | class _Proj = identity, | 54 | class _Proj = identity, |
| 55 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 55 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 56 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 56 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 57 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | 57 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 58 | return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 58 | return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 59 | } | 59 | } |
lib/libcxx/include/__algorithm/ranges_any_of.h+2-2| ... | @@ -45,7 +45,7 @@ struct __fn { | ... | @@ -45,7 +45,7 @@ struct __fn { |
| 45 | sentinel_for<_Iter> _Sent, | 45 | sentinel_for<_Iter> _Sent, |
| 46 | class _Proj = identity, | 46 | class _Proj = identity, |
| 47 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | 47 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 48 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 49 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { | 49 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { |
| 50 | return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj); | 50 | return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 51 | } | 51 | } |
| ... | @@ -53,7 +53,7 @@ struct __fn { | ... | @@ -53,7 +53,7 @@ struct __fn { |
| 53 | template <input_range _Range, | 53 | template <input_range _Range, |
| 54 | class _Proj = identity, | 54 | class _Proj = identity, |
| 55 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 55 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 56 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 56 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 57 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | 57 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 58 | return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 58 | return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 59 | } | 59 | } |
lib/libcxx/include/__algorithm/ranges_binary_search.h+2-2| ... | @@ -39,7 +39,7 @@ struct __fn { | ... | @@ -39,7 +39,7 @@ struct __fn { |
| 39 | class _Type, | 39 | class _Type, |
| 40 | class _Proj = identity, | 40 | class _Proj = identity, |
| 41 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> | 41 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> |
| 42 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 42 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 43 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 43 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 44 | auto __ret = std::__lower_bound<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); | 44 | auto __ret = std::__lower_bound<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); |
| 45 | return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret)); | 45 | return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret)); |
| ... | @@ -49,7 +49,7 @@ struct __fn { | ... | @@ -49,7 +49,7 @@ struct __fn { |
| 49 | class _Type, | 49 | class _Type, |
| 50 | class _Proj = identity, | 50 | class _Proj = identity, |
| 51 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 51 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 52 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 53 | operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 53 | operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 54 | auto __first = ranges::begin(__r); | 54 | auto __first = ranges::begin(__r); |
| 55 | auto __last = ranges::end(__r); | 55 | auto __last = ranges::end(__r); |
lib/libcxx/include/__algorithm/ranges_clamp.h+1-1| ... | @@ -35,7 +35,7 @@ struct __fn { | ... | @@ -35,7 +35,7 @@ struct __fn { |
| 35 | template <class _Type, | 35 | template <class _Type, |
| 36 | class _Proj = identity, | 36 | class _Proj = identity, |
| 37 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> | 37 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> |
| 38 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Type& operator()( | 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Type& operator()( |
| 39 | const _Type& __value, const _Type& __low, const _Type& __high, _Comp __comp = {}, _Proj __proj = {}) const { | 39 | const _Type& __value, const _Type& __low, const _Type& __high, _Comp __comp = {}, _Proj __proj = {}) const { |
| 40 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 40 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 41 | !bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))), | 41 | !bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))), |
lib/libcxx/include/__algorithm/ranges_contains.h+2-2| ... | @@ -37,14 +37,14 @@ namespace __contains { | ... | @@ -37,14 +37,14 @@ namespace __contains { |
| 37 | struct __fn { | 37 | struct __fn { |
| 38 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> | 38 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> |
| 39 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> | 39 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> |
| 40 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool static | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static |
| 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) { | 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) { |
| 42 | return ranges::find(std::move(__first), __last, __value, std::ref(__proj)) != __last; | 42 | return ranges::find(std::move(__first), __last, __value, std::ref(__proj)) != __last; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | template <input_range _Range, class _Type, class _Proj = identity> | 45 | template <input_range _Range, class _Type, class _Proj = identity> |
| 46 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | 46 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> |
| 47 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool static | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static |
| 48 | operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) { | 48 | operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) { |
| 49 | return ranges::find(ranges::begin(__range), ranges::end(__range), __value, std::ref(__proj)) != | 49 | return ranges::find(ranges::begin(__range), ranges::end(__range), __value, std::ref(__proj)) != |
| 50 | ranges::end(__range); | 50 | ranges::end(__range); |
lib/libcxx/include/__algorithm/ranges_contains_subrange.h created+97| ... | @@ -0,0 +1,97 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H | ||
| 11 | |||
| 12 | #include <__algorithm/ranges_search.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__functional/identity.h> | ||
| 15 | #include <__functional/ranges_operations.h> | ||
| 16 | #include <__functional/reference_wrapper.h> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__iterator/indirectly_comparable.h> | ||
| 19 | #include <__iterator/projected.h> | ||
| 20 | #include <__ranges/access.h> | ||
| 21 | #include <__ranges/concepts.h> | ||
| 22 | #include <__ranges/size.h> | ||
| 23 | #include <__ranges/subrange.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_PUSH_MACROS | ||
| 31 | #include <__undef_macros> | ||
| 32 | |||
| 33 | #if _LIBCPP_STD_VER >= 23 | ||
| 34 | |||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 36 | |||
| 37 | namespace ranges { | ||
| 38 | namespace __contains_subrange { | ||
| 39 | struct __fn { | ||
| 40 | template <forward_iterator _Iter1, | ||
| 41 | sentinel_for<_Iter1> _Sent1, | ||
| 42 | forward_iterator _Iter2, | ||
| 43 | sentinel_for<_Iter2> _Sent2, | ||
| 44 | class _Pred = ranges::equal_to, | ||
| 45 | class _Proj1 = identity, | ||
| 46 | class _Proj2 = identity> | ||
| 47 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | ||
| 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static operator()( | ||
| 49 | _Iter1 __first1, | ||
| 50 | _Sent1 __last1, | ||
| 51 | _Iter2 __first2, | ||
| 52 | _Sent2 __last2, | ||
| 53 | _Pred __pred = {}, | ||
| 54 | _Proj1 __proj1 = {}, | ||
| 55 | _Proj2 __proj2 = {}) { | ||
| 56 | if (__first2 == __last2) | ||
| 57 | return true; | ||
| 58 | |||
| 59 | auto __ret = ranges::search( | ||
| 60 | std::move(__first1), __last1, std::move(__first2), __last2, __pred, std::ref(__proj1), std::ref(__proj2)); | ||
| 61 | return __ret.empty() == false; | ||
| 62 | } | ||
| 63 | |||
| 64 | template <forward_range _Range1, | ||
| 65 | forward_range _Range2, | ||
| 66 | class _Pred = ranges::equal_to, | ||
| 67 | class _Proj1 = identity, | ||
| 68 | class _Proj2 = identity> | ||
| 69 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | ||
| 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static | ||
| 71 | operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { | ||
| 72 | if constexpr (sized_range<_Range2>) { | ||
| 73 | if (ranges::size(__range2) == 0) | ||
| 74 | return true; | ||
| 75 | } else { | ||
| 76 | if (ranges::begin(__range2) == ranges::end(__range2)) | ||
| 77 | return true; | ||
| 78 | } | ||
| 79 | |||
| 80 | auto __ret = ranges::search(__range1, __range2, __pred, std::ref(__proj1), std::ref(__proj2)); | ||
| 81 | return __ret.empty() == false; | ||
| 82 | } | ||
| 83 | }; | ||
| 84 | } // namespace __contains_subrange | ||
| 85 | |||
| 86 | inline namespace __cpo { | ||
| 87 | inline constexpr auto contains_subrange = __contains_subrange::__fn{}; | ||
| 88 | } // namespace __cpo | ||
| 89 | } // namespace ranges | ||
| 90 | |||
| 91 | _LIBCPP_END_NAMESPACE_STD | ||
| 92 | |||
| 93 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 94 | |||
| 95 | _LIBCPP_POP_MACROS | ||
| 96 | |||
| 97 | #endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H | ||
lib/libcxx/include/__algorithm/ranges_count.h+2-2| ... | @@ -38,14 +38,14 @@ namespace __count { | ... | @@ -38,14 +38,14 @@ namespace __count { |
| 38 | struct __fn { | 38 | struct __fn { |
| 39 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> | 39 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> |
| 40 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> | 40 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> |
| 41 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> | 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> |
| 42 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { | 42 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { |
| 43 | return std::__count<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __proj); | 43 | return std::__count<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __proj); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <input_range _Range, class _Type, class _Proj = identity> | 46 | template <input_range _Range, class _Type, class _Proj = identity> |
| 47 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | 47 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> |
| 48 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> |
| 49 | operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const { | 49 | operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const { |
| 50 | return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj); | 50 | return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj); |
| 51 | } | 51 | } |
lib/libcxx/include/__algorithm/ranges_count_if.h+2-2| ... | @@ -50,7 +50,7 @@ struct __fn { | ... | @@ -50,7 +50,7 @@ struct __fn { |
| 50 | sentinel_for<_Iter> _Sent, | 50 | sentinel_for<_Iter> _Sent, |
| 51 | class _Proj = identity, | 51 | class _Proj = identity, |
| 52 | indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate> | 52 | indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate> |
| 53 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> | 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> |
| 54 | operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const { | 54 | operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const { |
| 55 | return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); | 55 | return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 56 | } | 56 | } |
| ... | @@ -58,7 +58,7 @@ struct __fn { | ... | @@ -58,7 +58,7 @@ struct __fn { |
| 58 | template <input_range _Range, | 58 | template <input_range _Range, |
| 59 | class _Proj = identity, | 59 | class _Proj = identity, |
| 60 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate> | 60 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate> |
| 61 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> | 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> |
| 62 | operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const { | 62 | operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const { |
| 63 | return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | 63 | return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); |
| 64 | } | 64 | } |
lib/libcxx/include/__algorithm/ranges_ends_with.h+5-5| ... | @@ -39,7 +39,7 @@ namespace ranges { | ... | @@ -39,7 +39,7 @@ namespace ranges { |
| 39 | namespace __ends_with { | 39 | namespace __ends_with { |
| 40 | struct __fn { | 40 | struct __fn { |
| 41 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | 41 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 42 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_bidirectional( | 42 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional( |
| 43 | _Iter1 __first1, | 43 | _Iter1 __first1, |
| 44 | _Sent1 __last1, | 44 | _Sent1 __last1, |
| 45 | _Iter2 __first2, | 45 | _Iter2 __first2, |
| ... | @@ -56,7 +56,7 @@ struct __fn { | ... | @@ -56,7 +56,7 @@ struct __fn { |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | 58 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 59 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl( | 59 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl( |
| 60 | _Iter1 __first1, | 60 | _Iter1 __first1, |
| 61 | _Sent1 __last1, | 61 | _Sent1 __last1, |
| 62 | _Iter2 __first2, | 62 | _Iter2 __first2, |
| ... | @@ -65,7 +65,7 @@ struct __fn { | ... | @@ -65,7 +65,7 @@ struct __fn { |
| 65 | _Proj1& __proj1, | 65 | _Proj1& __proj1, |
| 66 | _Proj2& __proj2) { | 66 | _Proj2& __proj2) { |
| 67 | if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> && | 67 | if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> && |
| 68 | (!std::random_access_iterator<_Sent1>)&&(!std::random_access_iterator<_Sent2>)) { | 68 | (!std::random_access_iterator<_Sent1>) && (!std::random_access_iterator<_Sent2>)) { |
| 69 | return __ends_with_fn_impl_bidirectional(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); | 69 | return __ends_with_fn_impl_bidirectional(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); |
| 70 | 70 | ||
| 71 | } else { | 71 | } else { |
| ... | @@ -133,7 +133,7 @@ struct __fn { | ... | @@ -133,7 +133,7 @@ struct __fn { |
| 133 | requires(forward_iterator<_Iter1> || sized_sentinel_for<_Sent1, _Iter1>) && | 133 | requires(forward_iterator<_Iter1> || sized_sentinel_for<_Sent1, _Iter1>) && |
| 134 | (forward_iterator<_Iter2> || sized_sentinel_for<_Sent2, _Iter2>) && | 134 | (forward_iterator<_Iter2> || sized_sentinel_for<_Sent2, _Iter2>) && |
| 135 | indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | 135 | indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> |
| 136 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 136 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 137 | _Iter1 __first1, | 137 | _Iter1 __first1, |
| 138 | _Sent1 __last1, | 138 | _Sent1 __last1, |
| 139 | _Iter2 __first2, | 139 | _Iter2 __first2, |
| ... | @@ -152,7 +152,7 @@ struct __fn { | ... | @@ -152,7 +152,7 @@ struct __fn { |
| 152 | class _Proj2 = identity> | 152 | class _Proj2 = identity> |
| 153 | requires(forward_range<_Range1> || sized_range<_Range1>) && (forward_range<_Range2> || sized_range<_Range2>) && | 153 | requires(forward_range<_Range1> || sized_range<_Range1>) && (forward_range<_Range2> || sized_range<_Range2>) && |
| 154 | indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 154 | indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 155 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 155 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 156 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 156 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 157 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { | 157 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { |
| 158 | auto __n1 = ranges::size(__range1); | 158 | auto __n1 = ranges::size(__range1); |
lib/libcxx/include/__algorithm/ranges_equal.h+2-2| ... | @@ -44,7 +44,7 @@ struct __fn { | ... | @@ -44,7 +44,7 @@ struct __fn { |
| 44 | class _Proj1 = identity, | 44 | class _Proj1 = identity, |
| 45 | class _Proj2 = identity> | 45 | class _Proj2 = identity> |
| 46 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | 46 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> |
| 47 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 48 | _Iter1 __first1, | 48 | _Iter1 __first1, |
| 49 | _Sent1 __last1, | 49 | _Sent1 __last1, |
| 50 | _Iter2 __first2, | 50 | _Iter2 __first2, |
| ... | @@ -74,7 +74,7 @@ struct __fn { | ... | @@ -74,7 +74,7 @@ struct __fn { |
| 74 | class _Proj1 = identity, | 74 | class _Proj1 = identity, |
| 75 | class _Proj2 = identity> | 75 | class _Proj2 = identity> |
| 76 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 76 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 77 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 77 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 78 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 78 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 79 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { | 79 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { |
| 80 | if (ranges::distance(__range1) != ranges::distance(__range2)) | 80 | if (ranges::distance(__range1) != ranges::distance(__range2)) |
lib/libcxx/include/__algorithm/ranges_equal_range.h+2-2| ... | @@ -46,7 +46,7 @@ struct __fn { | ... | @@ -46,7 +46,7 @@ struct __fn { |
| 46 | class _Tp, | 46 | class _Tp, |
| 47 | class _Proj = identity, | 47 | class _Proj = identity, |
| 48 | indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less> | 48 | indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less> |
| 49 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> |
| 50 | operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 50 | operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 51 | auto __ret = std::__equal_range<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __comp, __proj); | 51 | auto __ret = std::__equal_range<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __comp, __proj); |
| 52 | return {std::move(__ret.first), std::move(__ret.second)}; | 52 | return {std::move(__ret.first), std::move(__ret.second)}; |
| ... | @@ -56,7 +56,7 @@ struct __fn { | ... | @@ -56,7 +56,7 @@ struct __fn { |
| 56 | class _Tp, | 56 | class _Tp, |
| 57 | class _Proj = identity, | 57 | class _Proj = identity, |
| 58 | indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 58 | indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 59 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> |
| 60 | operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 60 | operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 61 | auto __ret = | 61 | auto __ret = |
| 62 | std::__equal_range<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), __value, __comp, __proj); | 62 | std::__equal_range<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), __value, __comp, __proj); |
lib/libcxx/include/__algorithm/ranges_find.h+4-4| ... | @@ -44,22 +44,22 @@ struct __fn { | ... | @@ -44,22 +44,22 @@ struct __fn { |
| 44 | if constexpr (forward_iterator<_Iter>) { | 44 | if constexpr (forward_iterator<_Iter>) { |
| 45 | auto [__first_un, __last_un] = std::__unwrap_range(__first, std::move(__last)); | 45 | auto [__first_un, __last_un] = std::__unwrap_range(__first, std::move(__last)); |
| 46 | return std::__rewrap_range<_Sent>( | 46 | return std::__rewrap_range<_Sent>( |
| 47 | std::move(__first), std::__find_impl(std::move(__first_un), std::move(__last_un), __value, __proj)); | 47 | std::move(__first), std::__find(std::move(__first_un), std::move(__last_un), __value, __proj)); |
| 48 | } else { | 48 | } else { |
| 49 | return std::__find_impl(std::move(__first), std::move(__last), __value, __proj); | 49 | return std::__find(std::move(__first), std::move(__last), __value, __proj); |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity> | 53 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity> |
| 54 | requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*> | 54 | requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*> |
| 55 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 56 | operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const { | 56 | operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const { |
| 57 | return __find_unwrap(std::move(__first), std::move(__last), __value, __proj); | 57 | return __find_unwrap(std::move(__first), std::move(__last), __value, __proj); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | template <input_range _Rp, class _Tp, class _Proj = identity> | 60 | template <input_range _Rp, class _Tp, class _Proj = identity> |
| 61 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*> | 61 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*> |
| 62 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 63 | operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const { | 63 | operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const { |
| 64 | return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj); | 64 | return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj); |
| 65 | } | 65 | } |
lib/libcxx/include/__algorithm/ranges_find_end.h+2-2| ... | @@ -45,7 +45,7 @@ struct __fn { | ... | @@ -45,7 +45,7 @@ struct __fn { |
| 45 | class _Proj1 = identity, | 45 | class _Proj1 = identity, |
| 46 | class _Proj2 = identity> | 46 | class _Proj2 = identity> |
| 47 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | 47 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> |
| 48 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()( | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()( |
| 49 | _Iter1 __first1, | 49 | _Iter1 __first1, |
| 50 | _Sent1 __last1, | 50 | _Sent1 __last1, |
| 51 | _Iter2 __first2, | 51 | _Iter2 __first2, |
| ... | @@ -72,7 +72,7 @@ struct __fn { | ... | @@ -72,7 +72,7 @@ struct __fn { |
| 72 | class _Proj1 = identity, | 72 | class _Proj1 = identity, |
| 73 | class _Proj2 = identity> | 73 | class _Proj2 = identity> |
| 74 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 74 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 75 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()( | 75 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()( |
| 76 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 76 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 77 | auto __ret = std::__find_end_impl<_RangeAlgPolicy>( | 77 | auto __ret = std::__find_end_impl<_RangeAlgPolicy>( |
| 78 | ranges::begin(__range1), | 78 | ranges::begin(__range1), |
lib/libcxx/include/__algorithm/ranges_find_first_of.h+2-2| ... | @@ -60,7 +60,7 @@ struct __fn { | ... | @@ -60,7 +60,7 @@ struct __fn { |
| 60 | class _Proj1 = identity, | 60 | class _Proj1 = identity, |
| 61 | class _Proj2 = identity> | 61 | class _Proj2 = identity> |
| 62 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | 62 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> |
| 63 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter1 operator()( | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter1 operator()( |
| 64 | _Iter1 __first1, | 64 | _Iter1 __first1, |
| 65 | _Sent1 __last1, | 65 | _Sent1 __last1, |
| 66 | _Iter2 __first2, | 66 | _Iter2 __first2, |
| ... | @@ -78,7 +78,7 @@ struct __fn { | ... | @@ -78,7 +78,7 @@ struct __fn { |
| 78 | class _Proj1 = identity, | 78 | class _Proj1 = identity, |
| 79 | class _Proj2 = identity> | 79 | class _Proj2 = identity> |
| 80 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 80 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 81 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range1> operator()( | 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range1> operator()( |
| 82 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 82 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 83 | return __find_first_of_impl( | 83 | return __find_first_of_impl( |
| 84 | ranges::begin(__range1), | 84 | ranges::begin(__range1), |
lib/libcxx/include/__algorithm/ranges_find_if.h+2-2| ... | @@ -48,13 +48,13 @@ struct __fn { | ... | @@ -48,13 +48,13 @@ struct __fn { |
| 48 | sentinel_for<_Ip> _Sp, | 48 | sentinel_for<_Ip> _Sp, |
| 49 | class _Proj = identity, | 49 | class _Proj = identity, |
| 50 | indirect_unary_predicate<projected<_Ip, _Proj>> _Pred> | 50 | indirect_unary_predicate<projected<_Ip, _Proj>> _Pred> |
| 51 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 51 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 52 | operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { | 52 | operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { |
| 53 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj); | 53 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred> | 56 | template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred> |
| 57 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 58 | operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { | 58 | operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { |
| 59 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | 59 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); |
| 60 | } | 60 | } |
lib/libcxx/include/__algorithm/ranges_find_if_not.h+2-2| ... | @@ -40,14 +40,14 @@ struct __fn { | ... | @@ -40,14 +40,14 @@ struct __fn { |
| 40 | sentinel_for<_Ip> _Sp, | 40 | sentinel_for<_Ip> _Sp, |
| 41 | class _Proj = identity, | 41 | class _Proj = identity, |
| 42 | indirect_unary_predicate<projected<_Ip, _Proj>> _Pred> | 42 | indirect_unary_predicate<projected<_Ip, _Proj>> _Pred> |
| 43 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 44 | operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { | 44 | operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { |
| 45 | auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); }; | 45 | auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); }; |
| 46 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj); | 46 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred> | 49 | template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred> |
| 50 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 51 | operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { | 51 | operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { |
| 52 | auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); }; | 52 | auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); }; |
| 53 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); | 53 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); |
lib/libcxx/include/__algorithm/ranges_find_last.h created+175| ... | @@ -0,0 +1,175 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__functional/identity.h> | ||
| 14 | #include <__functional/invoke.h> | ||
| 15 | #include <__functional/ranges_operations.h> | ||
| 16 | #include <__iterator/concepts.h> | ||
| 17 | #include <__iterator/indirectly_comparable.h> | ||
| 18 | #include <__iterator/next.h> | ||
| 19 | #include <__iterator/prev.h> | ||
| 20 | #include <__iterator/projected.h> | ||
| 21 | #include <__ranges/access.h> | ||
| 22 | #include <__ranges/concepts.h> | ||
| 23 | #include <__ranges/subrange.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_PUSH_MACROS | ||
| 31 | #include <__undef_macros> | ||
| 32 | |||
| 33 | #if _LIBCPP_STD_VER >= 23 | ||
| 34 | |||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 36 | |||
| 37 | namespace ranges { | ||
| 38 | |||
| 39 | template <class _Iter, class _Sent, class _Pred, class _Proj> | ||
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | ||
| 41 | __find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) { | ||
| 42 | if (__first == __last) { | ||
| 43 | return subrange<_Iter>(__first, __first); | ||
| 44 | } | ||
| 45 | |||
| 46 | if constexpr (bidirectional_iterator<_Iter>) { | ||
| 47 | auto __last_it = ranges::next(__first, __last); | ||
| 48 | for (auto __it = ranges::prev(__last_it); __it != __first; --__it) { | ||
| 49 | if (__pred(std::invoke(__proj, *__it))) { | ||
| 50 | return subrange<_Iter>(std::move(__it), std::move(__last_it)); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | if (__pred(std::invoke(__proj, *__first))) { | ||
| 54 | return subrange<_Iter>(std::move(__first), std::move(__last_it)); | ||
| 55 | } | ||
| 56 | return subrange<_Iter>(__last_it, __last_it); | ||
| 57 | } else { | ||
| 58 | bool __found = false; | ||
| 59 | _Iter __found_it; | ||
| 60 | for (; __first != __last; ++__first) { | ||
| 61 | if (__pred(std::invoke(__proj, *__first))) { | ||
| 62 | __found = true; | ||
| 63 | __found_it = __first; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | if (__found) { | ||
| 68 | return subrange<_Iter>(std::move(__found_it), std::move(__first)); | ||
| 69 | } else { | ||
| 70 | return subrange<_Iter>(__first, __first); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | namespace __find_last { | ||
| 76 | struct __fn { | ||
| 77 | template <class _Type> | ||
| 78 | struct __op { | ||
| 79 | const _Type& __value; | ||
| 80 | template <class _Elem> | ||
| 81 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const { | ||
| 82 | return std::forward<_Elem>(__elem) == __value; | ||
| 83 | } | ||
| 84 | }; | ||
| 85 | |||
| 86 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> | ||
| 87 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> | ||
| 88 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> | ||
| 89 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) { | ||
| 90 | return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Type>{__value}, __proj); | ||
| 91 | } | ||
| 92 | |||
| 93 | template <forward_range _Range, class _Type, class _Proj = identity> | ||
| 94 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | ||
| 95 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range> | ||
| 96 | operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) { | ||
| 97 | return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj); | ||
| 98 | } | ||
| 99 | }; | ||
| 100 | } // namespace __find_last | ||
| 101 | |||
| 102 | namespace __find_last_if { | ||
| 103 | struct __fn { | ||
| 104 | template <class _Pred> | ||
| 105 | struct __op { | ||
| 106 | _Pred& __pred; | ||
| 107 | template <class _Elem> | ||
| 108 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const { | ||
| 109 | return std::invoke(__pred, std::forward<_Elem>(__elem)); | ||
| 110 | } | ||
| 111 | }; | ||
| 112 | |||
| 113 | template <forward_iterator _Iter, | ||
| 114 | sentinel_for<_Iter> _Sent, | ||
| 115 | class _Proj = identity, | ||
| 116 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | ||
| 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> | ||
| 118 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) { | ||
| 119 | return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Pred>{__pred}, __proj); | ||
| 120 | } | ||
| 121 | |||
| 122 | template <forward_range _Range, | ||
| 123 | class _Proj = identity, | ||
| 124 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | ||
| 125 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range> | ||
| 126 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) { | ||
| 127 | return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); | ||
| 128 | } | ||
| 129 | }; | ||
| 130 | } // namespace __find_last_if | ||
| 131 | |||
| 132 | namespace __find_last_if_not { | ||
| 133 | struct __fn { | ||
| 134 | template <class _Pred> | ||
| 135 | struct __op { | ||
| 136 | _Pred& __pred; | ||
| 137 | template <class _Elem> | ||
| 138 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const { | ||
| 139 | return !std::invoke(__pred, std::forward<_Elem>(__elem)); | ||
| 140 | } | ||
| 141 | }; | ||
| 142 | |||
| 143 | template <forward_iterator _Iter, | ||
| 144 | sentinel_for<_Iter> _Sent, | ||
| 145 | class _Proj = identity, | ||
| 146 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | ||
| 147 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> | ||
| 148 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) { | ||
| 149 | return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Pred>{__pred}, __proj); | ||
| 150 | } | ||
| 151 | |||
| 152 | template <forward_range _Range, | ||
| 153 | class _Proj = identity, | ||
| 154 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | ||
| 155 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range> | ||
| 156 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) { | ||
| 157 | return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); | ||
| 158 | } | ||
| 159 | }; | ||
| 160 | } // namespace __find_last_if_not | ||
| 161 | |||
| 162 | inline namespace __cpo { | ||
| 163 | inline constexpr auto find_last = __find_last::__fn{}; | ||
| 164 | inline constexpr auto find_last_if = __find_last_if::__fn{}; | ||
| 165 | inline constexpr auto find_last_if_not = __find_last_if_not::__fn{}; | ||
| 166 | } // namespace __cpo | ||
| 167 | } // namespace ranges | ||
| 168 | |||
| 169 | _LIBCPP_END_NAMESPACE_STD | ||
| 170 | |||
| 171 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 172 | |||
| 173 | _LIBCPP_POP_MACROS | ||
| 174 | |||
| 175 | #endif // _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H | ||
lib/libcxx/include/__algorithm/ranges_includes.h+2-2| ... | @@ -45,7 +45,7 @@ struct __fn { | ... | @@ -45,7 +45,7 @@ struct __fn { |
| 45 | class _Proj1 = identity, | 45 | class _Proj1 = identity, |
| 46 | class _Proj2 = identity, | 46 | class _Proj2 = identity, |
| 47 | indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less> | 47 | indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less> |
| 48 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 49 | _Iter1 __first1, | 49 | _Iter1 __first1, |
| 50 | _Sent1 __last1, | 50 | _Sent1 __last1, |
| 51 | _Iter2 __first2, | 51 | _Iter2 __first2, |
| ... | @@ -69,7 +69,7 @@ struct __fn { | ... | @@ -69,7 +69,7 @@ struct __fn { |
| 69 | class _Proj2 = identity, | 69 | class _Proj2 = identity, |
| 70 | indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> | 70 | indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> |
| 71 | _Comp = ranges::less> | 71 | _Comp = ranges::less> |
| 72 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 72 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 73 | _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 73 | _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 74 | return std::__includes( | 74 | return std::__includes( |
| 75 | ranges::begin(__range1), | 75 | ranges::begin(__range1), |
lib/libcxx/include/__algorithm/ranges_is_heap.h+2-2| ... | @@ -51,7 +51,7 @@ struct __fn { | ... | @@ -51,7 +51,7 @@ struct __fn { |
| 51 | sentinel_for<_Iter> _Sent, | 51 | sentinel_for<_Iter> _Sent, |
| 52 | class _Proj = identity, | 52 | class _Proj = identity, |
| 53 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | 53 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> |
| 54 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 55 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 55 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 56 | return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | 56 | return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); |
| 57 | } | 57 | } |
| ... | @@ -59,7 +59,7 @@ struct __fn { | ... | @@ -59,7 +59,7 @@ struct __fn { |
| 59 | template <random_access_range _Range, | 59 | template <random_access_range _Range, |
| 60 | class _Proj = identity, | 60 | class _Proj = identity, |
| 61 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 61 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 62 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 63 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | 63 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { |
| 64 | return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); | 64 | return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); |
| 65 | } | 65 | } |
lib/libcxx/include/__algorithm/ranges_is_heap_until.h+2-2| ... | @@ -51,7 +51,7 @@ struct __fn { | ... | @@ -51,7 +51,7 @@ struct __fn { |
| 51 | sentinel_for<_Iter> _Sent, | 51 | sentinel_for<_Iter> _Sent, |
| 52 | class _Proj = identity, | 52 | class _Proj = identity, |
| 53 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | 53 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> |
| 54 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 55 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 55 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 56 | return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | 56 | return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj); |
| 57 | } | 57 | } |
| ... | @@ -59,7 +59,7 @@ struct __fn { | ... | @@ -59,7 +59,7 @@ struct __fn { |
| 59 | template <random_access_range _Range, | 59 | template <random_access_range _Range, |
| 60 | class _Proj = identity, | 60 | class _Proj = identity, |
| 61 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 61 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 62 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> |
| 63 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | 63 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { |
| 64 | return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); | 64 | return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); |
| 65 | } | 65 | } |
lib/libcxx/include/__algorithm/ranges_is_partitioned.h+2-2| ... | @@ -57,7 +57,7 @@ struct __fn { | ... | @@ -57,7 +57,7 @@ struct __fn { |
| 57 | sentinel_for<_Iter> _Sent, | 57 | sentinel_for<_Iter> _Sent, |
| 58 | class _Proj = identity, | 58 | class _Proj = identity, |
| 59 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | 59 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 60 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 61 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | 61 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { |
| 62 | return __is_partitioned_impl(std::move(__first), std::move(__last), __pred, __proj); | 62 | return __is_partitioned_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 63 | } | 63 | } |
| ... | @@ -65,7 +65,7 @@ struct __fn { | ... | @@ -65,7 +65,7 @@ struct __fn { |
| 65 | template <input_range _Range, | 65 | template <input_range _Range, |
| 66 | class _Proj = identity, | 66 | class _Proj = identity, |
| 67 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 67 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 68 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 69 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | 69 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 70 | return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 70 | return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 71 | } | 71 | } |
lib/libcxx/include/__algorithm/ranges_is_permutation.h+2-2| ... | @@ -56,7 +56,7 @@ struct __fn { | ... | @@ -56,7 +56,7 @@ struct __fn { |
| 56 | class _Proj1 = identity, | 56 | class _Proj1 = identity, |
| 57 | class _Proj2 = identity, | 57 | class _Proj2 = identity, |
| 58 | indirect_equivalence_relation<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Pred = ranges::equal_to> | 58 | indirect_equivalence_relation<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Pred = ranges::equal_to> |
| 59 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 60 | _Iter1 __first1, | 60 | _Iter1 __first1, |
| 61 | _Sent1 __last1, | 61 | _Sent1 __last1, |
| 62 | _Iter2 __first2, | 62 | _Iter2 __first2, |
| ... | @@ -74,7 +74,7 @@ struct __fn { | ... | @@ -74,7 +74,7 @@ struct __fn { |
| 74 | class _Proj2 = identity, | 74 | class _Proj2 = identity, |
| 75 | indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, | 75 | indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, |
| 76 | projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to> | 76 | projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to> |
| 77 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 77 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 78 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 78 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 79 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { | 79 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { |
| 80 | if (ranges::distance(__range1) != ranges::distance(__range2)) | 80 | if (ranges::distance(__range1) != ranges::distance(__range2)) |
lib/libcxx/include/__algorithm/ranges_is_sorted.h+2-2| ... | @@ -37,7 +37,7 @@ struct __fn { | ... | @@ -37,7 +37,7 @@ struct __fn { |
| 37 | sentinel_for<_Iter> _Sent, | 37 | sentinel_for<_Iter> _Sent, |
| 38 | class _Proj = identity, | 38 | class _Proj = identity, |
| 39 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | 39 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> |
| 40 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 41 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 41 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 42 | return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last; | 42 | return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last; |
| 43 | } | 43 | } |
| ... | @@ -45,7 +45,7 @@ struct __fn { | ... | @@ -45,7 +45,7 @@ struct __fn { |
| 45 | template <forward_range _Range, | 45 | template <forward_range _Range, |
| 46 | class _Proj = identity, | 46 | class _Proj = identity, |
| 47 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 47 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 48 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 49 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | 49 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { |
| 50 | auto __last = ranges::end(__range); | 50 | auto __last = ranges::end(__range); |
| 51 | return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; | 51 | return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; |
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h+2-2| ... | @@ -53,7 +53,7 @@ struct __fn { | ... | @@ -53,7 +53,7 @@ struct __fn { |
| 53 | sentinel_for<_Iter> _Sent, | 53 | sentinel_for<_Iter> _Sent, |
| 54 | class _Proj = identity, | 54 | class _Proj = identity, |
| 55 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | 55 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> |
| 56 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter | 56 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 57 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 57 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 58 | return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj); | 58 | return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj); |
| 59 | } | 59 | } |
| ... | @@ -61,7 +61,7 @@ struct __fn { | ... | @@ -61,7 +61,7 @@ struct __fn { |
| 61 | template <forward_range _Range, | 61 | template <forward_range _Range, |
| 62 | class _Proj = identity, | 62 | class _Proj = identity, |
| 63 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 63 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 64 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | 64 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> |
| 65 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | 65 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { |
| 66 | return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); | 66 | return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); |
| 67 | } | 67 | } |
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h+2-2| ... | @@ -60,7 +60,7 @@ struct __fn { | ... | @@ -60,7 +60,7 @@ struct __fn { |
| 60 | class _Proj1 = identity, | 60 | class _Proj1 = identity, |
| 61 | class _Proj2 = identity, | 61 | class _Proj2 = identity, |
| 62 | indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less> | 62 | indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less> |
| 63 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 64 | _Iter1 __first1, | 64 | _Iter1 __first1, |
| 65 | _Sent1 __last1, | 65 | _Sent1 __last1, |
| 66 | _Iter2 __first2, | 66 | _Iter2 __first2, |
| ... | @@ -78,7 +78,7 @@ struct __fn { | ... | @@ -78,7 +78,7 @@ struct __fn { |
| 78 | class _Proj2 = identity, | 78 | class _Proj2 = identity, |
| 79 | indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> | 79 | indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> |
| 80 | _Comp = ranges::less> | 80 | _Comp = ranges::less> |
| 81 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 82 | _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 82 | _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 83 | return __lexicographical_compare_impl( | 83 | return __lexicographical_compare_impl( |
| 84 | ranges::begin(__range1), | 84 | ranges::begin(__range1), |
lib/libcxx/include/__algorithm/ranges_lower_bound.h+2-2| ... | @@ -43,7 +43,7 @@ struct __fn { | ... | @@ -43,7 +43,7 @@ struct __fn { |
| 43 | class _Type, | 43 | class _Type, |
| 44 | class _Proj = identity, | 44 | class _Proj = identity, |
| 45 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> | 45 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> |
| 46 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter | 46 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 47 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 47 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 48 | return std::__lower_bound<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); | 48 | return std::__lower_bound<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); |
| 49 | } | 49 | } |
| ... | @@ -52,7 +52,7 @@ struct __fn { | ... | @@ -52,7 +52,7 @@ struct __fn { |
| 52 | class _Type, | 52 | class _Type, |
| 53 | class _Proj = identity, | 53 | class _Proj = identity, |
| 54 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 54 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 55 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> |
| 56 | operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 56 | operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 57 | return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj); | 57 | return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj); |
| 58 | } | 58 | } |
lib/libcxx/include/__algorithm/ranges_max.h+4-4| ... | @@ -41,7 +41,7 @@ struct __fn { | ... | @@ -41,7 +41,7 @@ struct __fn { |
| 41 | template <class _Tp, | 41 | template <class _Tp, |
| 42 | class _Proj = identity, | 42 | class _Proj = identity, |
| 43 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | 43 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> |
| 44 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& | 44 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& |
| 45 | operator()(_LIBCPP_LIFETIMEBOUND const _Tp& __a, | 45 | operator()(_LIBCPP_LIFETIMEBOUND const _Tp& __a, |
| 46 | _LIBCPP_LIFETIMEBOUND const _Tp& __b, | 46 | _LIBCPP_LIFETIMEBOUND const _Tp& __b, |
| 47 | _Comp __comp = {}, | 47 | _Comp __comp = {}, |
| ... | @@ -52,7 +52,7 @@ struct __fn { | ... | @@ -52,7 +52,7 @@ struct __fn { |
| 52 | template <copyable _Tp, | 52 | template <copyable _Tp, |
| 53 | class _Proj = identity, | 53 | class _Proj = identity, |
| 54 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | 54 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> |
| 55 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp |
| 56 | operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { | 56 | operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { |
| 57 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 57 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 58 | __il.begin() != __il.end(), "initializer_list must contain at least one element"); | 58 | __il.begin() != __il.end(), "initializer_list must contain at least one element"); |
| ... | @@ -65,7 +65,7 @@ struct __fn { | ... | @@ -65,7 +65,7 @@ struct __fn { |
| 65 | class _Proj = identity, | 65 | class _Proj = identity, |
| 66 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | 66 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> |
| 67 | requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*> | 67 | requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*> |
| 68 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp> | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp> |
| 69 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 69 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 70 | auto __first = ranges::begin(__r); | 70 | auto __first = ranges::begin(__r); |
| 71 | auto __last = ranges::end(__r); | 71 | auto __last = ranges::end(__r); |
| ... | @@ -98,6 +98,6 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -98,6 +98,6 @@ _LIBCPP_END_NAMESPACE_STD |
| 98 | 98 | ||
| 99 | _LIBCPP_POP_MACROS | 99 | _LIBCPP_POP_MACROS |
| 100 | 100 | ||
| 101 | #endif // _LIBCPP_STD_VER >= 20 && | 101 | #endif // _LIBCPP_STD_VER >= 20 |
| 102 | 102 | ||
| 103 | #endif // _LIBCPP___ALGORITHM_RANGES_MAX_H | 103 | #endif // _LIBCPP___ALGORITHM_RANGES_MAX_H |
lib/libcxx/include/__algorithm/ranges_max_element.h+2-2| ... | @@ -38,7 +38,7 @@ struct __fn { | ... | @@ -38,7 +38,7 @@ struct __fn { |
| 38 | sentinel_for<_Ip> _Sp, | 38 | sentinel_for<_Ip> _Sp, |
| 39 | class _Proj = identity, | 39 | class _Proj = identity, |
| 40 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | 40 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> |
| 41 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 42 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | 42 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 43 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; | 43 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; |
| 44 | return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj); | 44 | return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj); |
| ... | @@ -47,7 +47,7 @@ struct __fn { | ... | @@ -47,7 +47,7 @@ struct __fn { |
| 47 | template <forward_range _Rp, | 47 | template <forward_range _Rp, |
| 48 | class _Proj = identity, | 48 | class _Proj = identity, |
| 49 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | 49 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> |
| 50 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 51 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 51 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 52 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; | 52 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; |
| 53 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); | 53 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); |
lib/libcxx/include/__algorithm/ranges_min.h+4-4| ... | @@ -40,7 +40,7 @@ struct __fn { | ... | @@ -40,7 +40,7 @@ struct __fn { |
| 40 | template <class _Tp, | 40 | template <class _Tp, |
| 41 | class _Proj = identity, | 41 | class _Proj = identity, |
| 42 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | 42 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> |
| 43 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& | 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& |
| 44 | operator()(_LIBCPP_LIFETIMEBOUND const _Tp& __a, | 44 | operator()(_LIBCPP_LIFETIMEBOUND const _Tp& __a, |
| 45 | _LIBCPP_LIFETIMEBOUND const _Tp& __b, | 45 | _LIBCPP_LIFETIMEBOUND const _Tp& __b, |
| 46 | _Comp __comp = {}, | 46 | _Comp __comp = {}, |
| ... | @@ -51,7 +51,7 @@ struct __fn { | ... | @@ -51,7 +51,7 @@ struct __fn { |
| 51 | template <copyable _Tp, | 51 | template <copyable _Tp, |
| 52 | class _Proj = identity, | 52 | class _Proj = identity, |
| 53 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | 53 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> |
| 54 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp |
| 55 | operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { | 55 | operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { |
| 56 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 56 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 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"); |
| ... | @@ -62,7 +62,7 @@ struct __fn { | ... | @@ -62,7 +62,7 @@ struct __fn { |
| 62 | class _Proj = identity, | 62 | class _Proj = identity, |
| 63 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | 63 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> |
| 64 | requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*> | 64 | requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*> |
| 65 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp> | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp> |
| 66 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 66 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 67 | auto __first = ranges::begin(__r); | 67 | auto __first = ranges::begin(__r); |
| 68 | auto __last = ranges::end(__r); | 68 | auto __last = ranges::end(__r); |
| ... | @@ -90,6 +90,6 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -90,6 +90,6 @@ _LIBCPP_END_NAMESPACE_STD |
| 90 | 90 | ||
| 91 | _LIBCPP_POP_MACROS | 91 | _LIBCPP_POP_MACROS |
| 92 | 92 | ||
| 93 | #endif // _LIBCPP_STD_VER >= 20 && | 93 | #endif // _LIBCPP_STD_VER >= 20 |
| 94 | 94 | ||
| 95 | #endif // _LIBCPP___ALGORITHM_RANGES_MIN_H | 95 | #endif // _LIBCPP___ALGORITHM_RANGES_MIN_H |
lib/libcxx/include/__algorithm/ranges_min_element.h+2-2| ... | @@ -52,7 +52,7 @@ struct __fn { | ... | @@ -52,7 +52,7 @@ struct __fn { |
| 52 | sentinel_for<_Ip> _Sp, | 52 | sentinel_for<_Ip> _Sp, |
| 53 | class _Proj = identity, | 53 | class _Proj = identity, |
| 54 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | 54 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> |
| 55 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 56 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | 56 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 57 | return ranges::__min_element_impl(__first, __last, __comp, __proj); | 57 | return ranges::__min_element_impl(__first, __last, __comp, __proj); |
| 58 | } | 58 | } |
| ... | @@ -60,7 +60,7 @@ struct __fn { | ... | @@ -60,7 +60,7 @@ struct __fn { |
| 60 | template <forward_range _Rp, | 60 | template <forward_range _Rp, |
| 61 | class _Proj = identity, | 61 | class _Proj = identity, |
| 62 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | 62 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> |
| 63 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 64 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 64 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 65 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | 65 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); |
| 66 | } | 66 | } |
lib/libcxx/include/__algorithm/ranges_minmax.h+19-4| ... | @@ -23,7 +23,9 @@ | ... | @@ -23,7 +23,9 @@ |
| 23 | #include <__iterator/projected.h> | 23 | #include <__iterator/projected.h> |
| 24 | #include <__ranges/access.h> | 24 | #include <__ranges/access.h> |
| 25 | #include <__ranges/concepts.h> | 25 | #include <__ranges/concepts.h> |
| 26 | #include <__type_traits/desugars_to.h> | ||
| 26 | #include <__type_traits/is_reference.h> | 27 | #include <__type_traits/is_reference.h> |
| 28 | #include <__type_traits/is_trivially_copyable.h> | ||
| 27 | #include <__type_traits/remove_cvref.h> | 29 | #include <__type_traits/remove_cvref.h> |
| 28 | #include <__utility/forward.h> | 30 | #include <__utility/forward.h> |
| 29 | #include <__utility/move.h> | 31 | #include <__utility/move.h> |
| ... | @@ -50,7 +52,7 @@ struct __fn { | ... | @@ -50,7 +52,7 @@ struct __fn { |
| 50 | template <class _Type, | 52 | template <class _Type, |
| 51 | class _Proj = identity, | 53 | class _Proj = identity, |
| 52 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> | 54 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> |
| 53 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&> | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&> |
| 54 | operator()(_LIBCPP_LIFETIMEBOUND const _Type& __a, | 56 | operator()(_LIBCPP_LIFETIMEBOUND const _Type& __a, |
| 55 | _LIBCPP_LIFETIMEBOUND const _Type& __b, | 57 | _LIBCPP_LIFETIMEBOUND const _Type& __b, |
| 56 | _Comp __comp = {}, | 58 | _Comp __comp = {}, |
| ... | @@ -63,7 +65,7 @@ struct __fn { | ... | @@ -63,7 +65,7 @@ struct __fn { |
| 63 | template <copyable _Type, | 65 | template <copyable _Type, |
| 64 | class _Proj = identity, | 66 | class _Proj = identity, |
| 65 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> | 67 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> |
| 66 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type> | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type> |
| 67 | operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const { | 69 | operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const { |
| 68 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 70 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 69 | __il.begin() != __il.end(), "initializer_list has to contain at least one element"); | 71 | __il.begin() != __il.end(), "initializer_list has to contain at least one element"); |
| ... | @@ -75,7 +77,7 @@ struct __fn { | ... | @@ -75,7 +77,7 @@ struct __fn { |
| 75 | class _Proj = identity, | 77 | class _Proj = identity, |
| 76 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 78 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 77 | requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*> | 79 | requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*> |
| 78 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<range_value_t<_Range>> | 80 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<range_value_t<_Range>> |
| 79 | operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 81 | operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 80 | auto __first = ranges::begin(__r); | 82 | auto __first = ranges::begin(__r); |
| 81 | auto __last = ranges::end(__r); | 83 | auto __last = ranges::end(__r); |
| ... | @@ -83,7 +85,20 @@ struct __fn { | ... | @@ -83,7 +85,20 @@ struct __fn { |
| 83 | 85 | ||
| 84 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range has to contain at least one element"); | 86 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range has to contain at least one element"); |
| 85 | 87 | ||
| 86 | if constexpr (forward_range<_Range>) { | 88 | // This optimiation is not in minmax_element because clang doesn't see through the pointers and as a result doesn't |
| 89 | // vectorize the code. | ||
| 90 | if constexpr (contiguous_range<_Range> && is_integral_v<_ValueT> && | ||
| 91 | __is_cheap_to_copy<_ValueT> & __is_identity<_Proj>::value && | ||
| 92 | __desugars_to_v<__less_tag, _Comp, _ValueT, _ValueT>) { | ||
| 93 | minmax_result<_ValueT> __result = {__r[0], __r[0]}; | ||
| 94 | for (auto __e : __r) { | ||
| 95 | if (__e < __result.min) | ||
| 96 | __result.min = __e; | ||
| 97 | if (__result.max < __e) | ||
| 98 | __result.max = __e; | ||
| 99 | } | ||
| 100 | return __result; | ||
| 101 | } else if constexpr (forward_range<_Range>) { | ||
| 87 | // Special-case the one element case. Avoid repeatedly initializing objects from the result of an iterator | 102 | // Special-case the one element case. Avoid repeatedly initializing objects from the result of an iterator |
| 88 | // dereference when doing so might not be idempotent. The `if constexpr` avoids the extra branch in cases where | 103 | // dereference when doing so might not be idempotent. The `if constexpr` avoids the extra branch in cases where |
| 89 | // it's not needed. | 104 | // it's not needed. |
lib/libcxx/include/__algorithm/ranges_minmax_element.h+2-2| ... | @@ -46,7 +46,7 @@ struct __fn { | ... | @@ -46,7 +46,7 @@ struct __fn { |
| 46 | sentinel_for<_Ip> _Sp, | 46 | sentinel_for<_Ip> _Sp, |
| 47 | class _Proj = identity, | 47 | class _Proj = identity, |
| 48 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | 48 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> |
| 49 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<_Ip> | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<_Ip> |
| 50 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | 50 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 51 | auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj); | 51 | auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj); |
| 52 | return {__ret.first, __ret.second}; | 52 | return {__ret.first, __ret.second}; |
| ... | @@ -55,7 +55,7 @@ struct __fn { | ... | @@ -55,7 +55,7 @@ struct __fn { |
| 55 | template <forward_range _Rp, | 55 | template <forward_range _Rp, |
| 56 | class _Proj = identity, | 56 | class _Proj = identity, |
| 57 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | 57 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> |
| 58 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<borrowed_iterator_t<_Rp>> | 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<borrowed_iterator_t<_Rp>> |
| 59 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 59 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 60 | auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | 60 | auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); |
| 61 | return {__ret.first, __ret.second}; | 61 | return {__ret.first, __ret.second}; |
lib/libcxx/include/__algorithm/ranges_mismatch.h+15-9| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MISMATCH_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_MISMATCH_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/in_in_result.h> | 12 | #include <__algorithm/in_in_result.h> |
| 13 | #include <__algorithm/mismatch.h> | ||
| 14 | #include <__algorithm/unwrap_range.h> | ||
| 13 | #include <__config> | 15 | #include <__config> |
| 14 | #include <__functional/identity.h> | 16 | #include <__functional/identity.h> |
| 15 | #include <__functional/invoke.h> | 17 | #include <__functional/invoke.h> |
| ... | @@ -42,13 +44,17 @@ struct __fn { | ... | @@ -42,13 +44,17 @@ struct __fn { |
| 42 | template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2> | 44 | template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2> |
| 43 | static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> | 45 | static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> |
| 44 | __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | 46 | __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 45 | while (__first1 != __last1 && __first2 != __last2) { | 47 | if constexpr (forward_iterator<_I1> && forward_iterator<_I2>) { |
| 46 | if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2))) | 48 | auto __range1 = std::__unwrap_range(__first1, __last1); |
| 47 | break; | 49 | auto __range2 = std::__unwrap_range(__first2, __last2); |
| 48 | ++__first1; | 50 | auto __res = |
| 49 | ++__first2; | 51 | std::__mismatch(__range1.first, __range1.second, __range2.first, __range2.second, __pred, __proj1, __proj2); |
| 52 | return {std::__rewrap_range<_S1>(__first1, __res.first), std::__rewrap_range<_S2>(__first2, __res.second)}; | ||
| 53 | } else { | ||
| 54 | auto __res = std::__mismatch( | ||
| 55 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2); | ||
| 56 | return {std::move(__res.first), std::move(__res.second)}; | ||
| 50 | } | 57 | } |
| 51 | return {std::move(__first1), std::move(__first2)}; | ||
| 52 | } | 58 | } |
| 53 | 59 | ||
| 54 | template <input_iterator _I1, | 60 | template <input_iterator _I1, |
| ... | @@ -59,7 +65,7 @@ struct __fn { | ... | @@ -59,7 +65,7 @@ struct __fn { |
| 59 | class _Proj1 = identity, | 65 | class _Proj1 = identity, |
| 60 | class _Proj2 = identity> | 66 | class _Proj2 = identity> |
| 61 | requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2> | 67 | requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2> |
| 62 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> operator()( | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> operator()( |
| 63 | _I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) | 69 | _I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) |
| 64 | const { | 70 | const { |
| 65 | return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2); | 71 | return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2); |
| ... | @@ -71,8 +77,8 @@ struct __fn { | ... | @@ -71,8 +77,8 @@ struct __fn { |
| 71 | class _Proj1 = identity, | 77 | class _Proj1 = identity, |
| 72 | class _Proj2 = identity> | 78 | class _Proj2 = identity> |
| 73 | requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2> | 79 | requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2> |
| 74 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<borrowed_iterator_t<_R1>, | 80 | [[nodiscard]] |
| 75 | borrowed_iterator_t<_R2>> | 81 | _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>> |
| 76 | operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 82 | operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 77 | return __go( | 83 | return __go( |
| 78 | ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2); | 84 | ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2); |
lib/libcxx/include/__algorithm/ranges_none_of.h+2-2| ... | @@ -46,7 +46,7 @@ struct __fn { | ... | @@ -46,7 +46,7 @@ struct __fn { |
| 46 | sentinel_for<_Iter> _Sent, | 46 | sentinel_for<_Iter> _Sent, |
| 47 | class _Proj = identity, | 47 | class _Proj = identity, |
| 48 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | 48 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 49 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 50 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { | 50 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { |
| 51 | return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj); | 51 | return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 52 | } | 52 | } |
| ... | @@ -54,7 +54,7 @@ struct __fn { | ... | @@ -54,7 +54,7 @@ struct __fn { |
| 54 | template <input_range _Range, | 54 | template <input_range _Range, |
| 55 | class _Proj = identity, | 55 | class _Proj = identity, |
| 56 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 56 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 57 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool | 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 58 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | 58 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 59 | return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 59 | return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 60 | } | 60 | } |
lib/libcxx/include/__algorithm/ranges_remove.h+2-2| ... | @@ -37,7 +37,7 @@ namespace __remove { | ... | @@ -37,7 +37,7 @@ namespace __remove { |
| 37 | struct __fn { | 37 | struct __fn { |
| 38 | template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> | 38 | template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> |
| 39 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> | 39 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> |
| 40 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> |
| 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { | 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { |
| 42 | auto __pred = [&](auto&& __other) -> bool { return __value == __other; }; | 42 | auto __pred = [&](auto&& __other) -> bool { return __value == __other; }; |
| 43 | return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); | 43 | return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); |
| ... | @@ -46,7 +46,7 @@ struct __fn { | ... | @@ -46,7 +46,7 @@ struct __fn { |
| 46 | template <forward_range _Range, class _Type, class _Proj = identity> | 46 | template <forward_range _Range, class _Type, class _Proj = identity> |
| 47 | requires permutable<iterator_t<_Range>> && | 47 | requires permutable<iterator_t<_Range>> && |
| 48 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | 48 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> |
| 49 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> |
| 50 | operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const { | 50 | operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const { |
| 51 | auto __pred = [&](auto&& __other) -> bool { return __value == __other; }; | 51 | auto __pred = [&](auto&& __other) -> bool { return __value == __other; }; |
| 52 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 52 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
lib/libcxx/include/__algorithm/ranges_remove_if.h+2-2| ... | @@ -59,7 +59,7 @@ struct __fn { | ... | @@ -59,7 +59,7 @@ struct __fn { |
| 59 | sentinel_for<_Iter> _Sent, | 59 | sentinel_for<_Iter> _Sent, |
| 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 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> |
| 63 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | 63 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { |
| 64 | return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); | 64 | return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); |
| 65 | } | 65 | } |
| ... | @@ -68,7 +68,7 @@ struct __fn { | ... | @@ -68,7 +68,7 @@ struct __fn { |
| 68 | class _Proj = identity, | 68 | class _Proj = identity, |
| 69 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 69 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 70 | requires permutable<iterator_t<_Range>> | 70 | requires permutable<iterator_t<_Range>> |
| 71 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> | 71 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> |
| 72 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | 72 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 73 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 73 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 74 | } | 74 | } |
lib/libcxx/include/__algorithm/ranges_search.h+2-2| ... | @@ -77,7 +77,7 @@ struct __fn { | ... | @@ -77,7 +77,7 @@ struct __fn { |
| 77 | class _Proj1 = identity, | 77 | class _Proj1 = identity, |
| 78 | class _Proj2 = identity> | 78 | class _Proj2 = identity> |
| 79 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | 79 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> |
| 80 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()( | 80 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()( |
| 81 | _Iter1 __first1, | 81 | _Iter1 __first1, |
| 82 | _Sent1 __last1, | 82 | _Sent1 __last1, |
| 83 | _Iter2 __first2, | 83 | _Iter2 __first2, |
| ... | @@ -94,7 +94,7 @@ struct __fn { | ... | @@ -94,7 +94,7 @@ struct __fn { |
| 94 | class _Proj1 = identity, | 94 | class _Proj1 = identity, |
| 95 | class _Proj2 = identity> | 95 | class _Proj2 = identity> |
| 96 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 96 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 97 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()( | 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()( |
| 98 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 98 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 99 | auto __first1 = ranges::begin(__range1); | 99 | auto __first1 = ranges::begin(__range1); |
| 100 | if constexpr (sized_range<_Range2>) { | 100 | if constexpr (sized_range<_Range2>) { |
lib/libcxx/include/__algorithm/ranges_search_n.h+2-2| ... | @@ -71,7 +71,7 @@ struct __fn { | ... | @@ -71,7 +71,7 @@ struct __fn { |
| 71 | class _Pred = ranges::equal_to, | 71 | class _Pred = ranges::equal_to, |
| 72 | class _Proj = identity> | 72 | class _Proj = identity> |
| 73 | requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj> | 73 | requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj> |
| 74 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> |
| 75 | operator()(_Iter __first, | 75 | operator()(_Iter __first, |
| 76 | _Sent __last, | 76 | _Sent __last, |
| 77 | iter_difference_t<_Iter> __count, | 77 | iter_difference_t<_Iter> __count, |
| ... | @@ -83,7 +83,7 @@ struct __fn { | ... | @@ -83,7 +83,7 @@ struct __fn { |
| 83 | 83 | ||
| 84 | template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity> | 84 | template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity> |
| 85 | requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj> | 85 | requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj> |
| 86 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()( | 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()( |
| 87 | _Range&& __range, range_difference_t<_Range> __count, const _Type& __value, _Pred __pred = {}, _Proj __proj = {}) | 87 | _Range&& __range, range_difference_t<_Range> __count, const _Type& __value, _Pred __pred = {}, _Proj __proj = {}) |
| 88 | const { | 88 | const { |
| 89 | auto __first = ranges::begin(__range); | 89 | auto __first = ranges::begin(__range); |
lib/libcxx/include/__algorithm/ranges_starts_with.h+4-4| ... | @@ -42,14 +42,14 @@ struct __fn { | ... | @@ -42,14 +42,14 @@ struct __fn { |
| 42 | class _Proj1 = identity, | 42 | class _Proj1 = identity, |
| 43 | class _Proj2 = identity> | 43 | class _Proj2 = identity> |
| 44 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | 44 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> |
| 45 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool operator()( |
| 46 | _Iter1 __first1, | 46 | _Iter1 __first1, |
| 47 | _Sent1 __last1, | 47 | _Sent1 __last1, |
| 48 | _Iter2 __first2, | 48 | _Iter2 __first2, |
| 49 | _Sent2 __last2, | 49 | _Sent2 __last2, |
| 50 | _Pred __pred = {}, | 50 | _Pred __pred = {}, |
| 51 | _Proj1 __proj1 = {}, | 51 | _Proj1 __proj1 = {}, |
| 52 | _Proj2 __proj2 = {}) const { | 52 | _Proj2 __proj2 = {}) { |
| 53 | return __mismatch::__fn::__go( | 53 | return __mismatch::__fn::__go( |
| 54 | std::move(__first1), | 54 | std::move(__first1), |
| 55 | std::move(__last1), | 55 | std::move(__last1), |
| ... | @@ -67,8 +67,8 @@ struct __fn { | ... | @@ -67,8 +67,8 @@ struct __fn { |
| 67 | class _Proj1 = identity, | 67 | class _Proj1 = identity, |
| 68 | class _Proj2 = identity> | 68 | class _Proj2 = identity> |
| 69 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 69 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 70 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool |
| 71 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 71 | operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { |
| 72 | return __mismatch::__fn::__go( | 72 | return __mismatch::__fn::__go( |
| 73 | ranges::begin(__range1), | 73 | ranges::begin(__range1), |
| 74 | ranges::end(__range1), | 74 | ranges::end(__range1), |
lib/libcxx/include/__algorithm/ranges_unique.h+2-2| ... | @@ -47,7 +47,7 @@ struct __fn { | ... | @@ -47,7 +47,7 @@ struct __fn { |
| 47 | sentinel_for<_Iter> _Sent, | 47 | sentinel_for<_Iter> _Sent, |
| 48 | class _Proj = identity, | 48 | class _Proj = identity, |
| 49 | indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to> | 49 | indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to> |
| 50 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> |
| 51 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 51 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 52 | auto __ret = | 52 | auto __ret = |
| 53 | std::__unique<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::__make_projected(__comp, __proj)); | 53 | std::__unique<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::__make_projected(__comp, __proj)); |
| ... | @@ -58,7 +58,7 @@ struct __fn { | ... | @@ -58,7 +58,7 @@ struct __fn { |
| 58 | class _Proj = identity, | 58 | class _Proj = identity, |
| 59 | indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to> | 59 | indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to> |
| 60 | requires permutable<iterator_t<_Range>> | 60 | requires permutable<iterator_t<_Range>> |
| 61 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> | 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> |
| 62 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | 62 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { |
| 63 | auto __ret = std::__unique<_RangeAlgPolicy>( | 63 | auto __ret = std::__unique<_RangeAlgPolicy>( |
| 64 | ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj)); | 64 | ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj)); |
lib/libcxx/include/__algorithm/ranges_upper_bound.h+2-2| ... | @@ -37,7 +37,7 @@ struct __fn { | ... | @@ -37,7 +37,7 @@ struct __fn { |
| 37 | class _Type, | 37 | class _Type, |
| 38 | class _Proj = identity, | 38 | class _Proj = identity, |
| 39 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> | 39 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> |
| 40 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 41 | operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 42 | auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool { | 42 | auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool { |
| 43 | return !std::invoke(__comp, __rhs, __lhs); | 43 | return !std::invoke(__comp, __rhs, __lhs); |
| ... | @@ -50,7 +50,7 @@ struct __fn { | ... | @@ -50,7 +50,7 @@ struct __fn { |
| 50 | class _Type, | 50 | class _Type, |
| 51 | class _Proj = identity, | 51 | class _Proj = identity, |
| 52 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | 52 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> |
| 53 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> |
| 54 | operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | 54 | operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { |
| 55 | auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool { | 55 | auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool { |
| 56 | return !std::invoke(__comp, __rhs, __lhs); | 56 | return !std::invoke(__comp, __rhs, __lhs); |
lib/libcxx/include/__algorithm/remove.h+1-1| ... | @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS |
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | template <class _ForwardIterator, class _Tp> | 26 | template <class _ForwardIterator, class _Tp> |
| 27 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 27 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 28 | remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 28 | remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 29 | __first = std::find(__first, __last, __value); | 29 | __first = std::find(__first, __last, __value); |
| 30 | if (__first != __last) { | 30 | if (__first != __last) { |
lib/libcxx/include/__algorithm/remove_if.h+1-1| ... | @@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS |
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | ||
| 25 | template <class _ForwardIterator, class _Predicate> | 25 | template <class _ForwardIterator, class _Predicate> |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 26 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 27 | remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | 27 | remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 28 | __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred); | 28 | __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred); |
| 29 | if (__first != __last) { | 29 | if (__first != __last) { |
lib/libcxx/include/__algorithm/rotate.h+1-1| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | #include <__algorithm/swap_ranges.h> | 15 | #include <__algorithm/swap_ranges.h> |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__type_traits/is_trivially_move_assignable.h> | 18 | #include <__type_traits/is_trivially_assignable.h> |
| 19 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| 20 | #include <__utility/pair.h> | 20 | #include <__utility/pair.h> |
| 21 | 21 |
lib/libcxx/include/__algorithm/search.h+27-24| ... | @@ -117,17 +117,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc | ... | @@ -117,17 +117,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc |
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | 120 | template <class _Iter1, |
| 121 | class _Sent1, | ||
| 122 | class _Iter2, | ||
| 123 | class _Sent2, | ||
| 124 | class _Pred, | ||
| 125 | class _Proj1, | ||
| 126 | class _Proj2, | ||
| 127 | __enable_if_t<__has_random_access_iterator_category<_Iter1>::value && | ||
| 128 | __has_random_access_iterator_category<_Iter2>::value, | ||
| 129 | int> = 0> | ||
| 121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl( | 130 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl( |
| 122 | _Iter1 __first1, | 131 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 123 | _Sent1 __last1, | ||
| 124 | _Iter2 __first2, | ||
| 125 | _Sent2 __last2, | ||
| 126 | _Pred& __pred, | ||
| 127 | _Proj1& __proj1, | ||
| 128 | _Proj2& __proj2, | ||
| 129 | __enable_if_t<__has_random_access_iterator_category<_Iter1>::value && | ||
| 130 | __has_random_access_iterator_category<_Iter2>::value>* = nullptr) { | ||
| 131 | auto __size2 = __last2 - __first2; | 132 | auto __size2 = __last2 - __first2; |
| 132 | if (__size2 == 0) | 133 | if (__size2 == 0) |
| 133 | return std::make_pair(__first1, __first1); | 134 | return std::make_pair(__first1, __first1); |
| ... | @@ -141,23 +142,25 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc | ... | @@ -141,23 +142,25 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc |
| 141 | __first1, __last1, __first2, __last2, __pred, __proj1, __proj2, __size1, __size2); | 142 | __first1, __last1, __first2, __last2, __pred, __proj1, __proj2, __size1, __size2); |
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | 145 | template < |
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl( | 146 | class _Iter1, |
| 146 | _Iter1 __first1, | 147 | class _Sent1, |
| 147 | _Sent1 __last1, | 148 | class _Iter2, |
| 148 | _Iter2 __first2, | 149 | class _Sent2, |
| 149 | _Sent2 __last2, | 150 | class _Pred, |
| 150 | _Pred& __pred, | 151 | class _Proj1, |
| 151 | _Proj1& __proj1, | 152 | class _Proj2, |
| 152 | _Proj2& __proj2, | ||
| 153 | __enable_if_t<__has_forward_iterator_category<_Iter1>::value && __has_forward_iterator_category<_Iter2>::value && | 153 | __enable_if_t<__has_forward_iterator_category<_Iter1>::value && __has_forward_iterator_category<_Iter2>::value && |
| 154 | !(__has_random_access_iterator_category<_Iter1>::value && | 154 | !(__has_random_access_iterator_category<_Iter1>::value && |
| 155 | __has_random_access_iterator_category<_Iter2>::value)>* = nullptr) { | 155 | __has_random_access_iterator_category<_Iter2>::value), |
| 156 | int> = 0> | ||
| 157 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl( | ||
| 158 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 156 | return std::__search_forward_impl<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); | 159 | return std::__search_forward_impl<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); |
| 157 | } | 160 | } |
| 158 | 161 | ||
| 159 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 162 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 160 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | 163 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 |
| 161 | search(_ForwardIterator1 __first1, | 164 | search(_ForwardIterator1 __first1, |
| 162 | _ForwardIterator1 __last1, | 165 | _ForwardIterator1 __last1, |
| 163 | _ForwardIterator2 __first2, | 166 | _ForwardIterator2 __first2, |
| ... | @@ -170,14 +173,14 @@ search(_ForwardIterator1 __first1, | ... | @@ -170,14 +173,14 @@ search(_ForwardIterator1 __first1, |
| 170 | } | 173 | } |
| 171 | 174 | ||
| 172 | template <class _ForwardIterator1, class _ForwardIterator2> | 175 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 173 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | 176 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 |
| 174 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | 177 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 175 | return std::search(__first1, __last1, __first2, __last2, __equal_to()); | 178 | return std::search(__first1, __last1, __first2, __last2, __equal_to()); |
| 176 | } | 179 | } |
| 177 | 180 | ||
| 178 | #if _LIBCPP_STD_VER >= 17 | 181 | #if _LIBCPP_STD_VER >= 17 |
| 179 | template <class _ForwardIterator, class _Searcher> | 182 | template <class _ForwardIterator, class _Searcher> |
| 180 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 183 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 181 | search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) { | 184 | search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) { |
| 182 | return __s(__f, __l).first; | 185 | return __s(__f, __l).first; |
| 183 | } | 186 | } |
lib/libcxx/include/__algorithm/search_n.h+22-21| ... | @@ -108,34 +108,35 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 std::pair<_Iter, _Iter> __se | ... | @@ -108,34 +108,35 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 std::pair<_Iter, _Iter> __se |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | template <class _Iter, class _Sent, class _DiffT, class _Type, class _Pred, class _Proj> | 111 | template <class _Iter, |
| 112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> __search_n_impl( | 112 | class _Sent, |
| 113 | _Iter __first, | 113 | class _DiffT, |
| 114 | _Sent __last, | 114 | class _Type, |
| 115 | _DiffT __count, | 115 | class _Pred, |
| 116 | const _Type& __value, | 116 | class _Proj, |
| 117 | _Pred& __pred, | 117 | __enable_if_t<__has_random_access_iterator_category<_Iter>::value, int> = 0> |
| 118 | _Proj& __proj, | 118 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> |
| 119 | __enable_if_t<__has_random_access_iterator_category<_Iter>::value>* = nullptr) { | 119 | __search_n_impl(_Iter __first, _Sent __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { |
| 120 | return std::__search_n_random_access_impl<_ClassicAlgPolicy>( | 120 | return std::__search_n_random_access_impl<_ClassicAlgPolicy>( |
| 121 | __first, __last, __count, __value, __pred, __proj, __last - __first); | 121 | __first, __last, __count, __value, __pred, __proj, __last - __first); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | template <class _Iter1, class _Sent1, class _DiffT, class _Type, class _Pred, class _Proj> | 124 | template <class _Iter1, |
| 125 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_n_impl( | 125 | class _Sent1, |
| 126 | _Iter1 __first, | 126 | class _DiffT, |
| 127 | _Sent1 __last, | 127 | class _Type, |
| 128 | _DiffT __count, | 128 | class _Pred, |
| 129 | const _Type& __value, | 129 | class _Proj, |
| 130 | _Pred& __pred, | 130 | __enable_if_t<__has_forward_iterator_category<_Iter1>::value && |
| 131 | _Proj& __proj, | 131 | !__has_random_access_iterator_category<_Iter1>::value, |
| 132 | __enable_if_t<__has_forward_iterator_category<_Iter1>::value && | 132 | int> = 0> |
| 133 | !__has_random_access_iterator_category<_Iter1>::value>* = nullptr) { | 133 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> |
| 134 | __search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { | ||
| 134 | return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last, __count, __value, __pred, __proj); | 135 | return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last, __count, __value, __pred, __proj); |
| 135 | } | 136 | } |
| 136 | 137 | ||
| 137 | template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> | 138 | template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> |
| 138 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n( | 139 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n( |
| 139 | _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) { | 140 | _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) { |
| 140 | static_assert( | 141 | static_assert( |
| 141 | __is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable"); | 142 | __is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable"); |
| ... | @@ -144,7 +145,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ... | @@ -144,7 +145,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 146 | template <class _ForwardIterator, class _Size, class _Tp> | 147 | template <class _ForwardIterator, class _Size, class _Tp> |
| 147 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 148 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 148 | search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) { | 149 | search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) { |
| 149 | return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to()); | 150 | return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to()); |
| 150 | } | 151 | } |
lib/libcxx/include/__algorithm/set_intersection.h+118-4| ... | @@ -12,10 +12,15 @@ | ... | @@ -12,10 +12,15 @@ |
| 12 | #include <__algorithm/comp.h> | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/lower_bound.h> | ||
| 15 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__functional/identity.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__iterator/next.h> | 19 | #include <__iterator/next.h> |
| 20 | #include <__type_traits/is_same.h> | ||
| 21 | #include <__utility/exchange.h> | ||
| 18 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 23 | #include <__utility/swap.h> | ||
| 19 | 24 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header | 26 | # pragma GCC system_header |
| ... | @@ -38,10 +43,103 @@ struct __set_intersection_result { | ... | @@ -38,10 +43,103 @@ struct __set_intersection_result { |
| 38 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} | 43 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} |
| 39 | }; | 44 | }; |
| 40 | 45 | ||
| 41 | template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | 46 | // Helper for __set_intersection() with one-sided binary search: populate result and advance input iterators if they |
| 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter> | 47 | // are found to potentially contain the same value in two consecutive calls. This function is very intimately related to |
| 48 | // the way it is used and doesn't attempt to abstract that, it's not appropriate for general usage outside of its | ||
| 49 | // context. | ||
| 50 | template <class _InForwardIter1, class _InForwardIter2, class _OutIter> | ||
| 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_intersection_add_output_if_equal( | ||
| 52 | bool __may_be_equal, | ||
| 53 | _InForwardIter1& __first1, | ||
| 54 | _InForwardIter2& __first2, | ||
| 55 | _OutIter& __result, | ||
| 56 | bool& __prev_may_be_equal) { | ||
| 57 | if (__may_be_equal && __prev_may_be_equal) { | ||
| 58 | *__result = *__first1; | ||
| 59 | ++__result; | ||
| 60 | ++__first1; | ||
| 61 | ++__first2; | ||
| 62 | __prev_may_be_equal = false; | ||
| 63 | } else { | ||
| 64 | __prev_may_be_equal = __may_be_equal; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | // With forward iterators we can make multiple passes over the data, allowing the use of one-sided binary search to | ||
| 69 | // reduce best-case complexity to log(N). Understanding how we can use binary search and still respect complexity | ||
| 70 | // guarantees is _not_ straightforward: the guarantee is "at most 2*(N+M)-1 comparisons", and one-sided binary search | ||
| 71 | // will necessarily overshoot depending on the position of the needle in the haystack -- for instance, if we're | ||
| 72 | // searching for 3 in (1, 2, 3, 4), we'll check if 3<1, then 3<2, then 3<4, and, finally, 3<3, for a total of 4 | ||
| 73 | // comparisons, when linear search would have yielded 3. However, because we won't need to perform the intervening | ||
| 74 | // reciprocal comparisons (ie 1<3, 2<3, 4<3), that extra comparison doesn't run afoul of the guarantee. Additionally, | ||
| 75 | // this type of scenario can only happen for match distances of up to 5 elements, because 2*log2(8) is 6, and we'll | ||
| 76 | // still be worse-off at position 5 of an 8-element set. From then onwards these scenarios can't happen. TL;DR: we'll be | ||
| 77 | // 1 comparison worse-off compared to the classic linear-searching algorithm if matching position 3 of a set with 4 | ||
| 78 | // elements, or position 5 if the set has 7 or 8 elements, but we'll never exceed the complexity guarantees from the | ||
| 79 | // standard. | ||
| 80 | template <class _AlgPolicy, | ||
| 81 | class _Compare, | ||
| 82 | class _InForwardIter1, | ||
| 83 | class _Sent1, | ||
| 84 | class _InForwardIter2, | ||
| 85 | class _Sent2, | ||
| 86 | class _OutIter> | ||
| 87 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | ||
| 88 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter> | ||
| 43 | __set_intersection( | 89 | __set_intersection( |
| 44 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { | 90 | _InForwardIter1 __first1, |
| 91 | _Sent1 __last1, | ||
| 92 | _InForwardIter2 __first2, | ||
| 93 | _Sent2 __last2, | ||
| 94 | _OutIter __result, | ||
| 95 | _Compare&& __comp, | ||
| 96 | std::forward_iterator_tag, | ||
| 97 | std::forward_iterator_tag) { | ||
| 98 | _LIBCPP_CONSTEXPR std::__identity __proj; | ||
| 99 | bool __prev_may_be_equal = false; | ||
| 100 | |||
| 101 | while (__first2 != __last2) { | ||
| 102 | _InForwardIter1 __first1_next = | ||
| 103 | std::__lower_bound_onesided<_AlgPolicy>(__first1, __last1, *__first2, __comp, __proj); | ||
| 104 | std::swap(__first1_next, __first1); | ||
| 105 | // keeping in mind that a==b iff !(a<b) && !(b<a): | ||
| 106 | // if we can't advance __first1, that means !(*__first1 < *_first2), therefore __may_be_equal==true | ||
| 107 | std::__set_intersection_add_output_if_equal( | ||
| 108 | __first1 == __first1_next, __first1, __first2, __result, __prev_may_be_equal); | ||
| 109 | if (__first1 == __last1) | ||
| 110 | break; | ||
| 111 | |||
| 112 | _InForwardIter2 __first2_next = | ||
| 113 | std::__lower_bound_onesided<_AlgPolicy>(__first2, __last2, *__first1, __comp, __proj); | ||
| 114 | std::swap(__first2_next, __first2); | ||
| 115 | std::__set_intersection_add_output_if_equal( | ||
| 116 | __first2 == __first2_next, __first1, __first2, __result, __prev_may_be_equal); | ||
| 117 | } | ||
| 118 | return __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter>( | ||
| 119 | _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)), | ||
| 120 | _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)), | ||
| 121 | std::move(__result)); | ||
| 122 | } | ||
| 123 | |||
| 124 | // input iterators are not suitable for multipass algorithms, so we stick to the classic single-pass version | ||
| 125 | template <class _AlgPolicy, | ||
| 126 | class _Compare, | ||
| 127 | class _InInputIter1, | ||
| 128 | class _Sent1, | ||
| 129 | class _InInputIter2, | ||
| 130 | class _Sent2, | ||
| 131 | class _OutIter> | ||
| 132 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | ||
| 133 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter> | ||
| 134 | __set_intersection( | ||
| 135 | _InInputIter1 __first1, | ||
| 136 | _Sent1 __last1, | ||
| 137 | _InInputIter2 __first2, | ||
| 138 | _Sent2 __last2, | ||
| 139 | _OutIter __result, | ||
| 140 | _Compare&& __comp, | ||
| 141 | std::input_iterator_tag, | ||
| 142 | std::input_iterator_tag) { | ||
| 45 | while (__first1 != __last1 && __first2 != __last2) { | 143 | while (__first1 != __last1 && __first2 != __last2) { |
| 46 | if (__comp(*__first1, *__first2)) | 144 | if (__comp(*__first1, *__first2)) |
| 47 | ++__first1; | 145 | ++__first1; |
| ... | @@ -55,12 +153,28 @@ __set_intersection( | ... | @@ -55,12 +153,28 @@ __set_intersection( |
| 55 | } | 153 | } |
| 56 | } | 154 | } |
| 57 | 155 | ||
| 58 | return __set_intersection_result<_InIter1, _InIter2, _OutIter>( | 156 | return __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>( |
| 59 | _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)), | 157 | _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)), |
| 60 | _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)), | 158 | _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)), |
| 61 | std::move(__result)); | 159 | std::move(__result)); |
| 62 | } | 160 | } |
| 63 | 161 | ||
| 162 | template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | ||
| 163 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | ||
| 164 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter> | ||
| 165 | __set_intersection( | ||
| 166 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { | ||
| 167 | return std::__set_intersection<_AlgPolicy>( | ||
| 168 | std::move(__first1), | ||
| 169 | std::move(__last1), | ||
| 170 | std::move(__first2), | ||
| 171 | std::move(__last2), | ||
| 172 | std::move(__result), | ||
| 173 | std::forward<_Compare>(__comp), | ||
| 174 | typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter1>(), | ||
| 175 | typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter2>()); | ||
| 176 | } | ||
| 177 | |||
| 64 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> | 178 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> |
| 65 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection( | 179 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection( |
| 66 | _InputIterator1 __first1, | 180 | _InputIterator1 __first1, |
lib/libcxx/include/__algorithm/simd_utils.h created+164| ... | @@ -0,0 +1,164 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_SIMD_UTILS_H | ||
| 10 | #define _LIBCPP___ALGORITHM_SIMD_UTILS_H | ||
| 11 | |||
| 12 | #include <__algorithm/min.h> | ||
| 13 | #include <__bit/bit_cast.h> | ||
| 14 | #include <__bit/countl.h> | ||
| 15 | #include <__bit/countr.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__type_traits/is_arithmetic.h> | ||
| 18 | #include <__type_traits/is_same.h> | ||
| 19 | #include <__utility/integer_sequence.h> | ||
| 20 | #include <cstddef> | ||
| 21 | #include <cstdint> | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 24 | # pragma GCC system_header | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_PUSH_MACROS | ||
| 28 | #include <__undef_macros> | ||
| 29 | |||
| 30 | // TODO: Find out how altivec changes things and allow vectorizations there too. | ||
| 31 | #if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__) | ||
| 32 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1 | ||
| 33 | #else | ||
| 34 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0 | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS && !defined(__OPTIMIZE_SIZE__) | ||
| 38 | # define _LIBCPP_VECTORIZE_ALGORITHMS 1 | ||
| 39 | #else | ||
| 40 | # define _LIBCPP_VECTORIZE_ALGORITHMS 0 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS | ||
| 44 | |||
| 45 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 46 | |||
| 47 | template <class _Tp> | ||
| 48 | inline constexpr bool __can_map_to_integer_v = | ||
| 49 | sizeof(_Tp) == alignof(_Tp) && (sizeof(_Tp) == 1 || sizeof(_Tp) == 2 || sizeof(_Tp) == 4 || sizeof(_Tp) == 8); | ||
| 50 | |||
| 51 | template <size_t _TypeSize> | ||
| 52 | struct __get_as_integer_type_impl; | ||
| 53 | |||
| 54 | template <> | ||
| 55 | struct __get_as_integer_type_impl<1> { | ||
| 56 | using type = uint8_t; | ||
| 57 | }; | ||
| 58 | |||
| 59 | template <> | ||
| 60 | struct __get_as_integer_type_impl<2> { | ||
| 61 | using type = uint16_t; | ||
| 62 | }; | ||
| 63 | template <> | ||
| 64 | struct __get_as_integer_type_impl<4> { | ||
| 65 | using type = uint32_t; | ||
| 66 | }; | ||
| 67 | template <> | ||
| 68 | struct __get_as_integer_type_impl<8> { | ||
| 69 | using type = uint64_t; | ||
| 70 | }; | ||
| 71 | |||
| 72 | template <class _Tp> | ||
| 73 | using __get_as_integer_type_t = typename __get_as_integer_type_impl<sizeof(_Tp)>::type; | ||
| 74 | |||
| 75 | // This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance | ||
| 76 | // in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms | ||
| 77 | // as far as benchmarks are concerned. | ||
| 78 | # if defined(__AVX__) || defined(__MVS__) | ||
| 79 | template <class _Tp> | ||
| 80 | inline constexpr size_t __native_vector_size = 32 / sizeof(_Tp); | ||
| 81 | # elif defined(__SSE__) || defined(__ARM_NEON__) | ||
| 82 | template <class _Tp> | ||
| 83 | inline constexpr size_t __native_vector_size = 16 / sizeof(_Tp); | ||
| 84 | # elif defined(__MMX__) | ||
| 85 | template <class _Tp> | ||
| 86 | inline constexpr size_t __native_vector_size = 8 / sizeof(_Tp); | ||
| 87 | # else | ||
| 88 | template <class _Tp> | ||
| 89 | inline constexpr size_t __native_vector_size = 1; | ||
| 90 | # endif | ||
| 91 | |||
| 92 | template <class _ArithmeticT, size_t _Np> | ||
| 93 | using __simd_vector __attribute__((__ext_vector_type__(_Np))) = _ArithmeticT; | ||
| 94 | |||
| 95 | template <class _VecT> | ||
| 96 | inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t { | ||
| 97 | static_assert(_False, "Not a vector!"); | ||
| 98 | }(); | ||
| 99 | |||
| 100 | template <class _Tp, size_t _Np> | ||
| 101 | inline constexpr size_t __simd_vector_size_v<__simd_vector<_Tp, _Np>> = _Np; | ||
| 102 | |||
| 103 | template <class _Tp, size_t _Np> | ||
| 104 | _LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp, _Np>) { | ||
| 105 | return _Tp{}; | ||
| 106 | } | ||
| 107 | |||
| 108 | template <class _VecT> | ||
| 109 | using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_type_impl(_VecT{})); | ||
| 110 | |||
| 111 | // This isn't inlined without always_inline when loading chars. | ||
| 112 | template <class _VecT, class _Iter> | ||
| 113 | _LIBCPP_NODISCARD _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept { | ||
| 114 | return [=]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE noexcept { | ||
| 115 | return _VecT{__iter[_Indices]...}; | ||
| 116 | }(make_index_sequence<__simd_vector_size_v<_VecT>>{}); | ||
| 117 | } | ||
| 118 | |||
| 119 | template <class _Tp, size_t _Np> | ||
| 120 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { | ||
| 121 | return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); | ||
| 122 | } | ||
| 123 | |||
| 124 | template <class _Tp, size_t _Np> | ||
| 125 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { | ||
| 126 | using __mask_vec = __simd_vector<bool, _Np>; | ||
| 127 | |||
| 128 | // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876 | ||
| 129 | auto __impl = [&]<class _MaskT>(_MaskT) _LIBCPP_NO_SANITIZE("memory") noexcept { | ||
| 130 | # if defined(_LIBCPP_BIG_ENDIAN) | ||
| 131 | return std::min<size_t>( | ||
| 132 | _Np, std::__countl_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec)))); | ||
| 133 | # else | ||
| 134 | return std::min<size_t>( | ||
| 135 | _Np, std::__countr_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec)))); | ||
| 136 | # endif | ||
| 137 | }; | ||
| 138 | |||
| 139 | if constexpr (sizeof(__mask_vec) == sizeof(uint8_t)) { | ||
| 140 | return __impl(uint8_t{}); | ||
| 141 | } else if constexpr (sizeof(__mask_vec) == sizeof(uint16_t)) { | ||
| 142 | return __impl(uint16_t{}); | ||
| 143 | } else if constexpr (sizeof(__mask_vec) == sizeof(uint32_t)) { | ||
| 144 | return __impl(uint32_t{}); | ||
| 145 | } else if constexpr (sizeof(__mask_vec) == sizeof(uint64_t)) { | ||
| 146 | return __impl(uint64_t{}); | ||
| 147 | } else { | ||
| 148 | static_assert(sizeof(__mask_vec) == 0, "unexpected required size for mask integer type"); | ||
| 149 | return 0; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | template <class _Tp, size_t _Np> | ||
| 154 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept { | ||
| 155 | return std::__find_first_set(~__vec); | ||
| 156 | } | ||
| 157 | |||
| 158 | _LIBCPP_END_NAMESPACE_STD | ||
| 159 | |||
| 160 | #endif // _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS | ||
| 161 | |||
| 162 | _LIBCPP_POP_MACROS | ||
| 163 | |||
| 164 | #endif // _LIBCPP___ALGORITHM_SIMD_UTILS_H | ||
lib/libcxx/include/__algorithm/sort.h+2-3| ... | @@ -696,9 +696,8 @@ __partition_with_equals_on_left(_RandomAccessIterator __first, _RandomAccessIter | ... | @@ -696,9 +696,8 @@ __partition_with_equals_on_left(_RandomAccessIterator __first, _RandomAccessIter |
| 696 | using _Ops = _IterOps<_AlgPolicy>; | 696 | using _Ops = _IterOps<_AlgPolicy>; |
| 697 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | 697 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 698 | typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type; | 698 | typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 699 | // TODO(LLVM18): Make __begin const, see https://reviews.llvm.org/D147089#4349748 | 699 | const _RandomAccessIterator __begin = __first; // used for bounds checking, those are not moved around |
| 700 | _RandomAccessIterator __begin = __first; // used for bounds checking, those are not moved around | 700 | const _RandomAccessIterator __end = __last; |
| 701 | const _RandomAccessIterator __end = __last; | ||
| 702 | (void)__end; // | 701 | (void)__end; // |
| 703 | value_type __pivot(_Ops::__iter_move(__first)); | 702 | value_type __pivot(_Ops::__iter_move(__first)); |
| 704 | if (__comp(__pivot, *(__last - difference_type(1)))) { | 703 | if (__comp(__pivot, *(__last - difference_type(1)))) { |
lib/libcxx/include/__algorithm/sort_heap.h+2-2| ... | @@ -16,8 +16,8 @@ | ... | @@ -16,8 +16,8 @@ |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__debug_utils/strict_weak_ordering_check.h> | 17 | #include <__debug_utils/strict_weak_ordering_check.h> |
| 18 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__type_traits/is_copy_assignable.h> | 19 | #include <__type_traits/is_assignable.h> |
| 20 | #include <__type_traits/is_copy_constructible.h> | 20 | #include <__type_traits/is_constructible.h> |
| 21 | #include <__utility/move.h> | 21 | #include <__utility/move.h> |
| 22 | 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__algorithm/stable_sort.h+1-1| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | #include <__memory/destruct_n.h> | 20 | #include <__memory/destruct_n.h> |
| 21 | #include <__memory/temporary_buffer.h> | 21 | #include <__memory/temporary_buffer.h> |
| 22 | #include <__memory/unique_ptr.h> | 22 | #include <__memory/unique_ptr.h> |
| 23 | #include <__type_traits/is_trivially_copy_assignable.h> | 23 | #include <__type_traits/is_trivially_assignable.h> |
| 24 | #include <__utility/move.h> | 24 | #include <__utility/move.h> |
| 25 | #include <__utility/pair.h> | 25 | #include <__utility/pair.h> |
| 26 | #include <new> | 26 | #include <new> |
lib/libcxx/include/__algorithm/unique.h+3-3| ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | // unique | 29 | // unique |
| 30 | 30 | ||
| 31 | template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate> | 31 | template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate> |
| 32 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter> | 32 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter> |
| 33 | __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | 33 | __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 34 | __first = std::__adjacent_find(__first, __last, __pred); | 34 | __first = std::__adjacent_find(__first, __last, __pred); |
| 35 | if (__first != __last) { | 35 | if (__first != __last) { |
| ... | @@ -46,13 +46,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | ... | @@ -46,13 +46,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | template <class _ForwardIterator, class _BinaryPredicate> | 48 | template <class _ForwardIterator, class _BinaryPredicate> |
| 49 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 49 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 50 | unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { | 50 | unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { |
| 51 | return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first; | 51 | return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | template <class _ForwardIterator> | 54 | template <class _ForwardIterator> |
| 55 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 55 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 56 | unique(_ForwardIterator __first, _ForwardIterator __last) { | 56 | unique(_ForwardIterator __first, _ForwardIterator __last) { |
| 57 | return std::unique(__first, __last, __equal_to()); | 57 | return std::unique(__first, __last, __equal_to()); |
| 58 | } | 58 | } |
lib/libcxx/include/__algorithm/unwrap_iter.h+1-1| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | #include <__iterator/iterator_traits.h> | 13 | #include <__iterator/iterator_traits.h> |
| 14 | #include <__memory/pointer_traits.h> | 14 | #include <__memory/pointer_traits.h> |
| 15 | #include <__type_traits/enable_if.h> | 15 | #include <__type_traits/enable_if.h> |
| 16 | #include <__type_traits/is_copy_constructible.h> | 16 | #include <__type_traits/is_constructible.h> |
| 17 | #include <__utility/declval.h> | 17 | #include <__utility/declval.h> |
| 18 | #include <__utility/move.h> | 18 | #include <__utility/move.h> |
| 19 | 19 |
lib/libcxx/include/__algorithm/upper_bound.h+3-3| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | #include <__iterator/advance.h> | 18 | #include <__iterator/advance.h> |
| 19 | #include <__iterator/distance.h> | 19 | #include <__iterator/distance.h> |
| 20 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__type_traits/is_copy_constructible.h> | 21 | #include <__type_traits/is_constructible.h> |
| 22 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 23 | 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -48,7 +48,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp | ... | @@ -48,7 +48,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | template <class _ForwardIterator, class _Tp, class _Compare> | 50 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 51 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 51 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 52 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | 52 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 53 | static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); | 53 | static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); |
| 54 | return std::__upper_bound<_ClassicAlgPolicy>( | 54 | return std::__upper_bound<_ClassicAlgPolicy>( |
| ... | @@ -56,7 +56,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu | ... | @@ -56,7 +56,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | template <class _ForwardIterator, class _Tp> | 58 | template <class _ForwardIterator, class _Tp> |
| 59 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 59 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 60 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 60 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 61 | return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>()); | 61 | return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>()); |
| 62 | } | 62 | } |
lib/libcxx/include/__assert+81| ... | @@ -34,4 +34,85 @@ | ... | @@ -34,4 +34,85 @@ |
| 34 | # define _LIBCPP_ASSUME(expression) ((void)0) | 34 | # define _LIBCPP_ASSUME(expression) ((void)0) |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | // clang-format off | ||
| 38 | // Fast hardening mode checks. | ||
| 39 | |||
| 40 | #if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST | ||
| 41 | |||
| 42 | // Enabled checks. | ||
| 43 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 44 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 45 | // Disabled checks. | ||
| 46 | // On most modern platforms, dereferencing a null pointer does not lead to an actual memory access. | ||
| 47 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 48 | // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security | ||
| 49 | // vulnerability. | ||
| 50 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) | ||
| 51 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression) | ||
| 52 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 53 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) | ||
| 54 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression) | ||
| 55 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression) | ||
| 56 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | ||
| 57 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 58 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) | ||
| 59 | |||
| 60 | // Extensive hardening mode checks. | ||
| 61 | |||
| 62 | #elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE | ||
| 63 | |||
| 64 | // Enabled checks. | ||
| 65 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 66 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 67 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 68 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 69 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 70 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 71 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 72 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 73 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 74 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 75 | // Disabled checks. | ||
| 76 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | ||
| 77 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 78 | |||
| 79 | // Debug hardening mode checks. | ||
| 80 | |||
| 81 | #elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | ||
| 82 | |||
| 83 | // All checks enabled. | ||
| 84 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 85 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 86 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 87 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 88 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 89 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 90 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 91 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 92 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 93 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 94 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 95 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 96 | |||
| 97 | // Disable all checks if hardening is not enabled. | ||
| 98 | |||
| 99 | #else | ||
| 100 | |||
| 101 | // All checks disabled. | ||
| 102 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression) | ||
| 103 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression) | ||
| 104 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 105 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) | ||
| 106 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression) | ||
| 107 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 108 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) | ||
| 109 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression) | ||
| 110 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression) | ||
| 111 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | ||
| 112 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 113 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) | ||
| 114 | |||
| 115 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST | ||
| 116 | // clang-format on | ||
| 117 | |||
| 37 | #endif // _LIBCPP___ASSERT | 118 | #endif // _LIBCPP___ASSERT |
lib/libcxx/include/__assertion_handler+11-2| ... | @@ -23,8 +23,17 @@ | ... | @@ -23,8 +23,17 @@ |
| 23 | 23 | ||
| 24 | #else | 24 | #else |
| 25 | 25 | ||
| 26 | // TODO(hardening): use `__builtin_verbose_trap(message)` once that becomes available. | 26 | # if __has_builtin(__builtin_verbose_trap) |
| 27 | # define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) | 27 | // AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream |
| 28 | // version before upstream Clang actually got the builtin. | ||
| 29 | # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 17000 | ||
| 30 | # define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message) | ||
| 31 | # else | ||
| 32 | # define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message) | ||
| 33 | # endif | ||
| 34 | # else | ||
| 35 | # define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) | ||
| 36 | # endif | ||
| 28 | 37 | ||
| 29 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | 38 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG |
| 30 | 39 |
lib/libcxx/include/__atomic/aliases.h+1-2| ... | @@ -18,7 +18,6 @@ | ... | @@ -18,7 +18,6 @@ |
| 18 | #include <__type_traits/make_unsigned.h> | 18 | #include <__type_traits/make_unsigned.h> |
| 19 | #include <cstddef> | 19 | #include <cstddef> |
| 20 | #include <cstdint> | 20 | #include <cstdint> |
| 21 | #include <cstdlib> | ||
| 22 | 21 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | # pragma GCC system_header | 23 | # pragma GCC system_header |
| ... | @@ -92,7 +91,7 @@ using __largest_lock_free_type = short; | ... | @@ -92,7 +91,7 @@ using __largest_lock_free_type = short; |
| 92 | # elif ATOMIC_CHAR_LOCK_FREE == 2 | 91 | # elif ATOMIC_CHAR_LOCK_FREE == 2 |
| 93 | using __largest_lock_free_type = char; | 92 | using __largest_lock_free_type = char; |
| 94 | # else | 93 | # else |
| 95 | # define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen in freestanding) | 94 | # define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms) |
| 96 | # endif | 95 | # endif |
| 97 | 96 | ||
| 98 | # ifndef _LIBCPP_NO_LOCK_FREE_TYPES | 97 | # ifndef _LIBCPP_NO_LOCK_FREE_TYPES |
lib/libcxx/include/__atomic/atomic.h+8-4| ... | @@ -462,22 +462,26 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __ | ... | @@ -462,22 +462,26 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __ |
| 462 | // atomic_notify_one | 462 | // atomic_notify_one |
| 463 | 463 | ||
| 464 | template <class _Tp> | 464 | template <class _Tp> |
| 465 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { | 465 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 466 | atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { | ||
| 466 | __o->notify_one(); | 467 | __o->notify_one(); |
| 467 | } | 468 | } |
| 468 | template <class _Tp> | 469 | template <class _Tp> |
| 469 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { | 470 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 471 | atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { | ||
| 470 | __o->notify_one(); | 472 | __o->notify_one(); |
| 471 | } | 473 | } |
| 472 | 474 | ||
| 473 | // atomic_notify_all | 475 | // atomic_notify_all |
| 474 | 476 | ||
| 475 | template <class _Tp> | 477 | template <class _Tp> |
| 476 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { | 478 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 479 | atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { | ||
| 477 | __o->notify_all(); | 480 | __o->notify_all(); |
| 478 | } | 481 | } |
| 479 | template <class _Tp> | 482 | template <class _Tp> |
| 480 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { | 483 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 484 | atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { | ||
| 481 | __o->notify_all(); | 485 | __o->notify_all(); |
| 482 | } | 486 | } |
| 483 | 487 |
lib/libcxx/include/__atomic/atomic_base.h+34-18| ... | @@ -14,11 +14,10 @@ | ... | @@ -14,11 +14,10 @@ |
| 14 | #include <__atomic/cxx_atomic_impl.h> | 14 | #include <__atomic/cxx_atomic_impl.h> |
| 15 | #include <__atomic/is_always_lock_free.h> | 15 | #include <__atomic/is_always_lock_free.h> |
| 16 | #include <__atomic/memory_order.h> | 16 | #include <__atomic/memory_order.h> |
| 17 | #include <__availability> | ||
| 18 | #include <__config> | 17 | #include <__config> |
| 19 | #include <__memory/addressof.h> | 18 | #include <__memory/addressof.h> |
| 20 | #include <__type_traits/is_integral.h> | 19 | #include <__type_traits/is_integral.h> |
| 21 | #include <__type_traits/is_nothrow_default_constructible.h> | 20 | #include <__type_traits/is_nothrow_constructible.h> |
| 22 | #include <__type_traits/is_same.h> | 21 | #include <__type_traits/is_same.h> |
| 23 | #include <version> | 22 | #include <version> |
| 24 | 23 | ||
| ... | @@ -34,7 +33,7 @@ struct __atomic_base // false | ... | @@ -34,7 +33,7 @@ struct __atomic_base // false |
| 34 | mutable __cxx_atomic_impl<_Tp> __a_; | 33 | mutable __cxx_atomic_impl<_Tp> __a_; |
| 35 | 34 | ||
| 36 | #if _LIBCPP_STD_VER >= 17 | 35 | #if _LIBCPP_STD_VER >= 17 |
| 37 | static _LIBCPP_CONSTEXPR bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; | 36 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; |
| 38 | #endif | 37 | #endif |
| 39 | 38 | ||
| 40 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT { | 39 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT { |
| ... | @@ -104,24 +103,20 @@ struct __atomic_base // false | ... | @@ -104,24 +103,20 @@ struct __atomic_base // false |
| 104 | 103 | ||
| 105 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const | 104 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const |
| 106 | volatile _NOEXCEPT { | 105 | volatile _NOEXCEPT { |
| 107 | std::__cxx_atomic_wait(std::addressof(__a_), __v, __m); | 106 | std::__atomic_wait(*this, __v, __m); |
| 108 | } | 107 | } |
| 109 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 108 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 110 | wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { | 109 | wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { |
| 111 | std::__cxx_atomic_wait(std::addressof(__a_), __v, __m); | 110 | std::__atomic_wait(*this, __v, __m); |
| 112 | } | 111 | } |
| 113 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | 112 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { |
| 114 | std::__cxx_atomic_notify_one(std::addressof(__a_)); | 113 | std::__atomic_notify_one(*this); |
| 115 | } | ||
| 116 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { | ||
| 117 | std::__cxx_atomic_notify_one(std::addressof(__a_)); | ||
| 118 | } | 114 | } |
| 115 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } | ||
| 119 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { | 116 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { |
| 120 | std::__cxx_atomic_notify_all(std::addressof(__a_)); | 117 | std::__atomic_notify_all(*this); |
| 121 | } | ||
| 122 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { | ||
| 123 | std::__cxx_atomic_notify_all(std::addressof(__a_)); | ||
| 124 | } | 118 | } |
| 119 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } | ||
| 125 | 120 | ||
| 126 | #if _LIBCPP_STD_VER >= 20 | 121 | #if _LIBCPP_STD_VER >= 20 |
| 127 | _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {} | 122 | _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {} |
| ... | @@ -134,11 +129,6 @@ struct __atomic_base // false | ... | @@ -134,11 +129,6 @@ struct __atomic_base // false |
| 134 | __atomic_base(const __atomic_base&) = delete; | 129 | __atomic_base(const __atomic_base&) = delete; |
| 135 | }; | 130 | }; |
| 136 | 131 | ||
| 137 | #if _LIBCPP_STD_VER >= 17 | ||
| 138 | template <class _Tp, bool __b> | ||
| 139 | _LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free; | ||
| 140 | #endif | ||
| 141 | |||
| 142 | // atomic<Integral> | 132 | // atomic<Integral> |
| 143 | 133 | ||
| 144 | template <class _Tp> | 134 | template <class _Tp> |
| ... | @@ -200,6 +190,32 @@ struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { | ... | @@ -200,6 +190,32 @@ struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { |
| 200 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; } | 190 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; } |
| 201 | }; | 191 | }; |
| 202 | 192 | ||
| 193 | // Here we need _IsIntegral because the default template argument is not enough | ||
| 194 | // e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from | ||
| 195 | // __atomic_base<int, false> and the caller of the wait function is | ||
| 196 | // __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work | ||
| 197 | template <class _Tp, bool _IsIntegral> | ||
| 198 | struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { | ||
| 199 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) { | ||
| 200 | return __a.load(__order); | ||
| 201 | } | ||
| 202 | |||
| 203 | static _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 204 | __atomic_load(const volatile __atomic_base<_Tp, _IsIntegral>& __this, memory_order __order) { | ||
| 205 | return __this.load(__order); | ||
| 206 | } | ||
| 207 | |||
| 208 | static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_Tp>* | ||
| 209 | __atomic_contention_address(const __atomic_base<_Tp, _IsIntegral>& __a) { | ||
| 210 | return std::addressof(__a.__a_); | ||
| 211 | } | ||
| 212 | |||
| 213 | static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_Tp>* | ||
| 214 | __atomic_contention_address(const volatile __atomic_base<_Tp, _IsIntegral>& __this) { | ||
| 215 | return std::addressof(__this.__a_); | ||
| 216 | } | ||
| 217 | }; | ||
| 218 | |||
| 203 | _LIBCPP_END_NAMESPACE_STD | 219 | _LIBCPP_END_NAMESPACE_STD |
| 204 | 220 | ||
| 205 | #endif // _LIBCPP___ATOMIC_ATOMIC_BASE_H | 221 | #endif // _LIBCPP___ATOMIC_ATOMIC_BASE_H |
lib/libcxx/include/__atomic/atomic_flag.h+48-19| ... | @@ -15,7 +15,8 @@ | ... | @@ -15,7 +15,8 @@ |
| 15 | #include <__atomic/memory_order.h> | 15 | #include <__atomic/memory_order.h> |
| 16 | #include <__chrono/duration.h> | 16 | #include <__chrono/duration.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__threading_support> | 18 | #include <__memory/addressof.h> |
| 19 | #include <__thread/support.h> | ||
| 19 | #include <cstdint> | 20 | #include <cstdint> |
| 20 | 21 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -47,22 +48,26 @@ struct atomic_flag { | ... | @@ -47,22 +48,26 @@ struct atomic_flag { |
| 47 | __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m); | 48 | __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m); |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const | 51 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 51 | volatile _NOEXCEPT { | 52 | wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT { |
| 52 | __cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); | 53 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); |
| 53 | } | 54 | } |
| 54 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 55 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 55 | wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { | 56 | wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { |
| 56 | __cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); | 57 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); |
| 57 | } | 58 | } |
| 58 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | 59 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { |
| 59 | __cxx_atomic_notify_one(&__a_); | 60 | std::__atomic_notify_one(*this); |
| 61 | } | ||
| 62 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { | ||
| 63 | std::__atomic_notify_one(*this); | ||
| 60 | } | 64 | } |
| 61 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { __cxx_atomic_notify_one(&__a_); } | ||
| 62 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { | 65 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { |
| 63 | __cxx_atomic_notify_all(&__a_); | 66 | std::__atomic_notify_all(*this); |
| 67 | } | ||
| 68 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { | ||
| 69 | std::__atomic_notify_all(*this); | ||
| 64 | } | 70 | } |
| 65 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { __cxx_atomic_notify_all(&__a_); } | ||
| 66 | 71 | ||
| 67 | #if _LIBCPP_STD_VER >= 20 | 72 | #if _LIBCPP_STD_VER >= 20 |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {} | 73 | _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {} |
| ... | @@ -77,6 +82,28 @@ struct atomic_flag { | ... | @@ -77,6 +82,28 @@ struct atomic_flag { |
| 77 | atomic_flag& operator=(const atomic_flag&) volatile = delete; | 82 | atomic_flag& operator=(const atomic_flag&) volatile = delete; |
| 78 | }; | 83 | }; |
| 79 | 84 | ||
| 85 | template <> | ||
| 86 | struct __atomic_waitable_traits<atomic_flag> { | ||
| 87 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE __atomic_load(const atomic_flag& __a, memory_order __order) { | ||
| 88 | return std::__cxx_atomic_load(&__a.__a_, __order); | ||
| 89 | } | ||
| 90 | |||
| 91 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE | ||
| 92 | __atomic_load(const volatile atomic_flag& __a, memory_order __order) { | ||
| 93 | return std::__cxx_atomic_load(&__a.__a_, __order); | ||
| 94 | } | ||
| 95 | |||
| 96 | static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE>* | ||
| 97 | __atomic_contention_address(const atomic_flag& __a) { | ||
| 98 | return std::addressof(__a.__a_); | ||
| 99 | } | ||
| 100 | |||
| 101 | static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE>* | ||
| 102 | __atomic_contention_address(const volatile atomic_flag& __a) { | ||
| 103 | return std::addressof(__a.__a_); | ||
| 104 | } | ||
| 105 | }; | ||
| 106 | |||
| 80 | inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT { return __o->test(); } | 107 | inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT { return __o->test(); } |
| 81 | 108 | ||
| 82 | inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const atomic_flag* __o) _NOEXCEPT { return __o->test(); } | 109 | inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const atomic_flag* __o) _NOEXCEPT { return __o->test(); } |
| ... | @@ -117,41 +144,43 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m | ... | @@ -117,41 +144,43 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m |
| 117 | __o->clear(__m); | 144 | __o->clear(__m); |
| 118 | } | 145 | } |
| 119 | 146 | ||
| 120 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 147 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 121 | atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT { | 148 | atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT { |
| 122 | __o->wait(__v); | 149 | __o->wait(__v); |
| 123 | } | 150 | } |
| 124 | 151 | ||
| 125 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 152 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 126 | atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT { | 153 | atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT { |
| 127 | __o->wait(__v); | 154 | __o->wait(__v); |
| 128 | } | 155 | } |
| 129 | 156 | ||
| 130 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 157 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 131 | atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { | 158 | atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { |
| 132 | __o->wait(__v, __m); | 159 | __o->wait(__v, __m); |
| 133 | } | 160 | } |
| 134 | 161 | ||
| 135 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 162 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 136 | atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { | 163 | atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { |
| 137 | __o->wait(__v, __m); | 164 | __o->wait(__v, __m); |
| 138 | } | 165 | } |
| 139 | 166 | ||
| 140 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 167 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 141 | atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT { | 168 | atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT { |
| 142 | __o->notify_one(); | 169 | __o->notify_one(); |
| 143 | } | 170 | } |
| 144 | 171 | ||
| 145 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { | 172 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 173 | atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { | ||
| 146 | __o->notify_one(); | 174 | __o->notify_one(); |
| 147 | } | 175 | } |
| 148 | 176 | ||
| 149 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 177 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 150 | atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT { | 178 | atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT { |
| 151 | __o->notify_all(); | 179 | __o->notify_all(); |
| 152 | } | 180 | } |
| 153 | 181 | ||
| 154 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { | 182 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void |
| 183 | atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { | ||
| 155 | __o->notify_all(); | 184 | __o->notify_all(); |
| 156 | } | 185 | } |
| 157 | 186 |
lib/libcxx/include/__atomic/atomic_init.h+3-5| ... | @@ -15,12 +15,10 @@ | ... | @@ -15,12 +15,10 @@ |
| 15 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #define ATOMIC_FLAG_INIT \ | 18 | #define ATOMIC_FLAG_INIT {false} |
| 19 | { false } | 19 | #define ATOMIC_VAR_INIT(__v) {__v} |
| 20 | #define ATOMIC_VAR_INIT(__v) \ | ||
| 21 | { __v } | ||
| 22 | 20 | ||
| 23 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | 21 | #if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) |
| 24 | # pragma clang deprecated(ATOMIC_VAR_INIT) | 22 | # pragma clang deprecated(ATOMIC_VAR_INIT) |
| 25 | #endif | 23 | #endif |
| 26 | 24 |
lib/libcxx/include/__atomic/atomic_ref.h created+378| ... | @@ -0,0 +1,378 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | // Kokkos v. 4.0 | ||
| 9 | // Copyright (2022) National Technology & Engineering | ||
| 10 | // Solutions of Sandia, LLC (NTESS). | ||
| 11 | // | ||
| 12 | // Under the terms of Contract DE-NA0003525 with NTESS, | ||
| 13 | // the U.S. Government retains certain rights in this software. | ||
| 14 | // | ||
| 15 | //===---------------------------------------------------------------------===// | ||
| 16 | |||
| 17 | #ifndef _LIBCPP___ATOMIC_ATOMIC_REF_H | ||
| 18 | #define _LIBCPP___ATOMIC_ATOMIC_REF_H | ||
| 19 | |||
| 20 | #include <__assert> | ||
| 21 | #include <__atomic/atomic_sync.h> | ||
| 22 | #include <__atomic/check_memory_order.h> | ||
| 23 | #include <__atomic/to_gcc_order.h> | ||
| 24 | #include <__concepts/arithmetic.h> | ||
| 25 | #include <__concepts/same_as.h> | ||
| 26 | #include <__config> | ||
| 27 | #include <__memory/addressof.h> | ||
| 28 | #include <__type_traits/has_unique_object_representation.h> | ||
| 29 | #include <__type_traits/is_trivially_copyable.h> | ||
| 30 | #include <cstddef> | ||
| 31 | #include <cstdint> | ||
| 32 | #include <cstring> | ||
| 33 | |||
| 34 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 35 | # pragma GCC system_header | ||
| 36 | #endif | ||
| 37 | |||
| 38 | _LIBCPP_PUSH_MACROS | ||
| 39 | #include <__undef_macros> | ||
| 40 | |||
| 41 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 42 | |||
| 43 | #if _LIBCPP_STD_VER >= 20 | ||
| 44 | |||
| 45 | // These types are required to make __atomic_is_always_lock_free work across GCC and Clang. | ||
| 46 | // The purpose of this trick is to make sure that we provide an object with the correct alignment | ||
| 47 | // to __atomic_is_always_lock_free, since that answer depends on the alignment. | ||
| 48 | template <size_t _Alignment> | ||
| 49 | struct __alignment_checker_type { | ||
| 50 | alignas(_Alignment) char __data; | ||
| 51 | }; | ||
| 52 | |||
| 53 | template <size_t _Alignment> | ||
| 54 | struct __get_aligner_instance { | ||
| 55 | static constexpr __alignment_checker_type<_Alignment> __instance{}; | ||
| 56 | }; | ||
| 57 | |||
| 58 | template <class _Tp> | ||
| 59 | struct __atomic_ref_base { | ||
| 60 | private: | ||
| 61 | _LIBCPP_HIDE_FROM_ABI static _Tp* __clear_padding(_Tp& __val) noexcept { | ||
| 62 | _Tp* __ptr = std::addressof(__val); | ||
| 63 | # if __has_builtin(__builtin_clear_padding) | ||
| 64 | __builtin_clear_padding(__ptr); | ||
| 65 | # endif | ||
| 66 | return __ptr; | ||
| 67 | } | ||
| 68 | |||
| 69 | _LIBCPP_HIDE_FROM_ABI static bool __compare_exchange( | ||
| 70 | _Tp* __ptr, _Tp* __expected, _Tp* __desired, bool __is_weak, int __success, int __failure) noexcept { | ||
| 71 | if constexpr ( | ||
| 72 | # if __has_builtin(__builtin_clear_padding) | ||
| 73 | has_unique_object_representations_v<_Tp> || floating_point<_Tp> | ||
| 74 | # else | ||
| 75 | true // NOLINT(readability-simplify-boolean-expr) | ||
| 76 | # endif | ||
| 77 | ) { | ||
| 78 | return __atomic_compare_exchange(__ptr, __expected, __desired, __is_weak, __success, __failure); | ||
| 79 | } else { // _Tp has padding bits and __builtin_clear_padding is available | ||
| 80 | __clear_padding(*__desired); | ||
| 81 | _Tp __copy = *__expected; | ||
| 82 | __clear_padding(__copy); | ||
| 83 | // The algorithm we use here is basically to perform `__atomic_compare_exchange` on the | ||
| 84 | // values until it has either succeeded, or failed because the value representation of the | ||
| 85 | // objects involved was different. This is why we loop around __atomic_compare_exchange: | ||
| 86 | // we basically loop until its failure is caused by the value representation of the objects | ||
| 87 | // being different, not only their object representation. | ||
| 88 | while (true) { | ||
| 89 | _Tp __prev = __copy; | ||
| 90 | if (__atomic_compare_exchange(__ptr, std::addressof(__copy), __desired, __is_weak, __success, __failure)) { | ||
| 91 | return true; | ||
| 92 | } | ||
| 93 | _Tp __curr = __copy; | ||
| 94 | if (std::memcmp(__clear_padding(__prev), __clear_padding(__curr), sizeof(_Tp)) != 0) { | ||
| 95 | // Value representation without padding bits do not compare equal -> | ||
| 96 | // write the current content of *ptr into *expected | ||
| 97 | std::memcpy(__expected, std::addressof(__copy), sizeof(_Tp)); | ||
| 98 | return false; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | friend struct __atomic_waitable_traits<__atomic_ref_base<_Tp>>; | ||
| 105 | |||
| 106 | // require types that are 1, 2, 4, 8, or 16 bytes in length to be aligned to at least their size to be potentially | ||
| 107 | // used lock-free | ||
| 108 | static constexpr size_t __min_alignment = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || (sizeof(_Tp) > 16) ? 0 : sizeof(_Tp); | ||
| 109 | |||
| 110 | public: | ||
| 111 | using value_type = _Tp; | ||
| 112 | |||
| 113 | static constexpr size_t required_alignment = alignof(_Tp) > __min_alignment ? alignof(_Tp) : __min_alignment; | ||
| 114 | |||
| 115 | // The __atomic_always_lock_free builtin takes into account the alignment of the pointer if provided, | ||
| 116 | // so we create a fake pointer with a suitable alignment when querying it. Note that we are guaranteed | ||
| 117 | // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition | ||
| 118 | // of atomic_ref's constructor. | ||
| 119 | static constexpr bool is_always_lock_free = | ||
| 120 | __atomic_always_lock_free(sizeof(_Tp), &__get_aligner_instance<required_alignment>::__instance); | ||
| 121 | |||
| 122 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); } | ||
| 123 | |||
| 124 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept | ||
| 125 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__order) { | ||
| 126 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 127 | __order == memory_order::relaxed || __order == memory_order::release || __order == memory_order::seq_cst, | ||
| 128 | "atomic_ref: memory order argument to atomic store operation is invalid"); | ||
| 129 | __atomic_store(__ptr_, __clear_padding(__desired), std::__to_gcc_order(__order)); | ||
| 130 | } | ||
| 131 | |||
| 132 | _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { | ||
| 133 | store(__desired); | ||
| 134 | return __desired; | ||
| 135 | } | ||
| 136 | |||
| 137 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __order = memory_order::seq_cst) const noexcept | ||
| 138 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__order) { | ||
| 139 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 140 | __order == memory_order::relaxed || __order == memory_order::consume || __order == memory_order::acquire || | ||
| 141 | __order == memory_order::seq_cst, | ||
| 142 | "atomic_ref: memory order argument to atomic load operation is invalid"); | ||
| 143 | alignas(_Tp) byte __mem[sizeof(_Tp)]; | ||
| 144 | auto* __ret = reinterpret_cast<_Tp*>(__mem); | ||
| 145 | __atomic_load(__ptr_, __ret, std::__to_gcc_order(__order)); | ||
| 146 | return *__ret; | ||
| 147 | } | ||
| 148 | |||
| 149 | _LIBCPP_HIDE_FROM_ABI operator _Tp() const noexcept { return load(); } | ||
| 150 | |||
| 151 | _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept { | ||
| 152 | alignas(_Tp) byte __mem[sizeof(_Tp)]; | ||
| 153 | auto* __ret = reinterpret_cast<_Tp*>(__mem); | ||
| 154 | __atomic_exchange(__ptr_, __clear_padding(__desired), __ret, std::__to_gcc_order(__order)); | ||
| 155 | return *__ret; | ||
| 156 | } | ||
| 157 | |||
| 158 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 159 | compare_exchange_weak(_Tp& __expected, _Tp __desired, memory_order __success, memory_order __failure) const noexcept | ||
| 160 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__success, __failure) { | ||
| 161 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 162 | __failure == memory_order::relaxed || __failure == memory_order::consume || | ||
| 163 | __failure == memory_order::acquire || __failure == memory_order::seq_cst, | ||
| 164 | "atomic_ref: failure memory order argument to weak atomic compare-and-exchange operation is invalid"); | ||
| 165 | return __compare_exchange( | ||
| 166 | __ptr_, | ||
| 167 | std::addressof(__expected), | ||
| 168 | std::addressof(__desired), | ||
| 169 | true, | ||
| 170 | std::__to_gcc_order(__success), | ||
| 171 | std::__to_gcc_order(__failure)); | ||
| 172 | } | ||
| 173 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 174 | compare_exchange_strong(_Tp& __expected, _Tp __desired, memory_order __success, memory_order __failure) const noexcept | ||
| 175 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__success, __failure) { | ||
| 176 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 177 | __failure == memory_order::relaxed || __failure == memory_order::consume || | ||
| 178 | __failure == memory_order::acquire || __failure == memory_order::seq_cst, | ||
| 179 | "atomic_ref: failure memory order argument to strong atomic compare-and-exchange operation is invalid"); | ||
| 180 | return __compare_exchange( | ||
| 181 | __ptr_, | ||
| 182 | std::addressof(__expected), | ||
| 183 | std::addressof(__desired), | ||
| 184 | false, | ||
| 185 | std::__to_gcc_order(__success), | ||
| 186 | std::__to_gcc_order(__failure)); | ||
| 187 | } | ||
| 188 | |||
| 189 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 190 | compare_exchange_weak(_Tp& __expected, _Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept { | ||
| 191 | return __compare_exchange( | ||
| 192 | __ptr_, | ||
| 193 | std::addressof(__expected), | ||
| 194 | std::addressof(__desired), | ||
| 195 | true, | ||
| 196 | std::__to_gcc_order(__order), | ||
| 197 | std::__to_gcc_failure_order(__order)); | ||
| 198 | } | ||
| 199 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 200 | compare_exchange_strong(_Tp& __expected, _Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept { | ||
| 201 | return __compare_exchange( | ||
| 202 | __ptr_, | ||
| 203 | std::addressof(__expected), | ||
| 204 | std::addressof(__desired), | ||
| 205 | false, | ||
| 206 | std::__to_gcc_order(__order), | ||
| 207 | std::__to_gcc_failure_order(__order)); | ||
| 208 | } | ||
| 209 | |||
| 210 | _LIBCPP_HIDE_FROM_ABI void wait(_Tp __old, memory_order __order = memory_order::seq_cst) const noexcept | ||
| 211 | _LIBCPP_CHECK_WAIT_MEMORY_ORDER(__order) { | ||
| 212 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 213 | __order == memory_order::relaxed || __order == memory_order::consume || __order == memory_order::acquire || | ||
| 214 | __order == memory_order::seq_cst, | ||
| 215 | "atomic_ref: memory order argument to atomic wait operation is invalid"); | ||
| 216 | std::__atomic_wait(*this, __old, __order); | ||
| 217 | } | ||
| 218 | _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { std::__atomic_notify_one(*this); } | ||
| 219 | _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); } | ||
| 220 | |||
| 221 | protected: | ||
| 222 | typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment))); | ||
| 223 | _Aligned_Tp* __ptr_; | ||
| 224 | |||
| 225 | _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {} | ||
| 226 | }; | ||
| 227 | |||
| 228 | template <class _Tp> | ||
| 229 | struct __atomic_waitable_traits<__atomic_ref_base<_Tp>> { | ||
| 230 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_ref_base<_Tp>& __a, memory_order __order) { | ||
| 231 | return __a.load(__order); | ||
| 232 | } | ||
| 233 | static _LIBCPP_HIDE_FROM_ABI const _Tp* __atomic_contention_address(const __atomic_ref_base<_Tp>& __a) { | ||
| 234 | return __a.__ptr_; | ||
| 235 | } | ||
| 236 | }; | ||
| 237 | |||
| 238 | template <class _Tp> | ||
| 239 | struct atomic_ref : public __atomic_ref_base<_Tp> { | ||
| 240 | static_assert(is_trivially_copyable_v<_Tp>, "std::atomic_ref<T> requires that 'T' be a trivially copyable type"); | ||
| 241 | |||
| 242 | using __base = __atomic_ref_base<_Tp>; | ||
| 243 | |||
| 244 | _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) { | ||
| 245 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 246 | reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0, | ||
| 247 | "atomic_ref ctor: referenced object must be aligned to required_alignment"); | ||
| 248 | } | ||
| 249 | |||
| 250 | _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default; | ||
| 251 | |||
| 252 | _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); } | ||
| 253 | |||
| 254 | atomic_ref& operator=(const atomic_ref&) = delete; | ||
| 255 | }; | ||
| 256 | |||
| 257 | template <class _Tp> | ||
| 258 | requires(std::integral<_Tp> && !std::same_as<bool, _Tp>) | ||
| 259 | struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { | ||
| 260 | using __base = __atomic_ref_base<_Tp>; | ||
| 261 | |||
| 262 | using difference_type = __base::value_type; | ||
| 263 | |||
| 264 | _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) { | ||
| 265 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 266 | reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0, | ||
| 267 | "atomic_ref ctor: referenced object must be aligned to required_alignment"); | ||
| 268 | } | ||
| 269 | |||
| 270 | _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default; | ||
| 271 | |||
| 272 | _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); } | ||
| 273 | |||
| 274 | atomic_ref& operator=(const atomic_ref&) = delete; | ||
| 275 | |||
| 276 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 277 | return __atomic_fetch_add(this->__ptr_, __arg, std::__to_gcc_order(__order)); | ||
| 278 | } | ||
| 279 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 280 | return __atomic_fetch_sub(this->__ptr_, __arg, std::__to_gcc_order(__order)); | ||
| 281 | } | ||
| 282 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 283 | return __atomic_fetch_and(this->__ptr_, __arg, std::__to_gcc_order(__order)); | ||
| 284 | } | ||
| 285 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 286 | return __atomic_fetch_or(this->__ptr_, __arg, std::__to_gcc_order(__order)); | ||
| 287 | } | ||
| 288 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 289 | return __atomic_fetch_xor(this->__ptr_, __arg, std::__to_gcc_order(__order)); | ||
| 290 | } | ||
| 291 | |||
| 292 | _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) const noexcept { return fetch_add(_Tp(1)); } | ||
| 293 | _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) const noexcept { return fetch_sub(_Tp(1)); } | ||
| 294 | _LIBCPP_HIDE_FROM_ABI _Tp operator++() const noexcept { return fetch_add(_Tp(1)) + _Tp(1); } | ||
| 295 | _LIBCPP_HIDE_FROM_ABI _Tp operator--() const noexcept { return fetch_sub(_Tp(1)) - _Tp(1); } | ||
| 296 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __arg) const noexcept { return fetch_add(__arg) + __arg; } | ||
| 297 | _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __arg) const noexcept { return fetch_sub(__arg) - __arg; } | ||
| 298 | _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __arg) const noexcept { return fetch_and(__arg) & __arg; } | ||
| 299 | _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __arg) const noexcept { return fetch_or(__arg) | __arg; } | ||
| 300 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __arg) const noexcept { return fetch_xor(__arg) ^ __arg; } | ||
| 301 | }; | ||
| 302 | |||
| 303 | template <class _Tp> | ||
| 304 | requires std::floating_point<_Tp> | ||
| 305 | struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { | ||
| 306 | using __base = __atomic_ref_base<_Tp>; | ||
| 307 | |||
| 308 | using difference_type = __base::value_type; | ||
| 309 | |||
| 310 | _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) { | ||
| 311 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 312 | reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0, | ||
| 313 | "atomic_ref ctor: referenced object must be aligned to required_alignment"); | ||
| 314 | } | ||
| 315 | |||
| 316 | _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default; | ||
| 317 | |||
| 318 | _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); } | ||
| 319 | |||
| 320 | atomic_ref& operator=(const atomic_ref&) = delete; | ||
| 321 | |||
| 322 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 323 | _Tp __old = this->load(memory_order_relaxed); | ||
| 324 | _Tp __new = __old + __arg; | ||
| 325 | while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) { | ||
| 326 | __new = __old + __arg; | ||
| 327 | } | ||
| 328 | return __old; | ||
| 329 | } | ||
| 330 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 331 | _Tp __old = this->load(memory_order_relaxed); | ||
| 332 | _Tp __new = __old - __arg; | ||
| 333 | while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) { | ||
| 334 | __new = __old - __arg; | ||
| 335 | } | ||
| 336 | return __old; | ||
| 337 | } | ||
| 338 | |||
| 339 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __arg) const noexcept { return fetch_add(__arg) + __arg; } | ||
| 340 | _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __arg) const noexcept { return fetch_sub(__arg) - __arg; } | ||
| 341 | }; | ||
| 342 | |||
| 343 | template <class _Tp> | ||
| 344 | struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> { | ||
| 345 | using __base = __atomic_ref_base<_Tp*>; | ||
| 346 | |||
| 347 | using difference_type = ptrdiff_t; | ||
| 348 | |||
| 349 | _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp*& __ptr) : __base(__ptr) {} | ||
| 350 | |||
| 351 | _LIBCPP_HIDE_FROM_ABI _Tp* operator=(_Tp* __desired) const noexcept { return __base::operator=(__desired); } | ||
| 352 | |||
| 353 | atomic_ref& operator=(const atomic_ref&) = delete; | ||
| 354 | |||
| 355 | _LIBCPP_HIDE_FROM_ABI _Tp* fetch_add(ptrdiff_t __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 356 | return __atomic_fetch_add(this->__ptr_, __arg * sizeof(_Tp), std::__to_gcc_order(__order)); | ||
| 357 | } | ||
| 358 | _LIBCPP_HIDE_FROM_ABI _Tp* fetch_sub(ptrdiff_t __arg, memory_order __order = memory_order_seq_cst) const noexcept { | ||
| 359 | return __atomic_fetch_sub(this->__ptr_, __arg * sizeof(_Tp), std::__to_gcc_order(__order)); | ||
| 360 | } | ||
| 361 | |||
| 362 | _LIBCPP_HIDE_FROM_ABI _Tp* operator++(int) const noexcept { return fetch_add(1); } | ||
| 363 | _LIBCPP_HIDE_FROM_ABI _Tp* operator--(int) const noexcept { return fetch_sub(1); } | ||
| 364 | _LIBCPP_HIDE_FROM_ABI _Tp* operator++() const noexcept { return fetch_add(1) + 1; } | ||
| 365 | _LIBCPP_HIDE_FROM_ABI _Tp* operator--() const noexcept { return fetch_sub(1) - 1; } | ||
| 366 | _LIBCPP_HIDE_FROM_ABI _Tp* operator+=(ptrdiff_t __arg) const noexcept { return fetch_add(__arg) + __arg; } | ||
| 367 | _LIBCPP_HIDE_FROM_ABI _Tp* operator-=(ptrdiff_t __arg) const noexcept { return fetch_sub(__arg) - __arg; } | ||
| 368 | }; | ||
| 369 | |||
| 370 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(atomic_ref); | ||
| 371 | |||
| 372 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 373 | |||
| 374 | _LIBCPP_END_NAMESPACE_STD | ||
| 375 | |||
| 376 | _LIBCPP_POP_MACROS | ||
| 377 | |||
| 378 | #endif // _LIBCPP__ATOMIC_ATOMIC_REF_H | ||
lib/libcxx/include/__atomic/atomic_sync.h+137-40| ... | @@ -12,13 +12,17 @@ | ... | @@ -12,13 +12,17 @@ |
| 12 | #include <__atomic/contention_t.h> | 12 | #include <__atomic/contention_t.h> |
| 13 | #include <__atomic/cxx_atomic_impl.h> | 13 | #include <__atomic/cxx_atomic_impl.h> |
| 14 | #include <__atomic/memory_order.h> | 14 | #include <__atomic/memory_order.h> |
| 15 | #include <__availability> | 15 | #include <__atomic/to_gcc_order.h> |
| 16 | #include <__chrono/duration.h> | 16 | #include <__chrono/duration.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__memory/addressof.h> | 18 | #include <__memory/addressof.h> |
| 19 | #include <__thread/poll_with_backoff.h> | 19 | #include <__thread/poll_with_backoff.h> |
| 20 | #include <__threading_support> | 20 | #include <__thread/support.h> |
| 21 | #include <__type_traits/conjunction.h> | ||
| 21 | #include <__type_traits/decay.h> | 22 | #include <__type_traits/decay.h> |
| 23 | #include <__type_traits/invoke.h> | ||
| 24 | #include <__type_traits/void_t.h> | ||
| 25 | #include <__utility/declval.h> | ||
| 22 | #include <cstring> | 26 | #include <cstring> |
| 23 | 27 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -27,33 +31,101 @@ | ... | @@ -27,33 +31,101 @@ |
| 27 | 31 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 33 | ||
| 34 | // The customisation points to enable the following functions: | ||
| 35 | // - __atomic_wait | ||
| 36 | // - __atomic_wait_unless | ||
| 37 | // - __atomic_notify_one | ||
| 38 | // - __atomic_notify_all | ||
| 39 | // Note that std::atomic<T>::wait was back-ported to C++03 | ||
| 40 | // The below implementations look ugly to support C++03 | ||
| 41 | template <class _Tp, class = void> | ||
| 42 | struct __atomic_waitable_traits { | ||
| 43 | template <class _AtomicWaitable> | ||
| 44 | static void __atomic_load(_AtomicWaitable&&, memory_order) = delete; | ||
| 45 | |||
| 46 | template <class _AtomicWaitable> | ||
| 47 | static void __atomic_contention_address(_AtomicWaitable&&) = delete; | ||
| 48 | }; | ||
| 49 | |||
| 50 | template <class _Tp, class = void> | ||
| 51 | struct __atomic_waitable : false_type {}; | ||
| 52 | |||
| 53 | template <class _Tp> | ||
| 54 | struct __atomic_waitable< _Tp, | ||
| 55 | __void_t<decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_load( | ||
| 56 | std::declval<const _Tp&>(), std::declval<memory_order>())), | ||
| 57 | decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address( | ||
| 58 | std::declval<const _Tp&>()))> > : true_type {}; | ||
| 59 | |||
| 60 | template <class _AtomicWaitable, class _Poll> | ||
| 61 | struct __atomic_wait_poll_impl { | ||
| 62 | const _AtomicWaitable& __a_; | ||
| 63 | _Poll __poll_; | ||
| 64 | memory_order __order_; | ||
| 65 | |||
| 66 | _LIBCPP_HIDE_FROM_ABI bool operator()() const { | ||
| 67 | auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a_, __order_); | ||
| 68 | return __poll_(__current_val); | ||
| 69 | } | ||
| 70 | }; | ||
| 71 | |||
| 30 | #ifndef _LIBCPP_HAS_NO_THREADS | 72 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 31 | 73 | ||
| 32 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*); | 74 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT; |
| 33 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*); | 75 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT; |
| 34 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile*); | 76 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t |
| 35 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile*, __cxx_contention_t); | 77 | __libcpp_atomic_monitor(void const volatile*) _NOEXCEPT; |
| 78 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | ||
| 79 | __libcpp_atomic_wait(void const volatile*, __cxx_contention_t) _NOEXCEPT; | ||
| 36 | 80 | ||
| 37 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 81 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void |
| 38 | __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*); | 82 | __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; |
| 39 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 83 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void |
| 40 | __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*); | 84 | __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; |
| 41 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | 85 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t |
| 42 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*); | 86 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; |
| 43 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 87 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void |
| 44 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t); | 88 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t) _NOEXCEPT; |
| 89 | |||
| 90 | template <class _AtomicWaitable, class _Poll> | ||
| 91 | struct __atomic_wait_backoff_impl { | ||
| 92 | const _AtomicWaitable& __a_; | ||
| 93 | _Poll __poll_; | ||
| 94 | memory_order __order_; | ||
| 95 | |||
| 96 | using __waitable_traits = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | ||
| 97 | |||
| 98 | _LIBCPP_AVAILABILITY_SYNC | ||
| 99 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 100 | __update_monitor_val_and_poll(__cxx_atomic_contention_t const volatile*, __cxx_contention_t& __monitor_val) const { | ||
| 101 | // In case the contention type happens to be __cxx_atomic_contention_t, i.e. __cxx_atomic_impl<int64_t>, | ||
| 102 | // the platform wait is directly monitoring the atomic value itself. | ||
| 103 | // `__poll_` takes the current value of the atomic as an in-out argument | ||
| 104 | // to potentially modify it. After it returns, `__monitor` has a value | ||
| 105 | // which can be safely waited on by `std::__libcpp_atomic_wait` without any | ||
| 106 | // ABA style issues. | ||
| 107 | __monitor_val = __waitable_traits::__atomic_load(__a_, __order_); | ||
| 108 | return __poll_(__monitor_val); | ||
| 109 | } | ||
| 110 | |||
| 111 | _LIBCPP_AVAILABILITY_SYNC | ||
| 112 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 113 | __update_monitor_val_and_poll(void const volatile* __contention_address, __cxx_contention_t& __monitor_val) const { | ||
| 114 | // In case the contention type is anything else, platform wait is monitoring a __cxx_atomic_contention_t | ||
| 115 | // from the global pool, the monitor comes from __libcpp_atomic_monitor | ||
| 116 | __monitor_val = std::__libcpp_atomic_monitor(__contention_address); | ||
| 117 | auto __current_val = __waitable_traits::__atomic_load(__a_, __order_); | ||
| 118 | return __poll_(__current_val); | ||
| 119 | } | ||
| 45 | 120 | ||
| 46 | template <class _Atp, class _Fn> | ||
| 47 | struct __libcpp_atomic_wait_backoff_impl { | ||
| 48 | _Atp* __a; | ||
| 49 | _Fn __test_fn; | ||
| 50 | _LIBCPP_AVAILABILITY_SYNC | 121 | _LIBCPP_AVAILABILITY_SYNC |
| 51 | _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const { | 122 | _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const { |
| 52 | if (__elapsed > chrono::microseconds(64)) { | 123 | if (__elapsed > chrono::microseconds(64)) { |
| 53 | auto const __monitor = std::__libcpp_atomic_monitor(__a); | 124 | auto __contention_address = __waitable_traits::__atomic_contention_address(__a_); |
| 54 | if (__test_fn()) | 125 | __cxx_contention_t __monitor_val; |
| 126 | if (__update_monitor_val_and_poll(__contention_address, __monitor_val)) | ||
| 55 | return true; | 127 | return true; |
| 56 | std::__libcpp_atomic_wait(__a, __monitor); | 128 | std::__libcpp_atomic_wait(__contention_address, __monitor_val); |
| 57 | } else if (__elapsed > chrono::microseconds(4)) | 129 | } else if (__elapsed > chrono::microseconds(4)) |
| 58 | __libcpp_thread_yield(); | 130 | __libcpp_thread_yield(); |
| 59 | else { | 131 | else { |
| ... | @@ -62,23 +134,49 @@ struct __libcpp_atomic_wait_backoff_impl { | ... | @@ -62,23 +134,49 @@ struct __libcpp_atomic_wait_backoff_impl { |
| 62 | } | 134 | } |
| 63 | }; | 135 | }; |
| 64 | 136 | ||
| 65 | template <class _Atp, class _Fn> | 137 | // The semantics of this function are similar to `atomic`'s |
| 66 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_wait(_Atp* __a, _Fn&& __test_fn) { | 138 | // `.wait(T old, std::memory_order order)`, but instead of having a hardcoded |
| 67 | __libcpp_atomic_wait_backoff_impl<_Atp, __decay_t<_Fn> > __backoff_fn = {__a, __test_fn}; | 139 | // predicate (is the loaded value unequal to `old`?), the predicate function is |
| 68 | return std::__libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn); | 140 | // specified as an argument. The loaded value is given as an in-out argument to |
| 141 | // the predicate. If the predicate function returns `true`, | ||
| 142 | // `__atomic_wait_unless` will return. If the predicate function returns | ||
| 143 | // `false`, it must set the argument to its current understanding of the atomic | ||
| 144 | // value. The predicate function must not return `false` spuriously. | ||
| 145 | template <class _AtomicWaitable, class _Poll> | ||
| 146 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | ||
| 147 | __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) { | ||
| 148 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | ||
| 149 | __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_impl = {__a, __poll, __order}; | ||
| 150 | __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order}; | ||
| 151 | std::__libcpp_thread_poll_with_backoff(__poll_impl, __backoff_fn); | ||
| 152 | } | ||
| 153 | |||
| 154 | template <class _AtomicWaitable> | ||
| 155 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable& __a) { | ||
| 156 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | ||
| 157 | std::__cxx_atomic_notify_one(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); | ||
| 158 | } | ||
| 159 | |||
| 160 | template <class _AtomicWaitable> | ||
| 161 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable& __a) { | ||
| 162 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | ||
| 163 | std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); | ||
| 69 | } | 164 | } |
| 70 | 165 | ||
| 71 | #else // _LIBCPP_HAS_NO_THREADS | 166 | #else // _LIBCPP_HAS_NO_THREADS |
| 72 | 167 | ||
| 73 | template <class _Tp> | 168 | template <class _AtomicWaitable, class _Poll> |
| 74 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) {} | 169 | _LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) { |
| 75 | template <class _Tp> | 170 | __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_fn = {__a, __poll, __order}; |
| 76 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> const volatile*) {} | 171 | std::__libcpp_thread_poll_with_backoff(__poll_fn, __spinning_backoff_policy()); |
| 77 | template <class _Atp, class _Fn> | ||
| 78 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_wait(_Atp*, _Fn&& __test_fn) { | ||
| 79 | return std::__libcpp_thread_poll_with_backoff(__test_fn, __spinning_backoff_policy()); | ||
| 80 | } | 172 | } |
| 81 | 173 | ||
| 174 | template <class _AtomicWaitable> | ||
| 175 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable&) {} | ||
| 176 | |||
| 177 | template <class _AtomicWaitable> | ||
| 178 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable&) {} | ||
| 179 | |||
| 82 | #endif // _LIBCPP_HAS_NO_THREADS | 180 | #endif // _LIBCPP_HAS_NO_THREADS |
| 83 | 181 | ||
| 84 | template <typename _Tp> | 182 | template <typename _Tp> |
| ... | @@ -86,21 +184,20 @@ _LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp c | ... | @@ -86,21 +184,20 @@ _LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp c |
| 86 | return std::memcmp(std::addressof(__lhs), std::addressof(__rhs), sizeof(_Tp)) == 0; | 184 | return std::memcmp(std::addressof(__lhs), std::addressof(__rhs), sizeof(_Tp)) == 0; |
| 87 | } | 185 | } |
| 88 | 186 | ||
| 89 | template <class _Atp, class _Tp> | 187 | template <class _Tp> |
| 90 | struct __cxx_atomic_wait_test_fn_impl { | 188 | struct __atomic_compare_unequal_to { |
| 91 | _Atp* __a; | 189 | _Tp __val_; |
| 92 | _Tp __val; | 190 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __arg) const { |
| 93 | memory_order __order; | 191 | return !std::__cxx_nonatomic_compare_equal(__arg, __val_); |
| 94 | _LIBCPP_HIDE_FROM_ABI bool operator()() const { | ||
| 95 | return !std::__cxx_nonatomic_compare_equal(std::__cxx_atomic_load(__a, __order), __val); | ||
| 96 | } | 192 | } |
| 97 | }; | 193 | }; |
| 98 | 194 | ||
| 99 | template <class _Atp, class _Tp> | 195 | template <class _AtomicWaitable, class _Up> |
| 100 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool | 196 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 101 | __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order) { | 197 | __atomic_wait(_AtomicWaitable& __a, _Up __val, memory_order __order) { |
| 102 | __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order}; | 198 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); |
| 103 | return std::__cxx_atomic_wait(__a, __test_fn); | 199 | __atomic_compare_unequal_to<_Up> __nonatomic_equal = {__val}; |
| 200 | std::__atomic_wait_unless(__a, __nonatomic_equal, __order); | ||
| 104 | } | 201 | } |
| 105 | 202 | ||
| 106 | _LIBCPP_END_NAMESPACE_STD | 203 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__atomic/check_memory_order.h+4| ... | @@ -27,4 +27,8 @@ | ... | @@ -27,4 +27,8 @@ |
| 27 | _LIBCPP_DIAGNOSE_WARNING(__f == memory_order_release || __f == memory_order_acq_rel, \ | 27 | _LIBCPP_DIAGNOSE_WARNING(__f == memory_order_release || __f == memory_order_acq_rel, \ |
| 28 | "memory order argument to atomic operation is invalid") | 28 | "memory order argument to atomic operation is invalid") |
| 29 | 29 | ||
| 30 | #define _LIBCPP_CHECK_WAIT_MEMORY_ORDER(__m) \ | ||
| 31 | _LIBCPP_DIAGNOSE_WARNING(__m == memory_order_release || __m == memory_order_acq_rel, \ | ||
| 32 | "memory order argument to atomic operation is invalid") | ||
| 33 | |||
| 30 | #endif // _LIBCPP___ATOMIC_CHECK_MEMORY_ORDER_H | 34 | #endif // _LIBCPP___ATOMIC_CHECK_MEMORY_ORDER_H |
lib/libcxx/include/__atomic/cxx_atomic_impl.h+2-316| ... | @@ -9,16 +9,14 @@ | ... | @@ -9,16 +9,14 @@ |
| 9 | #ifndef _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H | 9 | #ifndef _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H |
| 10 | #define _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H | 10 | #define _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H |
| 11 | 11 | ||
| 12 | #include <__atomic/is_always_lock_free.h> | ||
| 13 | #include <__atomic/memory_order.h> | 12 | #include <__atomic/memory_order.h> |
| 13 | #include <__atomic/to_gcc_order.h> | ||
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__memory/addressof.h> | 15 | #include <__memory/addressof.h> |
| 16 | #include <__type_traits/conditional.h> | ||
| 17 | #include <__type_traits/is_assignable.h> | 16 | #include <__type_traits/is_assignable.h> |
| 18 | #include <__type_traits/is_trivially_copyable.h> | 17 | #include <__type_traits/is_trivially_copyable.h> |
| 19 | #include <__type_traits/remove_const.h> | 18 | #include <__type_traits/remove_const.h> |
| 20 | #include <cstddef> | 19 | #include <cstddef> |
| 21 | #include <cstring> | ||
| 22 | 20 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -26,7 +24,7 @@ | ... | @@ -26,7 +24,7 @@ |
| 26 | 24 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 26 | ||
| 29 | #if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) || defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS) | 27 | #if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) |
| 30 | 28 | ||
| 31 | // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because | 29 | // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because |
| 32 | // the default operator= in an object is not volatile, a byte-by-byte copy | 30 | // the default operator= in an object is not volatile, a byte-by-byte copy |
| ... | @@ -44,10 +42,6 @@ _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, | ... | @@ -44,10 +42,6 @@ _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, |
| 44 | *__to++ = *__from++; | 42 | *__to++ = *__from++; |
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) | ||
| 50 | |||
| 51 | template <typename _Tp> | 45 | template <typename _Tp> |
| 52 | struct __cxx_atomic_base_impl { | 46 | struct __cxx_atomic_base_impl { |
| 53 | _LIBCPP_HIDE_FROM_ABI | 47 | _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -61,32 +55,6 @@ struct __cxx_atomic_base_impl { | ... | @@ -61,32 +55,6 @@ struct __cxx_atomic_base_impl { |
| 61 | _Tp __a_value; | 55 | _Tp __a_value; |
| 62 | }; | 56 | }; |
| 63 | 57 | ||
| 64 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) { | ||
| 65 | // Avoid switch statement to make this a constexpr. | ||
| 66 | return __order == memory_order_relaxed | ||
| 67 | ? __ATOMIC_RELAXED | ||
| 68 | : (__order == memory_order_acquire | ||
| 69 | ? __ATOMIC_ACQUIRE | ||
| 70 | : (__order == memory_order_release | ||
| 71 | ? __ATOMIC_RELEASE | ||
| 72 | : (__order == memory_order_seq_cst | ||
| 73 | ? __ATOMIC_SEQ_CST | ||
| 74 | : (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_CONSUME)))); | ||
| 75 | } | ||
| 76 | |||
| 77 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) { | ||
| 78 | // Avoid switch statement to make this a constexpr. | ||
| 79 | return __order == memory_order_relaxed | ||
| 80 | ? __ATOMIC_RELAXED | ||
| 81 | : (__order == memory_order_acquire | ||
| 82 | ? __ATOMIC_ACQUIRE | ||
| 83 | : (__order == memory_order_release | ||
| 84 | ? __ATOMIC_RELAXED | ||
| 85 | : (__order == memory_order_seq_cst | ||
| 86 | ? __ATOMIC_SEQ_CST | ||
| 87 | : (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE : __ATOMIC_CONSUME)))); | ||
| 88 | } | ||
| 89 | |||
| 90 | template <typename _Tp> | 58 | template <typename _Tp> |
| 91 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) { | 59 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) { |
| 92 | __cxx_atomic_assign_volatile(__a->__a_value, __val); | 60 | __cxx_atomic_assign_volatile(__a->__a_value, __val); |
| ... | @@ -529,289 +497,7 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o | ... | @@ -529,289 +497,7 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o |
| 529 | 497 | ||
| 530 | #endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP | 498 | #endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP |
| 531 | 499 | ||
| 532 | #ifdef _LIBCPP_ATOMIC_ONLY_USE_BUILTINS | ||
| 533 | |||
| 534 | template <typename _Tp> | ||
| 535 | struct __cxx_atomic_lock_impl { | ||
| 536 | _LIBCPP_HIDE_FROM_ABI __cxx_atomic_lock_impl() _NOEXCEPT : __a_value(), __a_lock(0) {} | ||
| 537 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_lock_impl(_Tp value) _NOEXCEPT | ||
| 538 | : __a_value(value), | ||
| 539 | __a_lock(0) {} | ||
| 540 | |||
| 541 | _Tp __a_value; | ||
| 542 | mutable __cxx_atomic_base_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_lock; | ||
| 543 | |||
| 544 | _LIBCPP_HIDE_FROM_ABI void __lock() const volatile { | ||
| 545 | while (1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire)) | ||
| 546 | /*spin*/; | ||
| 547 | } | ||
| 548 | _LIBCPP_HIDE_FROM_ABI void __lock() const { | ||
| 549 | while (1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire)) | ||
| 550 | /*spin*/; | ||
| 551 | } | ||
| 552 | _LIBCPP_HIDE_FROM_ABI void __unlock() const volatile { | ||
| 553 | __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release); | ||
| 554 | } | ||
| 555 | _LIBCPP_HIDE_FROM_ABI void __unlock() const { | ||
| 556 | __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release); | ||
| 557 | } | ||
| 558 | _LIBCPP_HIDE_FROM_ABI _Tp __read() const volatile { | ||
| 559 | __lock(); | ||
| 560 | _Tp __old; | ||
| 561 | __cxx_atomic_assign_volatile(__old, __a_value); | ||
| 562 | __unlock(); | ||
| 563 | return __old; | ||
| 564 | } | ||
| 565 | _LIBCPP_HIDE_FROM_ABI _Tp __read() const { | ||
| 566 | __lock(); | ||
| 567 | _Tp __old = __a_value; | ||
| 568 | __unlock(); | ||
| 569 | return __old; | ||
| 570 | } | ||
| 571 | _LIBCPP_HIDE_FROM_ABI void __read_inplace(_Tp* __dst) const volatile { | ||
| 572 | __lock(); | ||
| 573 | __cxx_atomic_assign_volatile(*__dst, __a_value); | ||
| 574 | __unlock(); | ||
| 575 | } | ||
| 576 | _LIBCPP_HIDE_FROM_ABI void __read_inplace(_Tp* __dst) const { | ||
| 577 | __lock(); | ||
| 578 | *__dst = __a_value; | ||
| 579 | __unlock(); | ||
| 580 | } | ||
| 581 | }; | ||
| 582 | |||
| 583 | template <typename _Tp> | ||
| 584 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) { | ||
| 585 | __cxx_atomic_assign_volatile(__a->__a_value, __val); | ||
| 586 | } | ||
| 587 | template <typename _Tp> | ||
| 588 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) { | ||
| 589 | __a->__a_value = __val; | ||
| 590 | } | ||
| 591 | |||
| 592 | template <typename _Tp> | ||
| 593 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) { | ||
| 594 | __a->__lock(); | ||
| 595 | __cxx_atomic_assign_volatile(__a->__a_value, __val); | ||
| 596 | __a->__unlock(); | ||
| 597 | } | ||
| 598 | template <typename _Tp> | ||
| 599 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) { | ||
| 600 | __a->__lock(); | ||
| 601 | __a->__a_value = __val; | ||
| 602 | __a->__unlock(); | ||
| 603 | } | ||
| 604 | |||
| 605 | template <typename _Tp> | ||
| 606 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_lock_impl<_Tp>* __a, memory_order) { | ||
| 607 | return __a->__read(); | ||
| 608 | } | ||
| 609 | template <typename _Tp> | ||
| 610 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_lock_impl<_Tp>* __a, memory_order) { | ||
| 611 | return __a->__read(); | ||
| 612 | } | ||
| 613 | |||
| 614 | template <typename _Tp> | ||
| 615 | _LIBCPP_HIDE_FROM_ABI void | ||
| 616 | __cxx_atomic_load(const volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __dst, memory_order) { | ||
| 617 | __a->__read_inplace(__dst); | ||
| 618 | } | ||
| 619 | template <typename _Tp> | ||
| 620 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_load(const __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __dst, memory_order) { | ||
| 621 | __a->__read_inplace(__dst); | ||
| 622 | } | ||
| 623 | |||
| 624 | template <typename _Tp> | ||
| 625 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) { | ||
| 626 | __a->__lock(); | ||
| 627 | _Tp __old; | ||
| 628 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 629 | __cxx_atomic_assign_volatile(__a->__a_value, __value); | ||
| 630 | __a->__unlock(); | ||
| 631 | return __old; | ||
| 632 | } | ||
| 633 | template <typename _Tp> | ||
| 634 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) { | ||
| 635 | __a->__lock(); | ||
| 636 | _Tp __old = __a->__a_value; | ||
| 637 | __a->__a_value = __value; | ||
| 638 | __a->__unlock(); | ||
| 639 | return __old; | ||
| 640 | } | ||
| 641 | |||
| 642 | template <typename _Tp> | ||
| 643 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | ||
| 644 | volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) { | ||
| 645 | _Tp __temp; | ||
| 646 | __a->__lock(); | ||
| 647 | __cxx_atomic_assign_volatile(__temp, __a->__a_value); | ||
| 648 | bool __ret = (std::memcmp(&__temp, __expected, sizeof(_Tp)) == 0); | ||
| 649 | if (__ret) | ||
| 650 | __cxx_atomic_assign_volatile(__a->__a_value, __value); | ||
| 651 | else | ||
| 652 | __cxx_atomic_assign_volatile(*__expected, __a->__a_value); | ||
| 653 | __a->__unlock(); | ||
| 654 | return __ret; | ||
| 655 | } | ||
| 656 | template <typename _Tp> | ||
| 657 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | ||
| 658 | __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) { | ||
| 659 | __a->__lock(); | ||
| 660 | bool __ret = (std::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0); | ||
| 661 | if (__ret) | ||
| 662 | std::memcpy(&__a->__a_value, &__value, sizeof(_Tp)); | ||
| 663 | else | ||
| 664 | std::memcpy(__expected, &__a->__a_value, sizeof(_Tp)); | ||
| 665 | __a->__unlock(); | ||
| 666 | return __ret; | ||
| 667 | } | ||
| 668 | |||
| 669 | template <typename _Tp> | ||
| 670 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | ||
| 671 | volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) { | ||
| 672 | _Tp __temp; | ||
| 673 | __a->__lock(); | ||
| 674 | __cxx_atomic_assign_volatile(__temp, __a->__a_value); | ||
| 675 | bool __ret = (std::memcmp(&__temp, __expected, sizeof(_Tp)) == 0); | ||
| 676 | if (__ret) | ||
| 677 | __cxx_atomic_assign_volatile(__a->__a_value, __value); | ||
| 678 | else | ||
| 679 | __cxx_atomic_assign_volatile(*__expected, __a->__a_value); | ||
| 680 | __a->__unlock(); | ||
| 681 | return __ret; | ||
| 682 | } | ||
| 683 | template <typename _Tp> | ||
| 684 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | ||
| 685 | __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) { | ||
| 686 | __a->__lock(); | ||
| 687 | bool __ret = (std::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0); | ||
| 688 | if (__ret) | ||
| 689 | std::memcpy(&__a->__a_value, &__value, sizeof(_Tp)); | ||
| 690 | else | ||
| 691 | std::memcpy(__expected, &__a->__a_value, sizeof(_Tp)); | ||
| 692 | __a->__unlock(); | ||
| 693 | return __ret; | ||
| 694 | } | ||
| 695 | |||
| 696 | template <typename _Tp, typename _Td> | ||
| 697 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) { | ||
| 698 | __a->__lock(); | ||
| 699 | _Tp __old; | ||
| 700 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 701 | __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old + __delta)); | ||
| 702 | __a->__unlock(); | ||
| 703 | return __old; | ||
| 704 | } | ||
| 705 | template <typename _Tp, typename _Td> | ||
| 706 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) { | ||
| 707 | __a->__lock(); | ||
| 708 | _Tp __old = __a->__a_value; | ||
| 709 | __a->__a_value += __delta; | ||
| 710 | __a->__unlock(); | ||
| 711 | return __old; | ||
| 712 | } | ||
| 713 | |||
| 714 | template <typename _Tp, typename _Td> | ||
| 715 | _LIBCPP_HIDE_FROM_ABI _Tp* | ||
| 716 | __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order) { | ||
| 717 | __a->__lock(); | ||
| 718 | _Tp* __old; | ||
| 719 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 720 | __cxx_atomic_assign_volatile(__a->__a_value, __old + __delta); | ||
| 721 | __a->__unlock(); | ||
| 722 | return __old; | ||
| 723 | } | ||
| 724 | template <typename _Tp, typename _Td> | ||
| 725 | _LIBCPP_HIDE_FROM_ABI _Tp* __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order) { | ||
| 726 | __a->__lock(); | ||
| 727 | _Tp* __old = __a->__a_value; | ||
| 728 | __a->__a_value += __delta; | ||
| 729 | __a->__unlock(); | ||
| 730 | return __old; | ||
| 731 | } | ||
| 732 | |||
| 733 | template <typename _Tp, typename _Td> | ||
| 734 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) { | ||
| 735 | __a->__lock(); | ||
| 736 | _Tp __old; | ||
| 737 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 738 | __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old - __delta)); | ||
| 739 | __a->__unlock(); | ||
| 740 | return __old; | ||
| 741 | } | ||
| 742 | template <typename _Tp, typename _Td> | ||
| 743 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) { | ||
| 744 | __a->__lock(); | ||
| 745 | _Tp __old = __a->__a_value; | ||
| 746 | __a->__a_value -= __delta; | ||
| 747 | __a->__unlock(); | ||
| 748 | return __old; | ||
| 749 | } | ||
| 750 | |||
| 751 | template <typename _Tp> | ||
| 752 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 753 | __cxx_atomic_fetch_and(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) { | ||
| 754 | __a->__lock(); | ||
| 755 | _Tp __old; | ||
| 756 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 757 | __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old & __pattern)); | ||
| 758 | __a->__unlock(); | ||
| 759 | return __old; | ||
| 760 | } | ||
| 761 | template <typename _Tp> | ||
| 762 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_and(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) { | ||
| 763 | __a->__lock(); | ||
| 764 | _Tp __old = __a->__a_value; | ||
| 765 | __a->__a_value &= __pattern; | ||
| 766 | __a->__unlock(); | ||
| 767 | return __old; | ||
| 768 | } | ||
| 769 | |||
| 770 | template <typename _Tp> | ||
| 771 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 772 | __cxx_atomic_fetch_or(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) { | ||
| 773 | __a->__lock(); | ||
| 774 | _Tp __old; | ||
| 775 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 776 | __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old | __pattern)); | ||
| 777 | __a->__unlock(); | ||
| 778 | return __old; | ||
| 779 | } | ||
| 780 | template <typename _Tp> | ||
| 781 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) { | ||
| 782 | __a->__lock(); | ||
| 783 | _Tp __old = __a->__a_value; | ||
| 784 | __a->__a_value |= __pattern; | ||
| 785 | __a->__unlock(); | ||
| 786 | return __old; | ||
| 787 | } | ||
| 788 | |||
| 789 | template <typename _Tp> | ||
| 790 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 791 | __cxx_atomic_fetch_xor(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) { | ||
| 792 | __a->__lock(); | ||
| 793 | _Tp __old; | ||
| 794 | __cxx_atomic_assign_volatile(__old, __a->__a_value); | ||
| 795 | __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old ^ __pattern)); | ||
| 796 | __a->__unlock(); | ||
| 797 | return __old; | ||
| 798 | } | ||
| 799 | template <typename _Tp> | ||
| 800 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_xor(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) { | ||
| 801 | __a->__lock(); | ||
| 802 | _Tp __old = __a->__a_value; | ||
| 803 | __a->__a_value ^= __pattern; | ||
| 804 | __a->__unlock(); | ||
| 805 | return __old; | ||
| 806 | } | ||
| 807 | |||
| 808 | template <typename _Tp, | ||
| 809 | typename _Base = typename conditional<__libcpp_is_always_lock_free<_Tp>::__value, | ||
| 810 | __cxx_atomic_base_impl<_Tp>, | ||
| 811 | __cxx_atomic_lock_impl<_Tp> >::type> | ||
| 812 | #else | ||
| 813 | template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> > | 500 | template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> > |
| 814 | #endif //_LIBCPP_ATOMIC_ONLY_USE_BUILTINS | ||
| 815 | struct __cxx_atomic_impl : public _Base { | 501 | struct __cxx_atomic_impl : public _Base { |
| 816 | static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type"); | 502 | static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type"); |
| 817 | 503 |
lib/libcxx/include/__atomic/memory_order.h+1-1| ... | @@ -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<memory_order>::type, __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/to_gcc_order.h created+54| ... | @@ -0,0 +1,54 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ATOMIC_TO_GCC_ORDER_H | ||
| 10 | #define _LIBCPP___ATOMIC_TO_GCC_ORDER_H | ||
| 11 | |||
| 12 | #include <__atomic/memory_order.h> | ||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if defined(__ATOMIC_RELAXED) && defined(__ATOMIC_CONSUME) && defined(__ATOMIC_ACQUIRE) && \ | ||
| 22 | defined(__ATOMIC_RELEASE) && defined(__ATOMIC_ACQ_REL) && defined(__ATOMIC_SEQ_CST) | ||
| 23 | |||
| 24 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) { | ||
| 25 | // Avoid switch statement to make this a constexpr. | ||
| 26 | return __order == memory_order_relaxed | ||
| 27 | ? __ATOMIC_RELAXED | ||
| 28 | : (__order == memory_order_acquire | ||
| 29 | ? __ATOMIC_ACQUIRE | ||
| 30 | : (__order == memory_order_release | ||
| 31 | ? __ATOMIC_RELEASE | ||
| 32 | : (__order == memory_order_seq_cst | ||
| 33 | ? __ATOMIC_SEQ_CST | ||
| 34 | : (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_CONSUME)))); | ||
| 35 | } | ||
| 36 | |||
| 37 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) { | ||
| 38 | // Avoid switch statement to make this a constexpr. | ||
| 39 | return __order == memory_order_relaxed | ||
| 40 | ? __ATOMIC_RELAXED | ||
| 41 | : (__order == memory_order_acquire | ||
| 42 | ? __ATOMIC_ACQUIRE | ||
| 43 | : (__order == memory_order_release | ||
| 44 | ? __ATOMIC_RELAXED | ||
| 45 | : (__order == memory_order_seq_cst | ||
| 46 | ? __ATOMIC_SEQ_CST | ||
| 47 | : (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE : __ATOMIC_CONSUME)))); | ||
| 48 | } | ||
| 49 | |||
| 50 | #endif | ||
| 51 | |||
| 52 | _LIBCPP_END_NAMESPACE_STD | ||
| 53 | |||
| 54 | #endif // _LIBCPP___ATOMIC_TO_GCC_ORDER_H | ||
lib/libcxx/include/__availability deleted-324| ... | @@ -1,324 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___AVAILABILITY | ||
| 11 | #define _LIBCPP___AVAILABILITY | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | // Libc++ is shipped by various vendors. In particular, it is used as a system | ||
| 20 | // library on macOS, iOS and other Apple platforms. In order for users to be | ||
| 21 | // able to compile a binary that is intended to be deployed to an older version | ||
| 22 | // of a platform, Clang provides availability attributes [1]. These attributes | ||
| 23 | // can be placed on declarations and are used to describe the life cycle of a | ||
| 24 | // symbol in the library. | ||
| 25 | // | ||
| 26 | // The main goal is to ensure a compile-time error if a symbol that hasn't been | ||
| 27 | // introduced in a previously released library is used in a program that targets | ||
| 28 | // that previously released library. Normally, this would be a load-time error | ||
| 29 | // when one tries to launch the program against the older library. | ||
| 30 | // | ||
| 31 | // For example, the filesystem library was introduced in the dylib in macOS 10.15. | ||
| 32 | // If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their | ||
| 33 | // program, the compiler would normally not complain (because the required | ||
| 34 | // declarations are in the headers), but the dynamic loader would fail to find | ||
| 35 | // the symbols when actually trying to launch the program on macOS 10.13. To | ||
| 36 | // turn this into a compile-time issue instead, declarations are annotated with | ||
| 37 | // when they were introduced, and the compiler can produce a diagnostic if the | ||
| 38 | // program references something that isn't available on the deployment target. | ||
| 39 | // | ||
| 40 | // This mechanism is general in nature, and any vendor can add their markup to | ||
| 41 | // the library (see below). Whenever a new feature is added that requires support | ||
| 42 | // in the shared library, two macros are added below to allow marking the feature | ||
| 43 | // as unavailable: | ||
| 44 | // 1. A macro named `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` which must be defined | ||
| 45 | // exactly when compiling for a target that doesn't support the feature. | ||
| 46 | // 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must always be defined | ||
| 47 | // and must expand to the proper availability attribute for the platform. | ||
| 48 | // | ||
| 49 | // When vendors decide to ship the feature as part of their shared library, they | ||
| 50 | // can update these macros appropriately for their platform, and the library will | ||
| 51 | // use those to provide an optimal user experience. | ||
| 52 | // | ||
| 53 | // Furthermore, many features in the standard library have corresponding | ||
| 54 | // feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` macros | ||
| 55 | // are checked by the corresponding feature-test macros generated by | ||
| 56 | // generate_feature_test_macro_components.py to ensure that the library | ||
| 57 | // doesn't announce a feature as being implemented if it is unavailable on | ||
| 58 | // the deployment target. | ||
| 59 | // | ||
| 60 | // Note that this mechanism is disabled by default in the "upstream" libc++. | ||
| 61 | // Availability annotations are only meaningful when shipping libc++ inside | ||
| 62 | // a platform (i.e. as a system library), and so vendors that want them should | ||
| 63 | // turn those annotations on at CMake configuration time. | ||
| 64 | // | ||
| 65 | // [1]: https://clang.llvm.org/docs/AttributeReference.html#availability | ||
| 66 | |||
| 67 | // For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY | ||
| 68 | // for a while. | ||
| 69 | #if defined(_LIBCPP_DISABLE_AVAILABILITY) | ||
| 70 | # if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
| 71 | # define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS | ||
| 72 | # endif | ||
| 73 | #endif | ||
| 74 | |||
| 75 | // Availability markup is disabled when building the library, or when a non-Clang | ||
| 76 | // compiler is used because only Clang supports the necessary attributes. | ||
| 77 | // doesn't support the proper attributes. | ||
| 78 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED) | ||
| 79 | # if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
| 80 | # define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS | ||
| 81 | # endif | ||
| 82 | #endif | ||
| 83 | |||
| 84 | #if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
| 85 | |||
| 86 | // These macros control the availability of std::bad_optional_access and | ||
| 87 | // other exception types. These were put in the shared library to prevent | ||
| 88 | // code bloat from every user program defining the vtable for these exception | ||
| 89 | // types. | ||
| 90 | // | ||
| 91 | // Note that when exceptions are disabled, the methods that normally throw | ||
| 92 | // these exceptions can be used even on older deployment targets, but those | ||
| 93 | // methods will abort instead of throwing. | ||
| 94 | # define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS 1 | ||
| 95 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | ||
| 96 | |||
| 97 | # define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS 1 | ||
| 98 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS | ||
| 99 | |||
| 100 | # define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST 1 | ||
| 101 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST | ||
| 102 | |||
| 103 | // These macros controls the availability of __cxa_init_primary_exception | ||
| 104 | // in the built library, which std::make_exception_ptr might use | ||
| 105 | // (see libcxx/include/__exception/exception_ptr.h). | ||
| 106 | # define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1 | ||
| 107 | # define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION | ||
| 108 | |||
| 109 | // These macros control the availability of all parts of <filesystem> that | ||
| 110 | // depend on something in the dylib. | ||
| 111 | # define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1 | ||
| 112 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY | ||
| 113 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | ||
| 114 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | ||
| 115 | |||
| 116 | // This controls the availability of floating-point std::to_chars functions. | ||
| 117 | // These overloads were added later than the integer overloads. | ||
| 118 | # define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1 | ||
| 119 | # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT | ||
| 120 | |||
| 121 | // This controls the availability of the C++20 synchronization library, | ||
| 122 | // which requires shared library support for various operations | ||
| 123 | // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>, | ||
| 124 | // <semaphore>, and notification functions on std::atomic. | ||
| 125 | # define _LIBCPP_AVAILABILITY_HAS_SYNC 1 | ||
| 126 | # define _LIBCPP_AVAILABILITY_SYNC | ||
| 127 | |||
| 128 | // This controls whether the library claims to provide a default verbose | ||
| 129 | // termination function, and consequently whether the headers will try | ||
| 130 | // to use it when the mechanism isn't overriden at compile-time. | ||
| 131 | # define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT 1 | ||
| 132 | # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT | ||
| 133 | |||
| 134 | // This controls the availability of the C++17 std::pmr library, | ||
| 135 | // which is implemented in large part in the built library. | ||
| 136 | # define _LIBCPP_AVAILABILITY_HAS_PMR 1 | ||
| 137 | # define _LIBCPP_AVAILABILITY_PMR | ||
| 138 | |||
| 139 | // This controls the availability of the C++20 time zone database. | ||
| 140 | // The parser code is built in the library. | ||
| 141 | # define _LIBCPP_AVAILABILITY_HAS_TZDB 1 | ||
| 142 | # define _LIBCPP_AVAILABILITY_TZDB | ||
| 143 | |||
| 144 | // This controls the availability of C++23 <print>, which | ||
| 145 | // has a dependency on the built library (it needs access to | ||
| 146 | // the underlying buffer types of std::cout, std::cerr, and std::clog. | ||
| 147 | # define _LIBCPP_AVAILABILITY_HAS_PRINT 1 | ||
| 148 | # define _LIBCPP_AVAILABILITY_PRINT | ||
| 149 | |||
| 150 | // Enable additional explicit instantiations of iostreams components. This | ||
| 151 | // reduces the number of weak definitions generated in programs that use | ||
| 152 | // iostreams by providing a single strong definition in the shared library. | ||
| 153 | // | ||
| 154 | // TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation, | ||
| 155 | // or once libc++ doesn't use the attribute anymore. | ||
| 156 | // TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed. | ||
| 157 | # if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32) | ||
| 158 | # define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1 | ||
| 159 | # else | ||
| 160 | # define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0 | ||
| 161 | # endif | ||
| 162 | |||
| 163 | #elif defined(__APPLE__) | ||
| 164 | |||
| 165 | # define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS \ | ||
| 166 | (!defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 50000) | ||
| 167 | |||
| 168 | # define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS | ||
| 169 | # define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS | ||
| 170 | |||
| 171 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((availability(watchos, strict, introduced = 5.0))) | ||
| 172 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | ||
| 173 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | ||
| 174 | |||
| 175 | // TODO: Update once this is released | ||
| 176 | # define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 | ||
| 177 | # define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION __attribute__((unavailable)) | ||
| 178 | |||
| 179 | // <filesystem> | ||
| 180 | // clang-format off | ||
| 181 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ | ||
| 182 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 183 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 184 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) | ||
| 185 | // clang-format on | ||
| 186 | # define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 0 | ||
| 187 | # else | ||
| 188 | # define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1 | ||
| 189 | # endif | ||
| 190 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY \ | ||
| 191 | __attribute__((availability(macos, strict, introduced = 10.15))) \ | ||
| 192 | __attribute__((availability(ios, strict, introduced = 13.0))) \ | ||
| 193 | __attribute__((availability(tvos, strict, introduced = 13.0))) \ | ||
| 194 | __attribute__((availability(watchos, strict, introduced = 6.0))) | ||
| 195 | // clang-format off | ||
| 196 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH \ | ||
| 197 | _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \ | ||
| 198 | _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ | ||
| 199 | _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ | ||
| 200 | _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))") | ||
| 201 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP \ | ||
| 202 | _Pragma("clang attribute pop") \ | ||
| 203 | _Pragma("clang attribute pop") \ | ||
| 204 | _Pragma("clang attribute pop") \ | ||
| 205 | _Pragma("clang attribute pop") | ||
| 206 | // clang-format on | ||
| 207 | |||
| 208 | // std::to_chars(floating-point) | ||
| 209 | // clang-format off | ||
| 210 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130300) || \ | ||
| 211 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160300) || \ | ||
| 212 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160300) || \ | ||
| 213 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90300) | ||
| 214 | // clang-format on | ||
| 215 | # define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 0 | ||
| 216 | # else | ||
| 217 | # define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1 | ||
| 218 | # endif | ||
| 219 | # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \ | ||
| 220 | __attribute__((availability(macos, strict, introduced = 13.3))) \ | ||
| 221 | __attribute__((availability(ios, strict, introduced = 16.3))) \ | ||
| 222 | __attribute__((availability(tvos, strict, introduced = 16.3))) \ | ||
| 223 | __attribute__((availability(watchos, strict, introduced = 9.3))) | ||
| 224 | |||
| 225 | // c++20 synchronization library | ||
| 226 | // clang-format off | ||
| 227 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ | ||
| 228 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \ | ||
| 229 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \ | ||
| 230 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000) | ||
| 231 | // clang-format on | ||
| 232 | # define _LIBCPP_AVAILABILITY_HAS_SYNC 0 | ||
| 233 | # else | ||
| 234 | # define _LIBCPP_AVAILABILITY_HAS_SYNC 1 | ||
| 235 | # endif | ||
| 236 | # define _LIBCPP_AVAILABILITY_SYNC \ | ||
| 237 | __attribute__((availability(macos, strict, introduced = 11.0))) \ | ||
| 238 | __attribute__((availability(ios, strict, introduced = 14.0))) \ | ||
| 239 | __attribute__((availability(tvos, strict, introduced = 14.0))) \ | ||
| 240 | __attribute__((availability(watchos, strict, introduced = 7.0))) | ||
| 241 | |||
| 242 | // __libcpp_verbose_abort | ||
| 243 | // TODO: Update once this is released | ||
| 244 | # define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT 0 | ||
| 245 | |||
| 246 | # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT __attribute__((unavailable)) | ||
| 247 | |||
| 248 | // std::pmr | ||
| 249 | // clang-format off | ||
| 250 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \ | ||
| 251 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \ | ||
| 252 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \ | ||
| 253 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000) | ||
| 254 | // clang-format on | ||
| 255 | # define _LIBCPP_AVAILABILITY_HAS_PMR 0 | ||
| 256 | # else | ||
| 257 | # define _LIBCPP_AVAILABILITY_HAS_PMR 1 | ||
| 258 | # endif | ||
| 259 | // TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed | ||
| 260 | // Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support | ||
| 261 | // it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we | ||
| 262 | // use availability annotations until that bug has been fixed. | ||
| 263 | # if 0 | ||
| 264 | # define _LIBCPP_AVAILABILITY_PMR \ | ||
| 265 | __attribute__((availability(macos, strict, introduced = 14.0))) \ | ||
| 266 | __attribute__((availability(ios, strict, introduced = 17.0))) \ | ||
| 267 | __attribute__((availability(tvos, strict, introduced = 17.0))) \ | ||
| 268 | __attribute__((availability(watchos, strict, introduced = 10.0))) | ||
| 269 | # else | ||
| 270 | # define _LIBCPP_AVAILABILITY_PMR | ||
| 271 | # endif | ||
| 272 | |||
| 273 | # define _LIBCPP_AVAILABILITY_HAS_TZDB 0 | ||
| 274 | # define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable)) | ||
| 275 | |||
| 276 | // Warning: This availability macro works differently than the other macros. | ||
| 277 | // The dylib part of print is not needed on Apple platforms. Therefore when | ||
| 278 | // the macro is not available the code calling the dylib is commented out. | ||
| 279 | // The macro _LIBCPP_AVAILABILITY_PRINT is not used. | ||
| 280 | # define _LIBCPP_AVAILABILITY_HAS_PRINT 0 | ||
| 281 | # define _LIBCPP_AVAILABILITY_PRINT __attribute__((unavailable)) | ||
| 282 | |||
| 283 | // clang-format off | ||
| 284 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120000) || \ | ||
| 285 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \ | ||
| 286 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000) || \ | ||
| 287 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000) | ||
| 288 | // clang-format on | ||
| 289 | # define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0 | ||
| 290 | # else | ||
| 291 | # define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1 | ||
| 292 | # endif | ||
| 293 | #else | ||
| 294 | |||
| 295 | // ...New vendors can add availability markup here... | ||
| 296 | |||
| 297 | # error \ | ||
| 298 | "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!" | ||
| 299 | |||
| 300 | #endif | ||
| 301 | |||
| 302 | // Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS. | ||
| 303 | // Those are defined in terms of the availability attributes above, and | ||
| 304 | // should not be vendor-specific. | ||
| 305 | #if defined(_LIBCPP_HAS_NO_EXCEPTIONS) | ||
| 306 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST | ||
| 307 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | ||
| 308 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS | ||
| 309 | #else | ||
| 310 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST | ||
| 311 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | ||
| 312 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS | ||
| 313 | #endif | ||
| 314 | |||
| 315 | // Define availability attributes that depend on both | ||
| 316 | // _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI. | ||
| 317 | #if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI) | ||
| 318 | # undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION | ||
| 319 | # undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION | ||
| 320 | # define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 | ||
| 321 | # define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION | ||
| 322 | #endif | ||
| 323 | |||
| 324 | #endif // _LIBCPP___AVAILABILITY | ||
lib/libcxx/include/__bit/bit_cast.h+10-1| ... | @@ -19,12 +19,21 @@ | ... | @@ -19,12 +19,21 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | ||
| 23 | |||
| 24 | template <class _ToType, class _FromType> | ||
| 25 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept { | ||
| 26 | return __builtin_bit_cast(_ToType, __from); | ||
| 27 | } | ||
| 28 | |||
| 29 | #endif // _LIBCPP_CXX03_LANG | ||
| 30 | |||
| 22 | #if _LIBCPP_STD_VER >= 20 | 31 | #if _LIBCPP_STD_VER >= 20 |
| 23 | 32 | ||
| 24 | template <class _ToType, class _FromType> | 33 | template <class _ToType, class _FromType> |
| 25 | requires(sizeof(_ToType) == sizeof(_FromType) && is_trivially_copyable_v<_ToType> && | 34 | requires(sizeof(_ToType) == sizeof(_FromType) && is_trivially_copyable_v<_ToType> && |
| 26 | is_trivially_copyable_v<_FromType>) | 35 | is_trivially_copyable_v<_FromType>) |
| 27 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept { | 36 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept { |
| 28 | return __builtin_bit_cast(_ToType, __from); | 37 | return __builtin_bit_cast(_ToType, __from); |
| 29 | } | 38 | } |
| 30 | 39 |
lib/libcxx/include/__bit/bit_ceil.h+2-2| ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | ||
| 26 | template <class _Tp> | 26 | template <class _Tp> |
| 27 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) noexcept { | 27 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) noexcept { |
| 28 | if (__t < 2) | 28 | if (__t < 2) |
| 29 | return 1; | 29 | return 1; |
| 30 | const unsigned __n = numeric_limits<_Tp>::digits - std::__countl_zero((_Tp)(__t - 1u)); | 30 | const unsigned __n = numeric_limits<_Tp>::digits - std::__countl_zero((_Tp)(__t - 1u)); |
| ... | @@ -42,7 +42,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) no | ... | @@ -42,7 +42,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) no |
| 42 | # if _LIBCPP_STD_VER >= 20 | 42 | # if _LIBCPP_STD_VER >= 20 |
| 43 | 43 | ||
| 44 | template <__libcpp_unsigned_integer _Tp> | 44 | template <__libcpp_unsigned_integer _Tp> |
| 45 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { | 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { |
| 46 | return std::__bit_ceil(__t); | 46 | return std::__bit_ceil(__t); |
| 47 | } | 47 | } |
| 48 | 48 |
lib/libcxx/include/__bit/bit_floor.h+1-1| ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER >= 20 | 23 | #if _LIBCPP_STD_VER >= 20 |
| 24 | 24 | ||
| 25 | template <__libcpp_unsigned_integer _Tp> | 25 | template <__libcpp_unsigned_integer _Tp> |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept { | 26 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept { |
| 27 | return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t); | 27 | return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t); |
| 28 | } | 28 | } |
| 29 | 29 |
lib/libcxx/include/__bit/bit_width.h+1-1| ... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | template <__libcpp_unsigned_integer _Tp> | 24 | template <__libcpp_unsigned_integer _Tp> |
| 25 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept { |
| 26 | return __t == 0 ? 0 : std::__bit_log2(__t) + 1; | 26 | return __t == 0 ? 0 : std::__bit_log2(__t) + 1; |
| 27 | } | 27 | } |
| 28 | 28 |
lib/libcxx/include/__bit/byteswap.h+1-1| ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER >= 23 | 23 | #if _LIBCPP_STD_VER >= 23 |
| 24 | 24 | ||
| 25 | template <integral _Tp> | 25 | template <integral _Tp> |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept { | 26 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept { |
| 27 | if constexpr (sizeof(_Tp) == 1) { | 27 | if constexpr (sizeof(_Tp) == 1) { |
| 28 | return __val; | 28 | return __val; |
| 29 | } else if constexpr (sizeof(_Tp) == 2) { | 29 | } else if constexpr (sizeof(_Tp) == 2) { |
lib/libcxx/include/__bit/countl.h+13-2| ... | @@ -6,6 +6,9 @@ | ... | @@ -6,6 +6,9 @@ |
| 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 | |||
| 9 | #ifndef _LIBCPP___BIT_COUNTL_H | 12 | #ifndef _LIBCPP___BIT_COUNTL_H |
| 10 | #define _LIBCPP___BIT_COUNTL_H | 13 | #define _LIBCPP___BIT_COUNTL_H |
| 11 | 14 | ||
| ... | @@ -38,6 +41,9 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_cl | ... | @@ -38,6 +41,9 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_cl |
| 38 | 41 | ||
| 39 | #ifndef _LIBCPP_HAS_NO_INT128 | 42 | #ifndef _LIBCPP_HAS_NO_INT128 |
| 40 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT { | 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 | ||
| 41 | // The function is written in this form due to C++ constexpr limitations. | 47 | // The function is written in this form due to C++ constexpr limitations. |
| 42 | // The algorithm: | 48 | // The algorithm: |
| 43 | // - Test whether any bit in the high 64-bits is set | 49 | // - Test whether any bit in the high 64-bits is set |
| ... | @@ -49,12 +55,16 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) | ... | @@ -49,12 +55,16 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) |
| 49 | // zeros in the high 64-bits. | 55 | // zeros in the high 64-bits. |
| 50 | return ((__x >> 64) == 0) ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x))) | 56 | return ((__x >> 64) == 0) ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x))) |
| 51 | : __builtin_clzll(static_cast<unsigned long long>(__x >> 64)); | 57 | : __builtin_clzll(static_cast<unsigned long long>(__x >> 64)); |
| 58 | # endif | ||
| 52 | } | 59 | } |
| 53 | #endif // _LIBCPP_HAS_NO_INT128 | 60 | #endif // _LIBCPP_HAS_NO_INT128 |
| 54 | 61 | ||
| 55 | template <class _Tp> | 62 | template <class _Tp> |
| 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { | 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { |
| 57 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type"); | 64 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type"); |
| 65 | #if __has_builtin(__builtin_clzg) | ||
| 66 | return __builtin_clzg(__t, numeric_limits<_Tp>::digits); | ||
| 67 | #else // __has_builtin(__builtin_clzg) | ||
| 58 | if (__t == 0) | 68 | if (__t == 0) |
| 59 | return numeric_limits<_Tp>::digits; | 69 | return numeric_limits<_Tp>::digits; |
| 60 | 70 | ||
| ... | @@ -79,17 +89,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _ | ... | @@ -79,17 +89,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _ |
| 79 | } | 89 | } |
| 80 | return __ret + __iter; | 90 | return __ret + __iter; |
| 81 | } | 91 | } |
| 92 | #endif // __has_builtin(__builtin_clzg) | ||
| 82 | } | 93 | } |
| 83 | 94 | ||
| 84 | #if _LIBCPP_STD_VER >= 20 | 95 | #if _LIBCPP_STD_VER >= 20 |
| 85 | 96 | ||
| 86 | template <__libcpp_unsigned_integer _Tp> | 97 | template <__libcpp_unsigned_integer _Tp> |
| 87 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept { | 98 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept { |
| 88 | return std::__countl_zero(__t); | 99 | return std::__countl_zero(__t); |
| 89 | } | 100 | } |
| 90 | 101 | ||
| 91 | template <__libcpp_unsigned_integer _Tp> | 102 | template <__libcpp_unsigned_integer _Tp> |
| 92 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { | 103 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { |
| 93 | return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | 104 | return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; |
| 94 | } | 105 | } |
| 95 | 106 |
lib/libcxx/include/__bit/countr.h+17-6| ... | @@ -6,6 +6,9 @@ | ... | @@ -6,6 +6,9 @@ |
| 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 | |||
| 9 | #ifndef _LIBCPP___BIT_COUNTR_H | 12 | #ifndef _LIBCPP___BIT_COUNTR_H |
| 10 | #define _LIBCPP___BIT_COUNTR_H | 13 | #define _LIBCPP___BIT_COUNTR_H |
| 11 | 14 | ||
| ... | @@ -35,13 +38,13 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ct | ... | @@ -35,13 +38,13 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ct |
| 35 | return __builtin_ctzll(__x); | 38 | return __builtin_ctzll(__x); |
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | #if _LIBCPP_STD_VER >= 20 | 41 | template <class _Tp> |
| 39 | 42 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT { | |
| 40 | template <__libcpp_unsigned_integer _Tp> | 43 | #if __has_builtin(__builtin_ctzg) |
| 41 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept { | 44 | return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); |
| 45 | #else // __has_builtin(__builtin_ctzg) | ||
| 42 | if (__t == 0) | 46 | if (__t == 0) |
| 43 | return numeric_limits<_Tp>::digits; | 47 | return numeric_limits<_Tp>::digits; |
| 44 | |||
| 45 | if (sizeof(_Tp) <= sizeof(unsigned int)) | 48 | if (sizeof(_Tp) <= sizeof(unsigned int)) |
| 46 | return std::__libcpp_ctz(static_cast<unsigned int>(__t)); | 49 | return std::__libcpp_ctz(static_cast<unsigned int>(__t)); |
| 47 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | 50 | else if (sizeof(_Tp) <= sizeof(unsigned long)) |
| ... | @@ -57,10 +60,18 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) n | ... | @@ -57,10 +60,18 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) n |
| 57 | } | 60 | } |
| 58 | return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t)); | 61 | return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t)); |
| 59 | } | 62 | } |
| 63 | #endif // __has_builtin(__builtin_ctzg) | ||
| 64 | } | ||
| 65 | |||
| 66 | #if _LIBCPP_STD_VER >= 20 | ||
| 67 | |||
| 68 | template <__libcpp_unsigned_integer _Tp> | ||
| 69 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept { | ||
| 70 | return std::__countr_zero(__t); | ||
| 60 | } | 71 | } |
| 61 | 72 | ||
| 62 | template <__libcpp_unsigned_integer _Tp> | 73 | template <__libcpp_unsigned_integer _Tp> |
| 63 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { | 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { |
| 64 | return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | 75 | return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; |
| 65 | } | 76 | } |
| 66 | 77 |
lib/libcxx/include/__bit/has_single_bit.h+1-1| ... | @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS |
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | template <__libcpp_unsigned_integer _Tp> | 26 | template <__libcpp_unsigned_integer _Tp> |
| 27 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept { | 27 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept { |
| 28 | return __t != 0 && (((__t & (__t - 1)) == 0)); | 28 | return __t != 0 && (((__t & (__t - 1)) == 0)); |
| 29 | } | 29 | } |
| 30 | 30 |
lib/libcxx/include/__bit/popcount.h+8-1| ... | @@ -6,6 +6,9 @@ | ... | @@ -6,6 +6,9 @@ |
| 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 | |||
| 9 | #ifndef _LIBCPP___BIT_POPCOUNT_H | 12 | #ifndef _LIBCPP___BIT_POPCOUNT_H |
| 10 | #define _LIBCPP___BIT_POPCOUNT_H | 13 | #define _LIBCPP___BIT_POPCOUNT_H |
| 11 | 14 | ||
| ... | @@ -38,7 +41,10 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo | ... | @@ -38,7 +41,10 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo |
| 38 | #if _LIBCPP_STD_VER >= 20 | 41 | #if _LIBCPP_STD_VER >= 20 |
| 39 | 42 | ||
| 40 | template <__libcpp_unsigned_integer _Tp> | 43 | template <__libcpp_unsigned_integer _Tp> |
| 41 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept { | 44 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept { |
| 45 | # if __has_builtin(__builtin_popcountg) | ||
| 46 | return __builtin_popcountg(__t); | ||
| 47 | # else // __has_builtin(__builtin_popcountg) | ||
| 42 | if (sizeof(_Tp) <= sizeof(unsigned int)) | 48 | if (sizeof(_Tp) <= sizeof(unsigned int)) |
| 43 | return std::__libcpp_popcount(static_cast<unsigned int>(__t)); | 49 | return std::__libcpp_popcount(static_cast<unsigned int>(__t)); |
| 44 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | 50 | else if (sizeof(_Tp) <= sizeof(unsigned long)) |
| ... | @@ -53,6 +59,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noex | ... | @@ -53,6 +59,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noex |
| 53 | } | 59 | } |
| 54 | return __ret; | 60 | return __ret; |
| 55 | } | 61 | } |
| 62 | # endif // __has_builtin(__builtin_popcountg) | ||
| 56 | } | 63 | } |
| 57 | 64 | ||
| 58 | #endif // _LIBCPP_STD_VER >= 20 | 65 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__bit/rotate.h+25-12| ... | @@ -20,24 +20,37 @@ | ... | @@ -20,24 +20,37 @@ |
| 20 | 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | // Writing two full functions for rotl and rotr makes it easier for the compiler | ||
| 24 | // to optimize the code. On x86 this function becomes the ROL instruction and | ||
| 25 | // the rotr function becomes the ROR instruction. | ||
| 23 | template <class _Tp> | 26 | template <class _Tp> |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __t, int __cnt) _NOEXCEPT { | 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT { |
| 25 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); | 28 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type"); |
| 26 | const unsigned int __dig = numeric_limits<_Tp>::digits; | 29 | const int __N = numeric_limits<_Tp>::digits; |
| 27 | if ((__cnt % __dig) == 0) | 30 | int __r = __s % __N; |
| 28 | return __t; | 31 | |
| 32 | if (__r == 0) | ||
| 33 | return __x; | ||
| 29 | 34 | ||
| 30 | if (__cnt < 0) { | 35 | if (__r > 0) |
| 31 | __cnt *= -1; | 36 | return (__x << __r) | (__x >> (__N - __r)); |
| 32 | return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); // rotr with negative __cnt is similar to rotl | ||
| 33 | } | ||
| 34 | 37 | ||
| 35 | return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig))); | 38 | return (__x >> -__r) | (__x << (__N + __r)); |
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | template <class _Tp> | 41 | template <class _Tp> |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __t, int __cnt) _NOEXCEPT { | 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT { |
| 40 | return std::__rotr(__t, -__cnt); | 43 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); |
| 44 | const int __N = numeric_limits<_Tp>::digits; | ||
| 45 | int __r = __s % __N; | ||
| 46 | |||
| 47 | if (__r == 0) | ||
| 48 | return __x; | ||
| 49 | |||
| 50 | if (__r > 0) | ||
| 51 | return (__x >> __r) | (__x << (__N - __r)); | ||
| 52 | |||
| 53 | return (__x << -__r) | (__x >> (__N + __r)); | ||
| 41 | } | 54 | } |
| 42 | 55 | ||
| 43 | #if _LIBCPP_STD_VER >= 20 | 56 | #if _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__bit_reference+26-66| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | #include <__bit/countr.h> | 16 | #include <__bit/countr.h> |
| 17 | #include <__bit/invert_if.h> | 17 | #include <__bit/invert_if.h> |
| 18 | #include <__bit/popcount.h> | 18 | #include <__bit/popcount.h> |
| 19 | #include <__compare/ordering.h> | ||
| 19 | #include <__config> | 20 | #include <__config> |
| 20 | #include <__fwd/bit_reference.h> | 21 | #include <__fwd/bit_reference.h> |
| 21 | #include <__iterator/iterator_traits.h> | 22 | #include <__iterator/iterator_traits.h> |
| ... | @@ -95,8 +96,8 @@ public: | ... | @@ -95,8 +96,8 @@ public: |
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | private: | 98 | private: |
| 98 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_reference( | 99 | _LIBCPP_HIDE_FROM_ABI |
| 99 | __storage_pointer __s, __storage_type __m) _NOEXCEPT | 100 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT |
| 100 | : __seg_(__s), | 101 | : __seg_(__s), |
| 101 | __mask_(__m) {} | 102 | __mask_(__m) {} |
| 102 | }; | 103 | }; |
| ... | @@ -149,6 +150,7 @@ public: | ... | @@ -149,6 +150,7 @@ public: |
| 149 | using __container = typename _Cp::__self; | 150 | using __container = typename _Cp::__self; |
| 150 | 151 | ||
| 151 | _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default; | 152 | _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default; |
| 153 | __bit_const_reference& operator=(const __bit_const_reference&) = delete; | ||
| 152 | 154 | ||
| 153 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT | 155 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT |
| 154 | : __seg_(__x.__seg_), | 156 | : __seg_(__x.__seg_), |
| ... | @@ -163,69 +165,12 @@ public: | ... | @@ -163,69 +165,12 @@ public: |
| 163 | } | 165 | } |
| 164 | 166 | ||
| 165 | private: | 167 | private: |
| 166 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __bit_const_reference( | 168 | _LIBCPP_HIDE_FROM_ABI |
| 167 | __storage_pointer __s, __storage_type __m) _NOEXCEPT | 169 | _LIBCPP_CONSTEXPR explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT |
| 168 | : __seg_(__s), | 170 | : __seg_(__s), |
| 169 | __mask_(__m) {} | 171 | __mask_(__m) {} |
| 170 | |||
| 171 | __bit_const_reference& operator=(const __bit_const_reference&) = delete; | ||
| 172 | }; | 172 | }; |
| 173 | 173 | ||
| 174 | // fill_n | ||
| 175 | |||
| 176 | template <bool _FillVal, class _Cp> | ||
| 177 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 178 | __fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { | ||
| 179 | using _It = __bit_iterator<_Cp, false>; | ||
| 180 | using __storage_type = typename _It::__storage_type; | ||
| 181 | |||
| 182 | const int __bits_per_word = _It::__bits_per_word; | ||
| 183 | // do first partial word | ||
| 184 | if (__first.__ctz_ != 0) { | ||
| 185 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | ||
| 186 | __storage_type __dn = std::min(__clz_f, __n); | ||
| 187 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | ||
| 188 | if (_FillVal) | ||
| 189 | *__first.__seg_ |= __m; | ||
| 190 | else | ||
| 191 | *__first.__seg_ &= ~__m; | ||
| 192 | __n -= __dn; | ||
| 193 | ++__first.__seg_; | ||
| 194 | } | ||
| 195 | // do middle whole words | ||
| 196 | __storage_type __nw = __n / __bits_per_word; | ||
| 197 | std::fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0); | ||
| 198 | __n -= __nw * __bits_per_word; | ||
| 199 | // do last partial word | ||
| 200 | if (__n > 0) { | ||
| 201 | __first.__seg_ += __nw; | ||
| 202 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 203 | if (_FillVal) | ||
| 204 | *__first.__seg_ |= __m; | ||
| 205 | else | ||
| 206 | *__first.__seg_ &= ~__m; | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | template <class _Cp> | ||
| 211 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 212 | fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value) { | ||
| 213 | if (__n > 0) { | ||
| 214 | if (__value) | ||
| 215 | std::__fill_n<true>(__first, __n); | ||
| 216 | else | ||
| 217 | std::__fill_n<false>(__first, __n); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | // fill | ||
| 222 | |||
| 223 | template <class _Cp> | ||
| 224 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 225 | fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value) { | ||
| 226 | std::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value); | ||
| 227 | } | ||
| 228 | |||
| 229 | // copy | 174 | // copy |
| 230 | 175 | ||
| 231 | template <class _Cp, bool _IsConst> | 176 | template <class _Cp, bool _IsConst> |
| ... | @@ -969,6 +914,7 @@ public: | ... | @@ -969,6 +914,7 @@ public: |
| 969 | return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_; | 914 | return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_; |
| 970 | } | 915 | } |
| 971 | 916 | ||
| 917 | #if _LIBCPP_STD_VER <= 17 | ||
| 972 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool | 918 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool |
| 973 | operator!=(const __bit_iterator& __x, const __bit_iterator& __y) { | 919 | operator!=(const __bit_iterator& __x, const __bit_iterator& __y) { |
| 974 | return !(__x == __y); | 920 | return !(__x == __y); |
| ... | @@ -993,10 +939,22 @@ public: | ... | @@ -993,10 +939,22 @@ public: |
| 993 | operator>=(const __bit_iterator& __x, const __bit_iterator& __y) { | 939 | operator>=(const __bit_iterator& __x, const __bit_iterator& __y) { |
| 994 | return !(__x < __y); | 940 | return !(__x < __y); |
| 995 | } | 941 | } |
| 942 | #else // _LIBCPP_STD_VER <= 17 | ||
| 943 | _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering | ||
| 944 | operator<=>(const __bit_iterator& __x, const __bit_iterator& __y) { | ||
| 945 | if (__x.__seg_ < __y.__seg_) | ||
| 946 | return strong_ordering::less; | ||
| 947 | |||
| 948 | if (__x.__seg_ == __y.__seg_) | ||
| 949 | return __x.__ctz_ <=> __y.__ctz_; | ||
| 950 | |||
| 951 | return strong_ordering::greater; | ||
| 952 | } | ||
| 953 | #endif // _LIBCPP_STD_VER <= 17 | ||
| 996 | 954 | ||
| 997 | private: | 955 | private: |
| 998 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator( | 956 | _LIBCPP_HIDE_FROM_ABI |
| 999 | __storage_pointer __s, unsigned __ctz) _NOEXCEPT | 957 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT |
| 1000 | : __seg_(__s), | 958 | : __seg_(__s), |
| 1001 | __ctz_(__ctz) {} | 959 | __ctz_(__ctz) {} |
| 1002 | 960 | ||
| ... | @@ -1007,8 +965,10 @@ private: | ... | @@ -1007,8 +965,10 @@ private: |
| 1007 | friend class __bit_iterator<_Cp, true>; | 965 | friend class __bit_iterator<_Cp, true>; |
| 1008 | template <class _Dp> | 966 | template <class _Dp> |
| 1009 | friend struct __bit_array; | 967 | friend struct __bit_array; |
| 968 | |||
| 1010 | template <bool _FillVal, class _Dp> | 969 | template <bool _FillVal, class _Dp> |
| 1011 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void __fill_n(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | 970 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void |
| 971 | __fill_n_bool(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | ||
| 1012 | 972 | ||
| 1013 | template <class _Dp, bool _IC> | 973 | template <class _Dp, bool _IC> |
| 1014 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned( | 974 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned( |
| ... | @@ -1053,8 +1013,8 @@ private: | ... | @@ -1053,8 +1013,8 @@ private: |
| 1053 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> | 1013 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> |
| 1054 | __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); | 1014 | __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); |
| 1055 | template <bool _ToCount, class _Dp, bool _IC> | 1015 | template <bool _ToCount, class _Dp, bool _IC> |
| 1056 | friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1016 | friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI |
| 1057 | __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); | 1017 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); |
| 1058 | }; | 1018 | }; |
| 1059 | 1019 | ||
| 1060 | _LIBCPP_END_NAMESPACE_STD | 1020 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__charconv/chars_format.h+3-6| ... | @@ -39,20 +39,17 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator^(chars_format __x, | ... | @@ -39,20 +39,17 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator^(chars_format __x, |
| 39 | return chars_format(std::__to_underlying(__x) ^ std::__to_underlying(__y)); | 39 | return chars_format(std::__to_underlying(__x) ^ std::__to_underlying(__y)); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format& | 42 | inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator&=(chars_format& __x, chars_format __y) { |
| 43 | operator&=(chars_format& __x, chars_format __y) { | ||
| 44 | __x = __x & __y; | 43 | __x = __x & __y; |
| 45 | return __x; | 44 | return __x; |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format& | 47 | inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator|=(chars_format& __x, chars_format __y) { |
| 49 | operator|=(chars_format& __x, chars_format __y) { | ||
| 50 | __x = __x | __y; | 48 | __x = __x | __y; |
| 51 | return __x; | 49 | return __x; |
| 52 | } | 50 | } |
| 53 | 51 | ||
| 54 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format& | 52 | inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator^=(chars_format& __x, chars_format __y) { |
| 55 | operator^=(chars_format& __x, chars_format __y) { | ||
| 56 | __x = __x ^ __y; | 53 | __x = __x ^ __y; |
| 57 | return __x; | 54 | return __x; |
| 58 | } | 55 | } |
lib/libcxx/include/__charconv/from_chars_integral.h+1| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | #define _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H | 11 | #define _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/copy_n.h> | 13 | #include <__algorithm/copy_n.h> |
| 14 | #include <__assert> | ||
| 14 | #include <__charconv/from_chars_result.h> | 15 | #include <__charconv/from_chars_result.h> |
| 15 | #include <__charconv/traits.h> | 16 | #include <__charconv/traits.h> |
| 16 | #include <__config> | 17 | #include <__config> |
lib/libcxx/include/__charconv/to_chars_base_10.h+1| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | #define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H | 11 | #define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/copy_n.h> | 13 | #include <__algorithm/copy_n.h> |
| 14 | #include <__assert> | ||
| 14 | #include <__charconv/tables.h> | 15 | #include <__charconv/tables.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <cstdint> | 17 | #include <cstdint> |
lib/libcxx/include/__charconv/to_chars_floating_point.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H | 10 | #ifndef _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H |
| 11 | #define _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H | 11 | #define _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__charconv/chars_format.h> | 13 | #include <__charconv/chars_format.h> |
| 15 | #include <__charconv/to_chars_result.h> | 14 | #include <__charconv/to_chars_result.h> |
| 16 | #include <__config> | 15 | #include <__config> |
lib/libcxx/include/__charconv/to_chars_integral.h+1| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | #define _LIBCPP___CHARCONV_TO_CHARS_INTEGRAL_H | 11 | #define _LIBCPP___CHARCONV_TO_CHARS_INTEGRAL_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/copy_n.h> | 13 | #include <__algorithm/copy_n.h> |
| 14 | #include <__assert> | ||
| 14 | #include <__bit/countl.h> | 15 | #include <__bit/countl.h> |
| 15 | #include <__charconv/tables.h> | 16 | #include <__charconv/tables.h> |
| 16 | #include <__charconv/to_chars_base_10.h> | 17 | #include <__charconv/to_chars_base_10.h> |
lib/libcxx/include/__charconv/traits.h+1| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP___CHARCONV_TRAITS | 10 | #ifndef _LIBCPP___CHARCONV_TRAITS |
| 11 | #define _LIBCPP___CHARCONV_TRAITS | 11 | #define _LIBCPP___CHARCONV_TRAITS |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 13 | #include <__bit/countl.h> | 14 | #include <__bit/countl.h> |
| 14 | #include <__charconv/tables.h> | 15 | #include <__charconv/tables.h> |
| 15 | #include <__charconv/to_chars_base_10.h> | 16 | #include <__charconv/to_chars_base_10.h> |
lib/libcxx/include/__chrono/convert_to_tm.h+16| ... | @@ -16,10 +16,12 @@ | ... | @@ -16,10 +16,12 @@ |
| 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/hh_mm_ss.h> | 18 | #include <__chrono/hh_mm_ss.h> |
| 19 | #include <__chrono/local_info.h> | ||
| 19 | #include <__chrono/month.h> | 20 | #include <__chrono/month.h> |
| 20 | #include <__chrono/month_weekday.h> | 21 | #include <__chrono/month_weekday.h> |
| 21 | #include <__chrono/monthday.h> | 22 | #include <__chrono/monthday.h> |
| 22 | #include <__chrono/statically_widen.h> | 23 | #include <__chrono/statically_widen.h> |
| 24 | #include <__chrono/sys_info.h> | ||
| 23 | #include <__chrono/system_clock.h> | 25 | #include <__chrono/system_clock.h> |
| 24 | #include <__chrono/time_point.h> | 26 | #include <__chrono/time_point.h> |
| 25 | #include <__chrono/weekday.h> | 27 | #include <__chrono/weekday.h> |
| ... | @@ -27,11 +29,13 @@ | ... | @@ -27,11 +29,13 @@ |
| 27 | #include <__chrono/year_month.h> | 29 | #include <__chrono/year_month.h> |
| 28 | #include <__chrono/year_month_day.h> | 30 | #include <__chrono/year_month_day.h> |
| 29 | #include <__chrono/year_month_weekday.h> | 31 | #include <__chrono/year_month_weekday.h> |
| 32 | #include <__chrono/zoned_time.h> | ||
| 30 | #include <__concepts/same_as.h> | 33 | #include <__concepts/same_as.h> |
| 31 | #include <__config> | 34 | #include <__config> |
| 32 | #include <__format/format_error.h> | 35 | #include <__format/format_error.h> |
| 33 | #include <__memory/addressof.h> | 36 | #include <__memory/addressof.h> |
| 34 | #include <__type_traits/is_convertible.h> | 37 | #include <__type_traits/is_convertible.h> |
| 38 | #include <__type_traits/is_specialization.h> | ||
| 35 | #include <cstdint> | 39 | #include <cstdint> |
| 36 | #include <ctime> | 40 | #include <ctime> |
| 37 | #include <limits> | 41 | #include <limits> |
| ... | @@ -171,6 +175,18 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { | ... | @@ -171,6 +175,18 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { |
| 171 | if (__value.hours().count() > std::numeric_limits<decltype(__result.tm_hour)>::max()) | 175 | if (__value.hours().count() > std::numeric_limits<decltype(__result.tm_hour)>::max()) |
| 172 | std::__throw_format_error("Formatting hh_mm_ss, encountered an hour overflow"); | 176 | std::__throw_format_error("Formatting hh_mm_ss, encountered an hour overflow"); |
| 173 | __result.tm_hour = __value.hours().count(); | 177 | __result.tm_hour = __value.hours().count(); |
| 178 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 179 | } else if constexpr (same_as<_ChronoT, chrono::sys_info>) { | ||
| 180 | // Has no time information. | ||
| 181 | } else if constexpr (same_as<_ChronoT, chrono::local_info>) { | ||
| 182 | // Has no time information. | ||
| 183 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 184 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 185 | } else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) { | ||
| 186 | return std::__convert_to_tm<_Tm>( | ||
| 187 | chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()}); | ||
| 188 | # endif | ||
| 189 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 174 | } else | 190 | } else |
| 175 | static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization"); | 191 | static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization"); |
| 176 | 192 |
lib/libcxx/include/__chrono/duration.h+10-10| ... | @@ -391,8 +391,8 @@ operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Perio | ... | @@ -391,8 +391,8 @@ operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Perio |
| 391 | 391 | ||
| 392 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 392 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 393 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 393 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 394 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | 394 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type |
| 395 | operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 395 | operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 396 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | 396 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; |
| 397 | return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); | 397 | return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); |
| 398 | } | 398 | } |
| ... | @@ -401,8 +401,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | ... | @@ -401,8 +401,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 401 | 401 | ||
| 402 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 402 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 403 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 403 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 404 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | 404 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type |
| 405 | operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 405 | operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 406 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | 406 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; |
| 407 | return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); | 407 | return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); |
| 408 | } | 408 | } |
| ... | @@ -412,7 +412,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | ... | @@ -412,7 +412,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 412 | template <class _Rep1, | 412 | template <class _Rep1, |
| 413 | class _Period, | 413 | class _Period, |
| 414 | class _Rep2, | 414 | class _Rep2, |
| 415 | __enable_if_t<is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> | 415 | __enable_if_t<is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> |
| 416 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 416 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> |
| 417 | operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | 417 | operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 418 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | 418 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; |
| ... | @@ -423,7 +423,7 @@ operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | ... | @@ -423,7 +423,7 @@ operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 423 | template <class _Rep1, | 423 | template <class _Rep1, |
| 424 | class _Period, | 424 | class _Period, |
| 425 | class _Rep2, | 425 | class _Rep2, |
| 426 | __enable_if_t<is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> | 426 | __enable_if_t<is_convertible<const _Rep1&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> |
| 427 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 427 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> |
| 428 | operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { | 428 | operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { |
| 429 | return __d * __s; | 429 | return __d * __s; |
| ... | @@ -435,7 +435,7 @@ template <class _Rep1, | ... | @@ -435,7 +435,7 @@ template <class _Rep1, |
| 435 | class _Period, | 435 | class _Period, |
| 436 | class _Rep2, | 436 | class _Rep2, |
| 437 | __enable_if_t<!__is_duration<_Rep2>::value && | 437 | __enable_if_t<!__is_duration<_Rep2>::value && |
| 438 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | 438 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, |
| 439 | int> = 0> | 439 | int> = 0> |
| 440 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 440 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> |
| 441 | operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | 441 | operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| ... | @@ -457,7 +457,7 @@ template <class _Rep1, | ... | @@ -457,7 +457,7 @@ template <class _Rep1, |
| 457 | class _Period, | 457 | class _Period, |
| 458 | class _Rep2, | 458 | class _Rep2, |
| 459 | __enable_if_t<!__is_duration<_Rep2>::value && | 459 | __enable_if_t<!__is_duration<_Rep2>::value && |
| 460 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | 460 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, |
| 461 | int> = 0> | 461 | int> = 0> |
| 462 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 462 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> |
| 463 | operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | 463 | operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| ... | @@ -468,8 +468,8 @@ operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | ... | @@ -468,8 +468,8 @@ operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 468 | 468 | ||
| 469 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 469 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 470 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 470 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 471 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | 471 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type |
| 472 | operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 472 | operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 473 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | 473 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; |
| 474 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | 474 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; |
| 475 | return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); | 475 | return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); |
lib/libcxx/include/__chrono/exception.h created+135| ... | @@ -0,0 +1,135 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_EXCEPTION_H | ||
| 13 | #define _LIBCPP___CHRONO_EXCEPTION_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__chrono/calendar.h> | ||
| 20 | # include <__chrono/local_info.h> | ||
| 21 | # include <__chrono/time_point.h> | ||
| 22 | # include <__config> | ||
| 23 | # include <__configuration/availability.h> | ||
| 24 | # include <__verbose_abort> | ||
| 25 | # include <format> | ||
| 26 | # include <stdexcept> | ||
| 27 | # include <string> | ||
| 28 | |||
| 29 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 30 | # pragma GCC system_header | ||
| 31 | # endif | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | |||
| 35 | # if _LIBCPP_STD_VER >= 20 | ||
| 36 | |||
| 37 | namespace chrono { | ||
| 38 | |||
| 39 | class nonexistent_local_time : public runtime_error { | ||
| 40 | public: | ||
| 41 | template <class _Duration> | ||
| 42 | _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& __time, const local_info& __info) | ||
| 43 | : runtime_error{__create_message(__time, __info)} { | ||
| 44 | // [time.zone.exception.nonexist]/2 | ||
| 45 | // Preconditions: i.result == local_info::nonexistent is true. | ||
| 46 | // The value of __info.result is not used. | ||
| 47 | _LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::nonexistent, | ||
| 48 | "creating an nonexistent_local_time from a local_info that is not non-existent"); | ||
| 49 | } | ||
| 50 | |||
| 51 | _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const nonexistent_local_time&) = default; | ||
| 52 | _LIBCPP_HIDE_FROM_ABI nonexistent_local_time& operator=(const nonexistent_local_time&) = default; | ||
| 53 | |||
| 54 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI ~nonexistent_local_time() override; // exported as key function | ||
| 55 | |||
| 56 | private: | ||
| 57 | template <class _Duration> | ||
| 58 | _LIBCPP_HIDE_FROM_ABI string __create_message(const local_time<_Duration>& __time, const local_info& __info) { | ||
| 59 | return std::format( | ||
| 60 | R"({} is in a gap between | ||
| 61 | {} {} and | ||
| 62 | {} {} which are both equivalent to | ||
| 63 | {} UTC)", | ||
| 64 | __time, | ||
| 65 | local_seconds{__info.first.end.time_since_epoch()} + __info.first.offset, | ||
| 66 | __info.first.abbrev, | ||
| 67 | local_seconds{__info.second.begin.time_since_epoch()} + __info.second.offset, | ||
| 68 | __info.second.abbrev, | ||
| 69 | __info.first.end); | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | |||
| 73 | template <class _Duration> | ||
| 74 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( | ||
| 75 | [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { | ||
| 76 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 77 | throw nonexistent_local_time(__time, __info); | ||
| 78 | # else | ||
| 79 | _LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode"); | ||
| 80 | # endif | ||
| 81 | } | ||
| 82 | |||
| 83 | class ambiguous_local_time : public runtime_error { | ||
| 84 | public: | ||
| 85 | template <class _Duration> | ||
| 86 | _LIBCPP_HIDE_FROM_ABI ambiguous_local_time(const local_time<_Duration>& __time, const local_info& __info) | ||
| 87 | : runtime_error{__create_message(__time, __info)} { | ||
| 88 | // [time.zone.exception.ambig]/2 | ||
| 89 | // Preconditions: i.result == local_info::ambiguous is true. | ||
| 90 | // The value of __info.result is not used. | ||
| 91 | _LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::ambiguous, | ||
| 92 | "creating an ambiguous_local_time from a local_info that is not ambiguous"); | ||
| 93 | } | ||
| 94 | |||
| 95 | _LIBCPP_HIDE_FROM_ABI ambiguous_local_time(const ambiguous_local_time&) = default; | ||
| 96 | _LIBCPP_HIDE_FROM_ABI ambiguous_local_time& operator=(const ambiguous_local_time&) = default; | ||
| 97 | |||
| 98 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI ~ambiguous_local_time() override; // exported as key function | ||
| 99 | |||
| 100 | private: | ||
| 101 | template <class _Duration> | ||
| 102 | _LIBCPP_HIDE_FROM_ABI string __create_message(const local_time<_Duration>& __time, const local_info& __info) { | ||
| 103 | return std::format( | ||
| 104 | // There are two spaces after the full-stop; this has been verified | ||
| 105 | // in the sources of the Standard. | ||
| 106 | R"({0} is ambiguous. It could be | ||
| 107 | {0} {1} == {2} UTC or | ||
| 108 | {0} {3} == {4} UTC)", | ||
| 109 | __time, | ||
| 110 | __info.first.abbrev, | ||
| 111 | __time - __info.first.offset, | ||
| 112 | __info.second.abbrev, | ||
| 113 | __time - __info.second.offset); | ||
| 114 | } | ||
| 115 | }; | ||
| 116 | |||
| 117 | template <class _Duration> | ||
| 118 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time( | ||
| 119 | [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { | ||
| 120 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 121 | throw ambiguous_local_time(__time, __info); | ||
| 122 | # else | ||
| 123 | _LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode"); | ||
| 124 | # endif | ||
| 125 | } | ||
| 126 | |||
| 127 | } // namespace chrono | ||
| 128 | |||
| 129 | # endif // _LIBCPP_STD_VER >= 20 | ||
| 130 | |||
| 131 | _LIBCPP_END_NAMESPACE_STD | ||
| 132 | |||
| 133 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 134 | |||
| 135 | #endif // _LIBCPP___CHRONO_EXCEPTION_H | ||
lib/libcxx/include/__chrono/file_clock.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___CHRONO_FILE_CLOCK_H | 10 | #ifndef _LIBCPP___CHRONO_FILE_CLOCK_H |
| 11 | #define _LIBCPP___CHRONO_FILE_CLOCK_H | 11 | #define _LIBCPP___CHRONO_FILE_CLOCK_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__chrono/duration.h> | 13 | #include <__chrono/duration.h> |
| 15 | #include <__chrono/system_clock.h> | 14 | #include <__chrono/system_clock.h> |
| 16 | #include <__chrono/time_point.h> | 15 | #include <__chrono/time_point.h> |
lib/libcxx/include/__chrono/formatter.h+195-26| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP___CHRONO_FORMATTER_H | 10 | #ifndef _LIBCPP___CHRONO_FORMATTER_H |
| 11 | #define _LIBCPP___CHRONO_FORMATTER_H | 11 | #define _LIBCPP___CHRONO_FORMATTER_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/ranges_copy.h> | ||
| 13 | #include <__chrono/calendar.h> | 14 | #include <__chrono/calendar.h> |
| 14 | #include <__chrono/concepts.h> | 15 | #include <__chrono/concepts.h> |
| 15 | #include <__chrono/convert_to_tm.h> | 16 | #include <__chrono/convert_to_tm.h> |
| ... | @@ -17,12 +18,14 @@ | ... | @@ -17,12 +18,14 @@ |
| 17 | #include <__chrono/duration.h> | 18 | #include <__chrono/duration.h> |
| 18 | #include <__chrono/file_clock.h> | 19 | #include <__chrono/file_clock.h> |
| 19 | #include <__chrono/hh_mm_ss.h> | 20 | #include <__chrono/hh_mm_ss.h> |
| 21 | #include <__chrono/local_info.h> | ||
| 20 | #include <__chrono/month.h> | 22 | #include <__chrono/month.h> |
| 21 | #include <__chrono/month_weekday.h> | 23 | #include <__chrono/month_weekday.h> |
| 22 | #include <__chrono/monthday.h> | 24 | #include <__chrono/monthday.h> |
| 23 | #include <__chrono/ostream.h> | 25 | #include <__chrono/ostream.h> |
| 24 | #include <__chrono/parser_std_format_spec.h> | 26 | #include <__chrono/parser_std_format_spec.h> |
| 25 | #include <__chrono/statically_widen.h> | 27 | #include <__chrono/statically_widen.h> |
| 28 | #include <__chrono/sys_info.h> | ||
| 26 | #include <__chrono/system_clock.h> | 29 | #include <__chrono/system_clock.h> |
| 27 | #include <__chrono/time_point.h> | 30 | #include <__chrono/time_point.h> |
| 28 | #include <__chrono/weekday.h> | 31 | #include <__chrono/weekday.h> |
| ... | @@ -30,6 +33,7 @@ | ... | @@ -30,6 +33,7 @@ |
| 30 | #include <__chrono/year_month.h> | 33 | #include <__chrono/year_month.h> |
| 31 | #include <__chrono/year_month_day.h> | 34 | #include <__chrono/year_month_day.h> |
| 32 | #include <__chrono/year_month_weekday.h> | 35 | #include <__chrono/year_month_weekday.h> |
| 36 | #include <__chrono/zoned_time.h> | ||
| 33 | #include <__concepts/arithmetic.h> | 37 | #include <__concepts/arithmetic.h> |
| 34 | #include <__concepts/same_as.h> | 38 | #include <__concepts/same_as.h> |
| 35 | #include <__config> | 39 | #include <__config> |
| ... | @@ -41,8 +45,10 @@ | ... | @@ -41,8 +45,10 @@ |
| 41 | #include <__format/parser_std_format_spec.h> | 45 | #include <__format/parser_std_format_spec.h> |
| 42 | #include <__format/write_escaped.h> | 46 | #include <__format/write_escaped.h> |
| 43 | #include <__memory/addressof.h> | 47 | #include <__memory/addressof.h> |
| 48 | #include <__type_traits/is_specialization.h> | ||
| 44 | #include <cmath> | 49 | #include <cmath> |
| 45 | #include <ctime> | 50 | #include <ctime> |
| 51 | #include <limits> | ||
| 46 | #include <sstream> | 52 | #include <sstream> |
| 47 | #include <string_view> | 53 | #include <string_view> |
| 48 | 54 | ||
| ... | @@ -79,12 +85,15 @@ namespace __formatter { | ... | @@ -79,12 +85,15 @@ namespace __formatter { |
| 79 | // small). Therefore a duration uses its own conversion. | 85 | // small). Therefore a duration uses its own conversion. |
| 80 | template <class _CharT, class _Rep, class _Period> | 86 | template <class _CharT, class _Rep, class _Period> |
| 81 | _LIBCPP_HIDE_FROM_ABI void | 87 | _LIBCPP_HIDE_FROM_ABI void |
| 82 | __format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_stringstream<_CharT>& __sstr) { | 88 | __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::duration<_Rep, _Period>& __value) { |
| 83 | __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point(); | 89 | __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point(); |
| 84 | 90 | ||
| 85 | using __duration = chrono::duration<_Rep, _Period>; | 91 | using __duration = chrono::duration<_Rep, _Period>; |
| 86 | 92 | ||
| 87 | auto __fraction = __value - chrono::duration_cast<chrono::seconds>(__value); | 93 | auto __fraction = __value - chrono::duration_cast<chrono::seconds>(__value); |
| 94 | // Converts a negative fraction to its positive value. | ||
| 95 | if (__value < chrono::seconds{0} && __fraction != __duration{0}) | ||
| 96 | __fraction += chrono::seconds{1}; | ||
| 88 | if constexpr (chrono::treat_as_floating_point_v<_Rep>) | 97 | if constexpr (chrono::treat_as_floating_point_v<_Rep>) |
| 89 | // When the floating-point value has digits itself they are ignored based | 98 | // When the floating-point value has digits itself they are ignored based |
| 90 | // on the wording in [tab:time.format.spec] | 99 | // on the wording in [tab:time.format.spec] |
| ... | @@ -110,13 +119,13 @@ __format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_strin | ... | @@ -110,13 +119,13 @@ __format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_strin |
| 110 | } | 119 | } |
| 111 | 120 | ||
| 112 | template <class _CharT, __is_time_point _Tp> | 121 | template <class _CharT, __is_time_point _Tp> |
| 113 | _LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, basic_stringstream<_CharT>& __sstr) { | 122 | _LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const _Tp& __value) { |
| 114 | __formatter::__format_sub_seconds(__value.time_since_epoch(), __sstr); | 123 | __formatter::__format_sub_seconds(__sstr, __value.time_since_epoch()); |
| 115 | } | 124 | } |
| 116 | 125 | ||
| 117 | template <class _CharT, class _Duration> | 126 | template <class _CharT, class _Duration> |
| 118 | _LIBCPP_HIDE_FROM_ABI void | 127 | _LIBCPP_HIDE_FROM_ABI void |
| 119 | __format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, basic_stringstream<_CharT>& __sstr) { | 128 | __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<_Duration>& __value) { |
| 120 | __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point(); | 129 | __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point(); |
| 121 | if constexpr (chrono::treat_as_floating_point_v<typename _Duration::rep>) | 130 | if constexpr (chrono::treat_as_floating_point_v<typename _Duration::rep>) |
| 122 | std::format_to(std::ostreambuf_iterator<_CharT>{__sstr}, | 131 | std::format_to(std::ostreambuf_iterator<_CharT>{__sstr}, |
| ... | @@ -130,10 +139,24 @@ __format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, basic_stringstr | ... | @@ -130,10 +139,24 @@ __format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, basic_stringstr |
| 130 | __value.fractional_width); | 139 | __value.fractional_width); |
| 131 | } | 140 | } |
| 132 | 141 | ||
| 142 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \ | ||
| 143 | !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 144 | template <class _CharT, class _Duration, class _TimeZonePtr> | ||
| 145 | _LIBCPP_HIDE_FROM_ABI void | ||
| 146 | __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) { | ||
| 147 | __formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch()); | ||
| 148 | } | ||
| 149 | # endif | ||
| 150 | |||
| 133 | template <class _Tp> | 151 | template <class _Tp> |
| 134 | consteval bool __use_fraction() { | 152 | consteval bool __use_fraction() { |
| 135 | if constexpr (__is_time_point<_Tp>) | 153 | if constexpr (__is_time_point<_Tp>) |
| 136 | return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width; | 154 | return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width; |
| 155 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \ | ||
| 156 | !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 157 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | ||
| 158 | return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width; | ||
| 159 | # endif | ||
| 137 | else if constexpr (chrono::__is_duration<_Tp>::value) | 160 | else if constexpr (chrono::__is_duration<_Tp>::value) |
| 138 | return chrono::hh_mm_ss<_Tp>::fractional_width; | 161 | return chrono::hh_mm_ss<_Tp>::fractional_width; |
| 139 | else if constexpr (__is_hh_mm_ss<_Tp>) | 162 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| ... | @@ -143,7 +166,7 @@ consteval bool __use_fraction() { | ... | @@ -143,7 +166,7 @@ consteval bool __use_fraction() { |
| 143 | } | 166 | } |
| 144 | 167 | ||
| 145 | template <class _CharT> | 168 | template <class _CharT> |
| 146 | _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& __sstr) { | 169 | _LIBCPP_HIDE_FROM_ABI void __format_year(basic_stringstream<_CharT>& __sstr, int __year) { |
| 147 | if (__year < 0) { | 170 | if (__year < 0) { |
| 148 | __sstr << _CharT('-'); | 171 | __sstr << _CharT('-'); |
| 149 | __year = -__year; | 172 | __year = -__year; |
| ... | @@ -159,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& | ... | @@ -159,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& |
| 159 | } | 182 | } |
| 160 | 183 | ||
| 161 | template <class _CharT> | 184 | template <class _CharT> |
| 162 | _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_CharT>& __sstr) { | 185 | _LIBCPP_HIDE_FROM_ABI void __format_century(basic_stringstream<_CharT>& __sstr, int __year) { |
| 163 | // TODO FMT Write an issue | 186 | // TODO FMT Write an issue |
| 164 | // [tab:time.format.spec] | 187 | // [tab:time.format.spec] |
| 165 | // %C The year divided by 100 using floored division. If the result is a | 188 | // %C The year divided by 100 using floored division. If the result is a |
| ... | @@ -170,10 +193,56 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_Char | ... | @@ -170,10 +193,56 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_Char |
| 170 | __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century); | 193 | __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century); |
| 171 | } | 194 | } |
| 172 | 195 | ||
| 196 | // Implements the %z format specifier according to [tab:time.format.spec], where | ||
| 197 | // '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same, | ||
| 198 | // so there is no need to distinguish between them.) | ||
| 199 | template <class _CharT> | ||
| 200 | _LIBCPP_HIDE_FROM_ABI void | ||
| 201 | __format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds __offset, bool __modifier) { | ||
| 202 | if (__offset < 0s) { | ||
| 203 | __sstr << _CharT('-'); | ||
| 204 | __offset = -__offset; | ||
| 205 | } else { | ||
| 206 | __sstr << _CharT('+'); | ||
| 207 | } | ||
| 208 | |||
| 209 | chrono::hh_mm_ss __hms{__offset}; | ||
| 210 | std::ostreambuf_iterator<_CharT> __out_it{__sstr}; | ||
| 211 | // Note HMS does not allow formatting hours > 23, but the offset is not limited to 24H. | ||
| 212 | std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __hms.hours().count()); | ||
| 213 | if (__modifier) | ||
| 214 | __sstr << _CharT(':'); | ||
| 215 | std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __hms.minutes().count()); | ||
| 216 | } | ||
| 217 | |||
| 218 | // Helper to store the time zone information needed for formatting. | ||
| 219 | struct _LIBCPP_HIDE_FROM_ABI __time_zone { | ||
| 220 | // Typically these abbreviations are short and fit in the string's internal | ||
| 221 | // buffer. | ||
| 222 | string __abbrev; | ||
| 223 | chrono::seconds __offset; | ||
| 224 | }; | ||
| 225 | |||
| 226 | template <class _Tp> | ||
| 227 | _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) { | ||
| 228 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 229 | if constexpr (same_as<_Tp, chrono::sys_info>) | ||
| 230 | return {__value.abbrev, __value.offset}; | ||
| 231 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 232 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 233 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | ||
| 234 | return __formatter::__convert_to_time_zone(__value.get_info()); | ||
| 235 | # endif | ||
| 236 | else | ||
| 237 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 238 | return {"UTC", chrono::seconds{0}}; | ||
| 239 | } | ||
| 240 | |||
| 173 | template <class _CharT, class _Tp> | 241 | template <class _CharT, class _Tp> |
| 174 | _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | 242 | _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 175 | const _Tp& __value, basic_stringstream<_CharT>& __sstr, basic_string_view<_CharT> __chrono_specs) { | 243 | basic_stringstream<_CharT>& __sstr, const _Tp& __value, basic_string_view<_CharT> __chrono_specs) { |
| 176 | tm __t = std::__convert_to_tm<tm>(__value); | 244 | tm __t = std::__convert_to_tm<tm>(__value); |
| 245 | __time_zone __z = __formatter::__convert_to_time_zone(__value); | ||
| 177 | const auto& __facet = std::use_facet<time_put<_CharT>>(__sstr.getloc()); | 246 | const auto& __facet = std::use_facet<time_put<_CharT>>(__sstr.getloc()); |
| 178 | for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); ++__it) { | 247 | for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); ++__it) { |
| 179 | if (*__it == _CharT('%')) { | 248 | if (*__it == _CharT('%')) { |
| ... | @@ -196,7 +265,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | ... | @@ -196,7 +265,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 196 | // strftime's output is only defined in the range [00, 99]. | 265 | // strftime's output is only defined in the range [00, 99]. |
| 197 | int __year = __t.tm_year + 1900; | 266 | int __year = __t.tm_year + 1900; |
| 198 | if (__year < 1000 || __year > 9999) | 267 | if (__year < 1000 || __year > 9999) |
| 199 | __formatter::__format_century(__year, __sstr); | 268 | __formatter::__format_century(__sstr, __year); |
| 200 | else | 269 | else |
| 201 | __facet.put( | 270 | __facet.put( |
| 202 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); | 271 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); |
| ... | @@ -242,7 +311,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | ... | @@ -242,7 +311,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 242 | __facet.put( | 311 | __facet.put( |
| 243 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); | 312 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); |
| 244 | if constexpr (__use_fraction<_Tp>()) | 313 | if constexpr (__use_fraction<_Tp>()) |
| 245 | __formatter::__format_sub_seconds(__value, __sstr); | 314 | __formatter::__format_sub_seconds(__sstr, __value); |
| 246 | break; | 315 | break; |
| 247 | 316 | ||
| 248 | // Unlike time_put and strftime the formatting library requires %Y | 317 | // Unlike time_put and strftime the formatting library requires %Y |
| ... | @@ -283,22 +352,24 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | ... | @@ -283,22 +352,24 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 283 | // Depending on the platform's libc the range of supported years is | 352 | // Depending on the platform's libc the range of supported years is |
| 284 | // limited. Intead of of testing all conditions use the internal | 353 | // limited. Intead of of testing all conditions use the internal |
| 285 | // implementation unconditionally. | 354 | // implementation unconditionally. |
| 286 | __formatter::__format_year(__t.tm_year + 1900, __sstr); | 355 | __formatter::__format_year(__sstr, __t.tm_year + 1900); |
| 287 | break; | 356 | break; |
| 288 | 357 | ||
| 289 | case _CharT('F'): { | 358 | case _CharT('F'): |
| 290 | int __year = __t.tm_year + 1900; | 359 | // Depending on the platform's libc the range of supported years is |
| 291 | if (__year < 1000) { | 360 | // limited. Instead of testing all conditions use the internal |
| 292 | __formatter::__format_year(__year, __sstr); | 361 | // implementation unconditionally. |
| 293 | __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday); | 362 | __formatter::__format_year(__sstr, __t.tm_year + 1900); |
| 294 | } else | 363 | __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday); |
| 295 | __facet.put( | 364 | break; |
| 296 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); | 365 | |
| 297 | } break; | 366 | case _CharT('z'): |
| 367 | __formatter::__format_zone_offset(__sstr, __z.__offset, false); | ||
| 368 | break; | ||
| 298 | 369 | ||
| 299 | case _CharT('Z'): | 370 | case _CharT('Z'): |
| 300 | // TODO FMT Add proper timezone support. | 371 | // __abbrev is always a char so the copy may convert. |
| 301 | __sstr << _LIBCPP_STATICALLY_WIDEN(_CharT, "UTC"); | 372 | ranges::copy(__z.__abbrev, std::ostreambuf_iterator<_CharT>{__sstr}); |
| 302 | break; | 373 | break; |
| 303 | 374 | ||
| 304 | case _CharT('O'): | 375 | case _CharT('O'): |
| ... | @@ -310,13 +381,19 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | ... | @@ -310,13 +381,19 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 310 | ++__it; | 381 | ++__it; |
| 311 | __facet.put( | 382 | __facet.put( |
| 312 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); | 383 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); |
| 313 | __formatter::__format_sub_seconds(__value, __sstr); | 384 | __formatter::__format_sub_seconds(__sstr, __value); |
| 314 | break; | 385 | break; |
| 315 | } | 386 | } |
| 316 | } | 387 | } |
| 388 | |||
| 389 | // Oz produces the same output as Ez below. | ||
| 317 | [[fallthrough]]; | 390 | [[fallthrough]]; |
| 318 | case _CharT('E'): | 391 | case _CharT('E'): |
| 319 | ++__it; | 392 | ++__it; |
| 393 | if (*__it == 'z') { | ||
| 394 | __formatter::__format_zone_offset(__sstr, __z.__offset, true); | ||
| 395 | break; | ||
| 396 | } | ||
| 320 | [[fallthrough]]; | 397 | [[fallthrough]]; |
| 321 | default: | 398 | default: |
| 322 | __facet.put( | 399 | __facet.put( |
| ... | @@ -365,6 +442,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) { | ... | @@ -365,6 +442,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) { |
| 365 | return __value.weekday().ok(); | 442 | return __value.weekday().ok(); |
| 366 | else if constexpr (__is_hh_mm_ss<_Tp>) | 443 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 367 | return true; | 444 | return true; |
| 445 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 446 | else if constexpr (same_as<_Tp, chrono::sys_info>) | ||
| 447 | return true; | ||
| 448 | else if constexpr (same_as<_Tp, chrono::local_info>) | ||
| 449 | return true; | ||
| 450 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 451 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 452 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | ||
| 453 | return true; | ||
| 454 | # endif | ||
| 455 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 368 | else | 456 | else |
| 369 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); | 457 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 370 | } | 458 | } |
| ... | @@ -405,6 +493,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) { | ... | @@ -405,6 +493,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) { |
| 405 | return __value.weekday().ok(); | 493 | return __value.weekday().ok(); |
| 406 | else if constexpr (__is_hh_mm_ss<_Tp>) | 494 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 407 | return true; | 495 | return true; |
| 496 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 497 | else if constexpr (same_as<_Tp, chrono::sys_info>) | ||
| 498 | return true; | ||
| 499 | else if constexpr (same_as<_Tp, chrono::local_info>) | ||
| 500 | return true; | ||
| 501 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 502 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 503 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | ||
| 504 | return true; | ||
| 505 | # endif | ||
| 506 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 408 | else | 507 | else |
| 409 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); | 508 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 410 | } | 509 | } |
| ... | @@ -445,6 +544,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) { | ... | @@ -445,6 +544,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) { |
| 445 | return __value.ok(); | 544 | return __value.ok(); |
| 446 | else if constexpr (__is_hh_mm_ss<_Tp>) | 545 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 447 | return true; | 546 | return true; |
| 547 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 548 | else if constexpr (same_as<_Tp, chrono::sys_info>) | ||
| 549 | return true; | ||
| 550 | else if constexpr (same_as<_Tp, chrono::local_info>) | ||
| 551 | return true; | ||
| 552 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 553 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 554 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | ||
| 555 | return true; | ||
| 556 | # endif | ||
| 557 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 448 | else | 558 | else |
| 449 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); | 559 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 450 | } | 560 | } |
| ... | @@ -485,6 +595,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) { | ... | @@ -485,6 +595,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) { |
| 485 | return __value.month().ok(); | 595 | return __value.month().ok(); |
| 486 | else if constexpr (__is_hh_mm_ss<_Tp>) | 596 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 487 | return true; | 597 | return true; |
| 598 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 599 | else if constexpr (same_as<_Tp, chrono::sys_info>) | ||
| 600 | return true; | ||
| 601 | else if constexpr (same_as<_Tp, chrono::local_info>) | ||
| 602 | return true; | ||
| 603 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 604 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 605 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | ||
| 606 | return true; | ||
| 607 | # endif | ||
| 608 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 488 | else | 609 | else |
| 489 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); | 610 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 490 | } | 611 | } |
| ... | @@ -510,9 +631,16 @@ __format_chrono(const _Tp& __value, | ... | @@ -510,9 +631,16 @@ __format_chrono(const _Tp& __value, |
| 510 | __sstr << __value; | 631 | __sstr << __value; |
| 511 | else { | 632 | else { |
| 512 | if constexpr (chrono::__is_duration<_Tp>::value) { | 633 | if constexpr (chrono::__is_duration<_Tp>::value) { |
| 513 | if (__value < __value.zero()) | 634 | // A duration can be a user defined arithmetic type. Users may specialize |
| 514 | __sstr << _CharT('-'); | 635 | // numeric_limits, but they may not specialize is_signed. |
| 515 | __formatter::__format_chrono_using_chrono_specs(chrono::abs(__value), __sstr, __chrono_specs); | 636 | if constexpr (numeric_limits<typename _Tp::rep>::is_signed) { |
| 637 | if (__value < __value.zero()) { | ||
| 638 | __sstr << _CharT('-'); | ||
| 639 | __formatter::__format_chrono_using_chrono_specs(__sstr, -__value, __chrono_specs); | ||
| 640 | } else | ||
| 641 | __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs); | ||
| 642 | } else | ||
| 643 | __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs); | ||
| 516 | // TODO FMT When keeping the precision it will truncate the string. | 644 | // TODO FMT When keeping the precision it will truncate the string. |
| 517 | // Note that the behaviour what the precision does isn't specified. | 645 | // Note that the behaviour what the precision does isn't specified. |
| 518 | __specs.__precision_ = -1; | 646 | __specs.__precision_ = -1; |
| ... | @@ -556,7 +684,7 @@ __format_chrono(const _Tp& __value, | ... | @@ -556,7 +684,7 @@ __format_chrono(const _Tp& __value, |
| 556 | __sstr << _CharT('-'); | 684 | __sstr << _CharT('-'); |
| 557 | } | 685 | } |
| 558 | 686 | ||
| 559 | __formatter::__format_chrono_using_chrono_specs(__value, __sstr, __chrono_specs); | 687 | __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs); |
| 560 | } | 688 | } |
| 561 | } | 689 | } |
| 562 | 690 | ||
| ... | @@ -814,6 +942,47 @@ public: | ... | @@ -814,6 +942,47 @@ public: |
| 814 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time); | 942 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time); |
| 815 | } | 943 | } |
| 816 | }; | 944 | }; |
| 945 | |||
| 946 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 947 | template <__fmt_char_type _CharT> | ||
| 948 | struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> { | ||
| 949 | public: | ||
| 950 | using _Base = __formatter_chrono<_CharT>; | ||
| 951 | |||
| 952 | template <class _ParseContext> | ||
| 953 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | ||
| 954 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time_zone); | ||
| 955 | } | ||
| 956 | }; | ||
| 957 | |||
| 958 | template <__fmt_char_type _CharT> | ||
| 959 | struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT> { | ||
| 960 | public: | ||
| 961 | using _Base = __formatter_chrono<_CharT>; | ||
| 962 | |||
| 963 | template <class _ParseContext> | ||
| 964 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | ||
| 965 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{}); | ||
| 966 | } | ||
| 967 | }; | ||
| 968 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 969 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 970 | // Note due to how libc++'s formatters are implemented there is no need to add | ||
| 971 | // the exposition only local-time-format-t abstraction. | ||
| 972 | template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT> | ||
| 973 | struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public __formatter_chrono<_CharT> { | ||
| 974 | public: | ||
| 975 | using _Base = __formatter_chrono<_CharT>; | ||
| 976 | |||
| 977 | template <class _ParseContext> | ||
| 978 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | ||
| 979 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); | ||
| 980 | } | ||
| 981 | }; | ||
| 982 | # endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && | ||
| 983 | // !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 984 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 985 | |||
| 817 | #endif // if _LIBCPP_STD_VER >= 20 | 986 | #endif // if _LIBCPP_STD_VER >= 20 |
| 818 | 987 | ||
| 819 | _LIBCPP_END_NAMESPACE_STD | 988 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__chrono/leap_second.h created+126| ... | @@ -0,0 +1,126 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_LEAP_SECOND_H | ||
| 13 | #define _LIBCPP___CHRONO_LEAP_SECOND_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__chrono/duration.h> | ||
| 20 | # include <__chrono/system_clock.h> | ||
| 21 | # include <__chrono/time_point.h> | ||
| 22 | # include <__compare/ordering.h> | ||
| 23 | # include <__compare/three_way_comparable.h> | ||
| 24 | # include <__config> | ||
| 25 | # include <__utility/private_constructor_tag.h> | ||
| 26 | |||
| 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | # endif | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | # if _LIBCPP_STD_VER >= 20 | ||
| 34 | |||
| 35 | namespace chrono { | ||
| 36 | |||
| 37 | class leap_second { | ||
| 38 | public: | ||
| 39 | [[nodiscard]] | ||
| 40 | _LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__private_constructor_tag, sys_seconds __date, seconds __value) | ||
| 41 | : __date_(__date), __value_(__value) {} | ||
| 42 | |||
| 43 | _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default; | ||
| 44 | _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default; | ||
| 45 | |||
| 46 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; } | ||
| 47 | |||
| 48 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; } | ||
| 49 | |||
| 50 | private: | ||
| 51 | sys_seconds __date_; | ||
| 52 | seconds __value_; | ||
| 53 | }; | ||
| 54 | |||
| 55 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const leap_second& __x, const leap_second& __y) { | ||
| 56 | return __x.date() == __y.date(); | ||
| 57 | } | ||
| 58 | |||
| 59 | _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) { | ||
| 60 | return __x.date() <=> __y.date(); | ||
| 61 | } | ||
| 62 | |||
| 63 | template <class _Duration> | ||
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) { | ||
| 65 | return __x.date() == __y; | ||
| 66 | } | ||
| 67 | |||
| 68 | template <class _Duration> | ||
| 69 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) { | ||
| 70 | return __x.date() < __y; | ||
| 71 | } | ||
| 72 | |||
| 73 | template <class _Duration> | ||
| 74 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) { | ||
| 75 | return __x < __y.date(); | ||
| 76 | } | ||
| 77 | |||
| 78 | template <class _Duration> | ||
| 79 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) { | ||
| 80 | return __y < __x; | ||
| 81 | } | ||
| 82 | |||
| 83 | template <class _Duration> | ||
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) { | ||
| 85 | return __y < __x; | ||
| 86 | } | ||
| 87 | |||
| 88 | template <class _Duration> | ||
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) { | ||
| 90 | return !(__y < __x); | ||
| 91 | } | ||
| 92 | |||
| 93 | template <class _Duration> | ||
| 94 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) { | ||
| 95 | return !(__y < __x); | ||
| 96 | } | ||
| 97 | |||
| 98 | template <class _Duration> | ||
| 99 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) { | ||
| 100 | return !(__x < __y); | ||
| 101 | } | ||
| 102 | |||
| 103 | template <class _Duration> | ||
| 104 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) { | ||
| 105 | return !(__x < __y); | ||
| 106 | } | ||
| 107 | |||
| 108 | # ifndef _LIBCPP_COMPILER_GCC | ||
| 109 | // This requirement cause a compilation loop in GCC-13 and running out of memory. | ||
| 110 | // TODO TZDB Test whether GCC-14 fixes this. | ||
| 111 | template <class _Duration> | ||
| 112 | requires three_way_comparable_with<sys_seconds, sys_time<_Duration>> | ||
| 113 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) { | ||
| 114 | return __x.date() <=> __y; | ||
| 115 | } | ||
| 116 | # endif | ||
| 117 | |||
| 118 | } // namespace chrono | ||
| 119 | |||
| 120 | # endif //_LIBCPP_STD_VER >= 20 | ||
| 121 | |||
| 122 | _LIBCPP_END_NAMESPACE_STD | ||
| 123 | |||
| 124 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 125 | |||
| 126 | #endif // _LIBCPP___CHRONO_LEAP_SECOND_H | ||
lib/libcxx/include/__chrono/local_info.h created+50| ... | @@ -0,0 +1,50 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_LOCAL_INFO_H | ||
| 13 | #define _LIBCPP___CHRONO_LOCAL_INFO_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__chrono/sys_info.h> | ||
| 20 | # include <__config> | ||
| 21 | |||
| 22 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | # endif | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | |||
| 28 | # if _LIBCPP_STD_VER >= 20 | ||
| 29 | |||
| 30 | namespace chrono { | ||
| 31 | |||
| 32 | struct local_info { | ||
| 33 | static constexpr int unique = 0; | ||
| 34 | static constexpr int nonexistent = 1; | ||
| 35 | static constexpr int ambiguous = 2; | ||
| 36 | |||
| 37 | int result; | ||
| 38 | sys_info first; | ||
| 39 | sys_info second; | ||
| 40 | }; | ||
| 41 | |||
| 42 | } // namespace chrono | ||
| 43 | |||
| 44 | # endif // _LIBCPP_STD_VER >= 20 | ||
| 45 | |||
| 46 | _LIBCPP_END_NAMESPACE_STD | ||
| 47 | |||
| 48 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 49 | |||
| 50 | #endif // _LIBCPP___CHRONO_LOCAL_INFO_H | ||
lib/libcxx/include/__chrono/ostream.h+52-1| ... | @@ -15,20 +15,23 @@ | ... | @@ -15,20 +15,23 @@ |
| 15 | #include <__chrono/duration.h> | 15 | #include <__chrono/duration.h> |
| 16 | #include <__chrono/file_clock.h> | 16 | #include <__chrono/file_clock.h> |
| 17 | #include <__chrono/hh_mm_ss.h> | 17 | #include <__chrono/hh_mm_ss.h> |
| 18 | #include <__chrono/local_info.h> | ||
| 18 | #include <__chrono/month.h> | 19 | #include <__chrono/month.h> |
| 19 | #include <__chrono/month_weekday.h> | 20 | #include <__chrono/month_weekday.h> |
| 20 | #include <__chrono/monthday.h> | 21 | #include <__chrono/monthday.h> |
| 21 | #include <__chrono/statically_widen.h> | 22 | #include <__chrono/statically_widen.h> |
| 23 | #include <__chrono/sys_info.h> | ||
| 22 | #include <__chrono/system_clock.h> | 24 | #include <__chrono/system_clock.h> |
| 23 | #include <__chrono/weekday.h> | 25 | #include <__chrono/weekday.h> |
| 24 | #include <__chrono/year.h> | 26 | #include <__chrono/year.h> |
| 25 | #include <__chrono/year_month.h> | 27 | #include <__chrono/year_month.h> |
| 26 | #include <__chrono/year_month_day.h> | 28 | #include <__chrono/year_month_day.h> |
| 27 | #include <__chrono/year_month_weekday.h> | 29 | #include <__chrono/year_month_weekday.h> |
| 30 | #include <__chrono/zoned_time.h> | ||
| 28 | #include <__concepts/same_as.h> | 31 | #include <__concepts/same_as.h> |
| 29 | #include <__config> | 32 | #include <__config> |
| 30 | #include <__format/format_functions.h> | 33 | #include <__format/format_functions.h> |
| 31 | #include <ostream> | 34 | #include <__fwd/ostream.h> |
| 32 | #include <ratio> | 35 | #include <ratio> |
| 33 | 36 | ||
| 34 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -262,6 +265,54 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms | ... | @@ -262,6 +265,54 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms |
| 262 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms); | 265 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms); |
| 263 | } | 266 | } |
| 264 | 267 | ||
| 268 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 269 | |||
| 270 | template <class _CharT, class _Traits> | ||
| 271 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 272 | operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_info& __info) { | ||
| 273 | // __info.abbrev is always std::basic_string<char>. | ||
| 274 | // Since these strings typically are short the conversion should be cheap. | ||
| 275 | std::basic_string<_CharT> __abbrev{__info.abbrev.begin(), __info.abbrev.end()}; | ||
| 276 | return __os << std::format( | ||
| 277 | _LIBCPP_STATICALLY_WIDEN(_CharT, "[{:%F %T}, {:%F %T}) {:%T} {:%Q%q} \"{}\""), | ||
| 278 | __info.begin, | ||
| 279 | __info.end, | ||
| 280 | hh_mm_ss{__info.offset}, | ||
| 281 | __info.save, | ||
| 282 | __abbrev); | ||
| 283 | } | ||
| 284 | |||
| 285 | template <class _CharT, class _Traits> | ||
| 286 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 287 | operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) { | ||
| 288 | auto __result = [&]() -> basic_string<_CharT> { | ||
| 289 | switch (__info.result) { | ||
| 290 | case local_info::unique: | ||
| 291 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "unique"); | ||
| 292 | case local_info::nonexistent: | ||
| 293 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "non-existent"); | ||
| 294 | case local_info::ambiguous: | ||
| 295 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "ambiguous"); | ||
| 296 | |||
| 297 | default: | ||
| 298 | return std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "unspecified result ({})"), __info.result); | ||
| 299 | }; | ||
| 300 | }; | ||
| 301 | |||
| 302 | return __os << std::format( | ||
| 303 | _LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second); | ||
| 304 | } | ||
| 305 | |||
| 306 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 307 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 308 | template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr> | ||
| 309 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 310 | operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) { | ||
| 311 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp); | ||
| 312 | } | ||
| 313 | # endif | ||
| 314 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 315 | |||
| 265 | } // namespace chrono | 316 | } // namespace chrono |
| 266 | 317 | ||
| 267 | #endif // if _LIBCPP_STD_VER >= 20 | 318 | #endif // if _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/sys_info.h created+51| ... | @@ -0,0 +1,51 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_SYS_INFO_H | ||
| 13 | #define _LIBCPP___CHRONO_SYS_INFO_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__chrono/duration.h> | ||
| 20 | # include <__chrono/system_clock.h> | ||
| 21 | # include <__chrono/time_point.h> | ||
| 22 | # include <__config> | ||
| 23 | # include <string> | ||
| 24 | |||
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 26 | # pragma GCC system_header | ||
| 27 | # endif | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | |||
| 31 | # if _LIBCPP_STD_VER >= 20 | ||
| 32 | |||
| 33 | namespace chrono { | ||
| 34 | |||
| 35 | struct sys_info { | ||
| 36 | sys_seconds begin; | ||
| 37 | sys_seconds end; | ||
| 38 | seconds offset; | ||
| 39 | minutes save; | ||
| 40 | string abbrev; | ||
| 41 | }; | ||
| 42 | |||
| 43 | } // namespace chrono | ||
| 44 | |||
| 45 | # endif // _LIBCPP_STD_VER >= 20 | ||
| 46 | |||
| 47 | _LIBCPP_END_NAMESPACE_STD | ||
| 48 | |||
| 49 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 50 | |||
| 51 | #endif // _LIBCPP___CHRONO_SYS_INFO_H | ||
lib/libcxx/include/__chrono/time_point.h+14-17| ... | @@ -78,7 +78,7 @@ public: | ... | @@ -78,7 +78,7 @@ public: |
| 78 | 78 | ||
| 79 | template <class _Clock, class _Duration1, class _Duration2> | 79 | template <class _Clock, class _Duration1, class _Duration2> |
| 80 | struct _LIBCPP_TEMPLATE_VIS | 80 | struct _LIBCPP_TEMPLATE_VIS |
| 81 | common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > { | 81 | common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > { |
| 82 | typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; | 82 | typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| ... | @@ -92,25 +92,22 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) { | ... | @@ -92,25 +92,22 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) { |
| 92 | 92 | ||
| 93 | #if _LIBCPP_STD_VER >= 17 | 93 | #if _LIBCPP_STD_VER >= 17 |
| 94 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | 94 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> |
| 95 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR time_point<_Clock, _ToDuration> | 95 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) { |
| 96 | floor(const time_point<_Clock, _Duration>& __t) { | ||
| 97 | return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())}; | 96 | return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())}; |
| 98 | } | 97 | } |
| 99 | 98 | ||
| 100 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | 99 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> |
| 101 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR time_point<_Clock, _ToDuration> | 100 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) { |
| 102 | ceil(const time_point<_Clock, _Duration>& __t) { | ||
| 103 | return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())}; | 101 | return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())}; |
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | 104 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> |
| 107 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR time_point<_Clock, _ToDuration> | 105 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) { |
| 108 | round(const time_point<_Clock, _Duration>& __t) { | ||
| 109 | return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())}; | 106 | return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())}; |
| 110 | } | 107 | } |
| 111 | 108 | ||
| 112 | template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0> | 109 | template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0> |
| 113 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) { | 110 | inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) { |
| 114 | return __d >= __d.zero() ? +__d : -__d; | 111 | return __d >= __d.zero() ? +__d : -__d; |
| 115 | } | 112 | } |
| 116 | #endif // _LIBCPP_STD_VER >= 17 | 113 | #endif // _LIBCPP_STD_VER >= 17 |
| ... | @@ -180,9 +177,9 @@ operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock | ... | @@ -180,9 +177,9 @@ operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock |
| 180 | // time_point operator+(time_point x, duration y); | 177 | // time_point operator+(time_point x, duration y); |
| 181 | 178 | ||
| 182 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | 179 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> |
| 183 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 180 | inline _LIBCPP_HIDE_FROM_ABI |
| 184 | time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | 181 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> |
| 185 | operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 182 | operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 186 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; | 183 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; |
| 187 | return _Tr(__lhs.time_since_epoch() + __rhs); | 184 | return _Tr(__lhs.time_since_epoch() + __rhs); |
| 188 | } | 185 | } |
| ... | @@ -190,18 +187,18 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | ... | @@ -190,18 +187,18 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 190 | // time_point operator+(duration x, time_point y); | 187 | // time_point operator+(duration x, time_point y); |
| 191 | 188 | ||
| 192 | template <class _Rep1, class _Period1, class _Clock, class _Duration2> | 189 | template <class _Rep1, class _Period1, class _Clock, class _Duration2> |
| 193 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 190 | inline _LIBCPP_HIDE_FROM_ABI |
| 194 | time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> | 191 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> |
| 195 | operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { | 192 | operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { |
| 196 | return __rhs + __lhs; | 193 | return __rhs + __lhs; |
| 197 | } | 194 | } |
| 198 | 195 | ||
| 199 | // time_point operator-(time_point x, duration y); | 196 | // time_point operator-(time_point x, duration y); |
| 200 | 197 | ||
| 201 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | 198 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> |
| 202 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 199 | inline _LIBCPP_HIDE_FROM_ABI |
| 203 | time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | 200 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> |
| 204 | operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 201 | operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 205 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; | 202 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; |
| 206 | return _Ret(__lhs.time_since_epoch() - __rhs); | 203 | return _Ret(__lhs.time_since_epoch() - __rhs); |
| 207 | } | 204 | } |
lib/libcxx/include/__chrono/time_zone.h created+182| ... | @@ -0,0 +1,182 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_TIME_ZONE_H | ||
| 13 | #define _LIBCPP___CHRONO_TIME_ZONE_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__chrono/calendar.h> | ||
| 20 | # include <__chrono/duration.h> | ||
| 21 | # include <__chrono/exception.h> | ||
| 22 | # include <__chrono/local_info.h> | ||
| 23 | # include <__chrono/sys_info.h> | ||
| 24 | # include <__chrono/system_clock.h> | ||
| 25 | # include <__compare/strong_order.h> | ||
| 26 | # include <__config> | ||
| 27 | # include <__memory/unique_ptr.h> | ||
| 28 | # include <__type_traits/common_type.h> | ||
| 29 | # include <string_view> | ||
| 30 | |||
| 31 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 32 | # pragma GCC system_header | ||
| 33 | # endif | ||
| 34 | |||
| 35 | _LIBCPP_PUSH_MACROS | ||
| 36 | # include <__undef_macros> | ||
| 37 | |||
| 38 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 39 | |||
| 40 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 41 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 42 | |||
| 43 | namespace chrono { | ||
| 44 | |||
| 45 | enum class choose { earliest, latest }; | ||
| 46 | |||
| 47 | class _LIBCPP_AVAILABILITY_TZDB time_zone { | ||
| 48 | _LIBCPP_HIDE_FROM_ABI time_zone() = default; | ||
| 49 | |||
| 50 | public: | ||
| 51 | class __impl; // public so it can be used by make_unique. | ||
| 52 | |||
| 53 | // The "constructor". | ||
| 54 | // | ||
| 55 | // The default constructor is private to avoid the constructor from being | ||
| 56 | // part of the ABI. Instead use an __ugly_named function as an ABI interface, | ||
| 57 | // since that gives us the ability to change it in the future. | ||
| 58 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI static time_zone __create(unique_ptr<__impl>&& __p); | ||
| 59 | |||
| 60 | _LIBCPP_EXPORTED_FROM_ABI ~time_zone(); | ||
| 61 | |||
| 62 | _LIBCPP_HIDE_FROM_ABI time_zone(time_zone&&) = default; | ||
| 63 | _LIBCPP_HIDE_FROM_ABI time_zone& operator=(time_zone&&) = default; | ||
| 64 | |||
| 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name(); } | ||
| 66 | |||
| 67 | template <class _Duration> | ||
| 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info(const sys_time<_Duration>& __time) const { | ||
| 69 | return __get_info(chrono::time_point_cast<seconds>(__time)); | ||
| 70 | } | ||
| 71 | |||
| 72 | template <class _Duration> | ||
| 73 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_info get_info(const local_time<_Duration>& __time) const { | ||
| 74 | return __get_info(chrono::time_point_cast<seconds>(__time)); | ||
| 75 | } | ||
| 76 | |||
| 77 | // We don't apply nodiscard here since this function throws on many inputs, | ||
| 78 | // so it could be used as a validation. | ||
| 79 | template <class _Duration> | ||
| 80 | _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>> to_sys(const local_time<_Duration>& __time) const { | ||
| 81 | local_info __info = get_info(__time); | ||
| 82 | switch (__info.result) { | ||
| 83 | case local_info::unique: | ||
| 84 | return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset}; | ||
| 85 | |||
| 86 | case local_info::nonexistent: | ||
| 87 | chrono::__throw_nonexistent_local_time(__time, __info); | ||
| 88 | |||
| 89 | case local_info::ambiguous: | ||
| 90 | chrono::__throw_ambiguous_local_time(__time, __info); | ||
| 91 | } | ||
| 92 | |||
| 93 | // TODO TZDB The Standard does not specify anything in these cases. | ||
| 94 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 95 | __info.result != -1, "cannot convert the local time; it would be before the minimum system clock value"); | ||
| 96 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 97 | __info.result != -2, "cannot convert the local time; it would be after the maximum system clock value"); | ||
| 98 | |||
| 99 | return {}; | ||
| 100 | } | ||
| 101 | |||
| 102 | template <class _Duration> | ||
| 103 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>> | ||
| 104 | to_sys(const local_time<_Duration>& __time, choose __z) const { | ||
| 105 | local_info __info = get_info(__time); | ||
| 106 | switch (__info.result) { | ||
| 107 | case local_info::unique: | ||
| 108 | case local_info::nonexistent: // first and second are the same | ||
| 109 | return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset}; | ||
| 110 | |||
| 111 | case local_info::ambiguous: | ||
| 112 | switch (__z) { | ||
| 113 | case choose::earliest: | ||
| 114 | return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset}; | ||
| 115 | |||
| 116 | case choose::latest: | ||
| 117 | return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.second.offset}; | ||
| 118 | |||
| 119 | // Note a value out of bounds is not specified. | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | // TODO TZDB The standard does not specify anything in these cases. | ||
| 124 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 125 | __info.result != -1, "cannot convert the local time; it would be before the minimum system clock value"); | ||
| 126 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 127 | __info.result != -2, "cannot convert the local time; it would be after the maximum system clock value"); | ||
| 128 | |||
| 129 | return {}; | ||
| 130 | } | ||
| 131 | |||
| 132 | template <class _Duration> | ||
| 133 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time<common_type_t<_Duration, seconds>> | ||
| 134 | to_local(const sys_time<_Duration>& __time) const { | ||
| 135 | using _Dp = common_type_t<_Duration, seconds>; | ||
| 136 | |||
| 137 | sys_info __info = get_info(__time); | ||
| 138 | |||
| 139 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 140 | __info.offset >= chrono::seconds{0} || __time.time_since_epoch() >= _Dp::min() - __info.offset, | ||
| 141 | "cannot convert the system time; it would be before the minimum local clock value"); | ||
| 142 | |||
| 143 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 144 | __info.offset <= chrono::seconds{0} || __time.time_since_epoch() <= _Dp::max() - __info.offset, | ||
| 145 | "cannot convert the system time; it would be after the maximum local clock value"); | ||
| 146 | |||
| 147 | return local_time<_Dp>{__time.time_since_epoch() + __info.offset}; | ||
| 148 | } | ||
| 149 | |||
| 150 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __impl& __implementation() const noexcept { return *__impl_; } | ||
| 151 | |||
| 152 | private: | ||
| 153 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI string_view __name() const noexcept; | ||
| 154 | |||
| 155 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI sys_info __get_info(sys_seconds __time) const; | ||
| 156 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info __get_info(local_seconds __time) const; | ||
| 157 | |||
| 158 | unique_ptr<__impl> __impl_; | ||
| 159 | }; | ||
| 160 | |||
| 161 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool | ||
| 162 | operator==(const time_zone& __x, const time_zone& __y) noexcept { | ||
| 163 | return __x.name() == __y.name(); | ||
| 164 | } | ||
| 165 | |||
| 166 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering | ||
| 167 | operator<=>(const time_zone& __x, const time_zone& __y) noexcept { | ||
| 168 | return __x.name() <=> __y.name(); | ||
| 169 | } | ||
| 170 | |||
| 171 | } // namespace chrono | ||
| 172 | |||
| 173 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | ||
| 174 | // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 175 | |||
| 176 | _LIBCPP_END_NAMESPACE_STD | ||
| 177 | |||
| 178 | _LIBCPP_POP_MACROS | ||
| 179 | |||
| 180 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 181 | |||
| 182 | #endif // _LIBCPP___CHRONO_TIME_ZONE_H | ||
lib/libcxx/include/__chrono/time_zone_link.h created+79| ... | @@ -0,0 +1,79 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_TIME_ZONE_LINK_H | ||
| 13 | #define _LIBCPP___CHRONO_TIME_ZONE_LINK_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__compare/strong_order.h> | ||
| 20 | # include <__config> | ||
| 21 | # include <__utility/private_constructor_tag.h> | ||
| 22 | # include <string> | ||
| 23 | # include <string_view> | ||
| 24 | |||
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 26 | # pragma GCC system_header | ||
| 27 | # endif | ||
| 28 | |||
| 29 | _LIBCPP_PUSH_MACROS | ||
| 30 | # include <__undef_macros> | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 35 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 36 | |||
| 37 | namespace chrono { | ||
| 38 | |||
| 39 | class time_zone_link { | ||
| 40 | public: | ||
| 41 | [[nodiscard]] | ||
| 42 | _LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__private_constructor_tag, string_view __name, string_view __target) | ||
| 43 | : __name_{__name}, __target_{__target} {} | ||
| 44 | |||
| 45 | _LIBCPP_HIDE_FROM_ABI time_zone_link(time_zone_link&&) = default; | ||
| 46 | _LIBCPP_HIDE_FROM_ABI time_zone_link& operator=(time_zone_link&&) = default; | ||
| 47 | |||
| 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name_; } | ||
| 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view target() const noexcept { return __target_; } | ||
| 50 | |||
| 51 | private: | ||
| 52 | string __name_; | ||
| 53 | // TODO TZDB instead of the name we can store the pointer to a zone. These | ||
| 54 | // pointers are immutable. This makes it possible to directly return a | ||
| 55 | // pointer in the time_zone in the 'locate_zone' function. | ||
| 56 | string __target_; | ||
| 57 | }; | ||
| 58 | |||
| 59 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool | ||
| 60 | operator==(const time_zone_link& __x, const time_zone_link& __y) noexcept { | ||
| 61 | return __x.name() == __y.name(); | ||
| 62 | } | ||
| 63 | |||
| 64 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering | ||
| 65 | operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept { | ||
| 66 | return __x.name() <=> __y.name(); | ||
| 67 | } | ||
| 68 | |||
| 69 | } // namespace chrono | ||
| 70 | |||
| 71 | # endif //_LIBCPP_STD_VER >= 20 | ||
| 72 | |||
| 73 | _LIBCPP_END_NAMESPACE_STD | ||
| 74 | |||
| 75 | _LIBCPP_POP_MACROS | ||
| 76 | |||
| 77 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 78 | |||
| 79 | #endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H | ||
lib/libcxx/include/__chrono/tzdb.h+52-3| ... | @@ -14,14 +14,23 @@ | ... | @@ -14,14 +14,23 @@ |
| 14 | 14 | ||
| 15 | #include <version> | 15 | #include <version> |
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) | 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) |
| 18 | 18 | ||
| 19 | # include <__algorithm/ranges_lower_bound.h> | ||
| 20 | # include <__chrono/leap_second.h> | ||
| 21 | # include <__chrono/time_zone.h> | ||
| 22 | # include <__chrono/time_zone_link.h> | ||
| 23 | # include <__config> | ||
| 19 | # include <string> | 24 | # include <string> |
| 25 | # include <vector> | ||
| 20 | 26 | ||
| 21 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | # pragma GCC system_header | 28 | # pragma GCC system_header |
| 23 | # endif | 29 | # endif |
| 24 | 30 | ||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | # include <__undef_macros> | ||
| 33 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 35 | ||
| 27 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | 36 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ |
| ... | @@ -29,8 +38,46 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,8 +38,46 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 38 | ||
| 30 | namespace chrono { | 39 | namespace chrono { |
| 31 | 40 | ||
| 32 | struct _LIBCPP_AVAILABILITY_TZDB tzdb { | 41 | struct tzdb { |
| 33 | string version; | 42 | string version; |
| 43 | vector<time_zone> zones; | ||
| 44 | vector<time_zone_link> links; | ||
| 45 | |||
| 46 | vector<leap_second> leap_seconds; | ||
| 47 | |||
| 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* __locate_zone(string_view __name) const { | ||
| 49 | if (const time_zone* __result = __find_in_zone(__name)) | ||
| 50 | return __result; | ||
| 51 | |||
| 52 | if (auto __it = ranges::lower_bound(links, __name, {}, &time_zone_link::name); | ||
| 53 | __it != links.end() && __it->name() == __name) | ||
| 54 | if (const time_zone* __result = __find_in_zone(__it->target())) | ||
| 55 | return __result; | ||
| 56 | |||
| 57 | return nullptr; | ||
| 58 | } | ||
| 59 | |||
| 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* locate_zone(string_view __name) const { | ||
| 61 | if (const time_zone* __result = __locate_zone(__name)) | ||
| 62 | return __result; | ||
| 63 | |||
| 64 | std::__throw_runtime_error("tzdb: requested time zone not found"); | ||
| 65 | } | ||
| 66 | |||
| 67 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const time_zone* current_zone() const { | ||
| 68 | return __current_zone(); | ||
| 69 | } | ||
| 70 | |||
| 71 | private: | ||
| 72 | _LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) const noexcept { | ||
| 73 | if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name); | ||
| 74 | __it != zones.end() && __it->name() == __name) | ||
| 75 | return std::addressof(*__it); | ||
| 76 | |||
| 77 | return nullptr; | ||
| 78 | } | ||
| 79 | |||
| 80 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* __current_zone() const; | ||
| 34 | }; | 81 | }; |
| 35 | 82 | ||
| 36 | } // namespace chrono | 83 | } // namespace chrono |
| ... | @@ -40,6 +87,8 @@ struct _LIBCPP_AVAILABILITY_TZDB tzdb { | ... | @@ -40,6 +87,8 @@ struct _LIBCPP_AVAILABILITY_TZDB tzdb { |
| 40 | 87 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | 88 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 89 | ||
| 43 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) | 90 | _LIBCPP_POP_MACROS |
| 91 | |||
| 92 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 44 | 93 | ||
| 45 | #endif // _LIBCPP___CHRONO_TZDB_H | 94 | #endif // _LIBCPP___CHRONO_TZDB_H |
lib/libcxx/include/__chrono/tzdb_list.h+43-16| ... | @@ -14,12 +14,13 @@ | ... | @@ -14,12 +14,13 @@ |
| 14 | 14 | ||
| 15 | #include <version> | 15 | #include <version> |
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) | 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) |
| 18 | 18 | ||
| 19 | # include <__availability> | 19 | # include <__chrono/time_zone.h> |
| 20 | # include <__chrono/tzdb.h> | 20 | # include <__chrono/tzdb.h> |
| 21 | # include <__config> | ||
| 22 | # include <__fwd/string.h> | ||
| 21 | # include <forward_list> | 23 | # include <forward_list> |
| 22 | # include <string_view> | ||
| 23 | 24 | ||
| 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | # pragma GCC system_header | 26 | # pragma GCC system_header |
| ... | @@ -32,9 +33,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -32,9 +33,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 33 | ||
| 33 | namespace chrono { | 34 | namespace chrono { |
| 34 | 35 | ||
| 36 | // TODO TZDB | ||
| 37 | // Libc++ recently switched to only export __ugly_names from the dylib. | ||
| 38 | // Since the library is still experimental the functions in this header | ||
| 39 | // should be adapted to this new style. The other tzdb headers should be | ||
| 40 | // evaluated too. | ||
| 41 | |||
| 35 | class _LIBCPP_AVAILABILITY_TZDB tzdb_list { | 42 | class _LIBCPP_AVAILABILITY_TZDB tzdb_list { |
| 36 | public: | 43 | public: |
| 37 | _LIBCPP_EXPORTED_FROM_ABI explicit tzdb_list(tzdb&& __tzdb); | 44 | class __impl; // public to allow construction in dylib |
| 45 | _LIBCPP_HIDE_FROM_ABI explicit tzdb_list(__impl* __p) : __impl_(__p) { | ||
| 46 | _LIBCPP_ASSERT_NON_NULL(__impl_ != nullptr, "initialized time_zone without a valid pimpl object"); | ||
| 47 | } | ||
| 38 | _LIBCPP_EXPORTED_FROM_ABI ~tzdb_list(); | 48 | _LIBCPP_EXPORTED_FROM_ABI ~tzdb_list(); |
| 39 | 49 | ||
| 40 | tzdb_list(const tzdb_list&) = delete; | 50 | tzdb_list(const tzdb_list&) = delete; |
| ... | @@ -42,32 +52,49 @@ public: | ... | @@ -42,32 +52,49 @@ public: |
| 42 | 52 | ||
| 43 | using const_iterator = forward_list<tzdb>::const_iterator; | 53 | using const_iterator = forward_list<tzdb>::const_iterator; |
| 44 | 54 | ||
| 45 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const tzdb& front() const noexcept; | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const tzdb& front() const noexcept { return __front(); } |
| 46 | 56 | ||
| 47 | _LIBCPP_EXPORTED_FROM_ABI const_iterator erase_after(const_iterator __p); | 57 | _LIBCPP_HIDE_FROM_ABI const_iterator erase_after(const_iterator __p) { return __erase_after(__p); } |
| 48 | 58 | ||
| 49 | _LIBCPP_EXPORTED_FROM_ABI tzdb& __emplace_front(tzdb&& __tzdb); | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return __begin(); } |
| 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return __end(); } | ||
| 50 | 61 | ||
| 51 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator begin() const noexcept; | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return __cbegin(); } |
| 52 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator end() const noexcept; | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return __cend(); } |
| 53 | 64 | ||
| 54 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator cbegin() const noexcept; | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __impl& __implementation() { return *__impl_; } |
| 55 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator cend() const noexcept; | ||
| 56 | 66 | ||
| 57 | private: | 67 | private: |
| 58 | class __impl; | 68 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const tzdb& __front() const noexcept; |
| 69 | |||
| 70 | _LIBCPP_EXPORTED_FROM_ABI const_iterator __erase_after(const_iterator __p); | ||
| 71 | |||
| 72 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __begin() const noexcept; | ||
| 73 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __end() const noexcept; | ||
| 74 | |||
| 75 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __cbegin() const noexcept; | ||
| 76 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __cend() const noexcept; | ||
| 77 | |||
| 59 | __impl* __impl_; | 78 | __impl* __impl_; |
| 60 | }; | 79 | }; |
| 61 | 80 | ||
| 62 | _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list(); | 81 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list(); |
| 63 | 82 | ||
| 64 | _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const tzdb& get_tzdb() { | 83 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const tzdb& get_tzdb() { |
| 65 | return get_tzdb_list().front(); | 84 | return get_tzdb_list().front(); |
| 66 | } | 85 | } |
| 67 | 86 | ||
| 87 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const time_zone* locate_zone(string_view __name) { | ||
| 88 | return get_tzdb().locate_zone(__name); | ||
| 89 | } | ||
| 90 | |||
| 91 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const time_zone* current_zone() { | ||
| 92 | return get_tzdb().current_zone(); | ||
| 93 | } | ||
| 94 | |||
| 68 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb(); | 95 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb(); |
| 69 | 96 | ||
| 70 | _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version(); | 97 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version(); |
| 71 | 98 | ||
| 72 | } // namespace chrono | 99 | } // namespace chrono |
| 73 | 100 | ||
| ... | @@ -76,6 +103,6 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string | ... | @@ -76,6 +103,6 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string |
| 76 | 103 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | 104 | _LIBCPP_END_NAMESPACE_STD |
| 78 | 105 | ||
| 79 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) | 106 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) |
| 80 | 107 | ||
| 81 | #endif // _LIBCPP___CHRONO_TZDB_LIST_H | 108 | #endif // _LIBCPP___CHRONO_TZDB_LIST_H |
lib/libcxx/include/__chrono/weekday.h+3| ... | @@ -79,6 +79,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con | ... | @@ -79,6 +79,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con |
| 79 | return __lhs.c_encoding() == __rhs.c_encoding(); | 79 | return __lhs.c_encoding() == __rhs.c_encoding(); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | // TODO(LLVM 20): Remove the escape hatch | ||
| 83 | # ifdef _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS | ||
| 82 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(const weekday& __lhs, const weekday& __rhs) noexcept { | 84 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(const weekday& __lhs, const weekday& __rhs) noexcept { |
| 83 | return __lhs.c_encoding() < __rhs.c_encoding(); | 85 | return __lhs.c_encoding() < __rhs.c_encoding(); |
| 84 | } | 86 | } |
| ... | @@ -94,6 +96,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(const weekday& __lhs, con | ... | @@ -94,6 +96,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(const weekday& __lhs, con |
| 94 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept { | 96 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept { |
| 95 | return !(__lhs < __rhs); | 97 | return !(__lhs < __rhs); |
| 96 | } | 98 | } |
| 99 | # endif // _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS | ||
| 97 | 100 | ||
| 98 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept { | 101 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept { |
| 99 | auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); | 102 | auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); |
lib/libcxx/include/__chrono/year_month_day.h+5-27| ... | @@ -239,33 +239,11 @@ operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) n | ... | @@ -239,33 +239,11 @@ operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) n |
| 239 | return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); | 239 | return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool | 242 | _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering |
| 243 | operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { | 243 | operator<=>(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { |
| 244 | return !(__lhs == __rhs); | 244 | if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0) |
| 245 | } | 245 | return __c; |
| 246 | 246 | return __lhs.month_day_last() <=> __rhs.month_day_last(); | |
| 247 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool | ||
| 248 | operator<(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { | ||
| 249 | if (__lhs.year() < __rhs.year()) | ||
| 250 | return true; | ||
| 251 | if (__lhs.year() > __rhs.year()) | ||
| 252 | return false; | ||
| 253 | return __lhs.month_day_last() < __rhs.month_day_last(); | ||
| 254 | } | ||
| 255 | |||
| 256 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool | ||
| 257 | operator>(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { | ||
| 258 | return __rhs < __lhs; | ||
| 259 | } | ||
| 260 | |||
| 261 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool | ||
| 262 | operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { | ||
| 263 | return !(__rhs < __lhs); | ||
| 264 | } | ||
| 265 | |||
| 266 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool | ||
| 267 | operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { | ||
| 268 | return !(__lhs < __rhs); | ||
| 269 | } | 247 | } |
| 270 | 248 | ||
| 271 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept { | 249 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept { |
lib/libcxx/include/__chrono/zoned_time.h created+227| ... | @@ -0,0 +1,227 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___CHRONO_ZONED_TIME_H | ||
| 13 | #define _LIBCPP___CHRONO_ZONED_TIME_H | ||
| 14 | |||
| 15 | #include <version> | ||
| 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 18 | |||
| 19 | # include <__chrono/calendar.h> | ||
| 20 | # include <__chrono/duration.h> | ||
| 21 | # include <__chrono/sys_info.h> | ||
| 22 | # include <__chrono/system_clock.h> | ||
| 23 | # include <__chrono/time_zone.h> | ||
| 24 | # include <__chrono/tzdb_list.h> | ||
| 25 | # include <__config> | ||
| 26 | # include <__fwd/string_view.h> | ||
| 27 | # include <__type_traits/common_type.h> | ||
| 28 | # include <__type_traits/conditional.h> | ||
| 29 | # include <__type_traits/remove_cvref.h> | ||
| 30 | # include <__utility/move.h> | ||
| 31 | |||
| 32 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 33 | # pragma GCC system_header | ||
| 34 | # endif | ||
| 35 | |||
| 36 | _LIBCPP_PUSH_MACROS | ||
| 37 | # include <__undef_macros> | ||
| 38 | |||
| 39 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 40 | |||
| 41 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 42 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 43 | |||
| 44 | namespace chrono { | ||
| 45 | |||
| 46 | template <class> | ||
| 47 | struct zoned_traits {}; | ||
| 48 | |||
| 49 | template <> | ||
| 50 | struct zoned_traits<const time_zone*> { | ||
| 51 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static const time_zone* default_zone() { return chrono::locate_zone("UTC"); } | ||
| 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static const time_zone* locate_zone(string_view __name) { | ||
| 53 | return chrono::locate_zone(__name); | ||
| 54 | } | ||
| 55 | }; | ||
| 56 | |||
| 57 | template <class _Duration, class _TimeZonePtr = const time_zone*> | ||
| 58 | class zoned_time { | ||
| 59 | // [time.zone.zonedtime.ctor]/2 | ||
| 60 | static_assert(__is_duration<_Duration>::value, | ||
| 61 | "the program is ill-formed since _Duration is not a specialization of std::chrono::duration"); | ||
| 62 | |||
| 63 | // The wording uses the constraints like | ||
| 64 | // constructible_from<zoned_time, decltype(__traits::locate_zone(string_view{}))> | ||
| 65 | // Using these constraints in the code causes the compiler to give an | ||
| 66 | // error that the constraint depends on itself. To avoid that issue use | ||
| 67 | // the fact it is possible to create this object from a _TimeZonePtr. | ||
| 68 | using __traits = zoned_traits<_TimeZonePtr>; | ||
| 69 | |||
| 70 | public: | ||
| 71 | using duration = common_type_t<_Duration, seconds>; | ||
| 72 | |||
| 73 | _LIBCPP_HIDE_FROM_ABI zoned_time() | ||
| 74 | requires requires { __traits::default_zone(); } | ||
| 75 | : __zone_{__traits::default_zone()}, __tp_{} {} | ||
| 76 | |||
| 77 | _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time&) = default; | ||
| 78 | _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const zoned_time&) = default; | ||
| 79 | |||
| 80 | _LIBCPP_HIDE_FROM_ABI zoned_time(const sys_time<_Duration>& __tp) | ||
| 81 | requires requires { __traits::default_zone(); } | ||
| 82 | : __zone_{__traits::default_zone()}, __tp_{__tp} {} | ||
| 83 | |||
| 84 | _LIBCPP_HIDE_FROM_ABI explicit zoned_time(_TimeZonePtr __zone) : __zone_{std::move(__zone)}, __tp_{} {} | ||
| 85 | |||
| 86 | _LIBCPP_HIDE_FROM_ABI explicit zoned_time(string_view __name) | ||
| 87 | requires(requires { __traits::locate_zone(string_view{}); } && | ||
| 88 | constructible_from<_TimeZonePtr, decltype(__traits::locate_zone(string_view{}))>) | ||
| 89 | : __zone_{__traits::locate_zone(__name)}, __tp_{} {} | ||
| 90 | |||
| 91 | template <class _Duration2> | ||
| 92 | _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time<_Duration2, _TimeZonePtr>& __zt) | ||
| 93 | requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>> | ||
| 94 | : __zone_{__zt.get_time_zone()}, __tp_{__zt.get_sys_time()} {} | ||
| 95 | |||
| 96 | _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const sys_time<_Duration>& __tp) | ||
| 97 | : __zone_{std::move(__zone)}, __tp_{__tp} {} | ||
| 98 | |||
| 99 | _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const sys_time<_Duration>& __tp) | ||
| 100 | requires requires { _TimeZonePtr{__traits::locate_zone(string_view{})}; } | ||
| 101 | : zoned_time{__traits::locate_zone(__name), __tp} {} | ||
| 102 | |||
| 103 | _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp) | ||
| 104 | requires(is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})), | ||
| 105 | sys_time<duration>>) | ||
| 106 | : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp)} {} | ||
| 107 | |||
| 108 | _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp) | ||
| 109 | requires(requires { | ||
| 110 | _TimeZonePtr{__traits::locate_zone(string_view{})}; | ||
| 111 | } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})), | ||
| 112 | sys_time<duration>>) | ||
| 113 | : zoned_time{__traits::locate_zone(__name), __tp} {} | ||
| 114 | |||
| 115 | _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp, choose __c) | ||
| 116 | requires(is_convertible_v< | ||
| 117 | decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)), | ||
| 118 | sys_time<duration>>) | ||
| 119 | : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp, __c)} {} | ||
| 120 | |||
| 121 | _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp, choose __c) | ||
| 122 | requires(requires { | ||
| 123 | _TimeZonePtr{__traits::locate_zone(string_view{})}; | ||
| 124 | } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)), | ||
| 125 | sys_time<duration>>) | ||
| 126 | : zoned_time{__traits::locate_zone(__name), __tp, __c} {} | ||
| 127 | |||
| 128 | template <class _Duration2, class _TimeZonePtr2> | ||
| 129 | _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const zoned_time<_Duration2, _TimeZonePtr2>& __zt) | ||
| 130 | requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>> | ||
| 131 | : __zone_{std::move(__zone)}, __tp_{__zt.get_sys_time()} {} | ||
| 132 | |||
| 133 | // per wording choose has no effect | ||
| 134 | template <class _Duration2, class _TimeZonePtr2> | ||
| 135 | _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const zoned_time<_Duration2, _TimeZonePtr2>& __zt, choose) | ||
| 136 | requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>> | ||
| 137 | : __zone_{std::move(__zone)}, __tp_{__zt.get_sys_time()} {} | ||
| 138 | |||
| 139 | template <class _Duration2, class _TimeZonePtr2> | ||
| 140 | _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const zoned_time<_Duration2, _TimeZonePtr2>& __zt) | ||
| 141 | requires(requires { | ||
| 142 | _TimeZonePtr{__traits::locate_zone(string_view{})}; | ||
| 143 | } && is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>) | ||
| 144 | : zoned_time{__traits::locate_zone(__name), __zt} {} | ||
| 145 | |||
| 146 | template <class _Duration2, class _TimeZonePtr2> | ||
| 147 | _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const zoned_time<_Duration2, _TimeZonePtr2>& __zt, choose __c) | ||
| 148 | requires(requires { | ||
| 149 | _TimeZonePtr{__traits::locate_zone(string_view{})}; | ||
| 150 | } && is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>) | ||
| 151 | : zoned_time{__traits::locate_zone(__name), __zt, __c} {} | ||
| 152 | |||
| 153 | _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) { | ||
| 154 | __tp_ = __tp; | ||
| 155 | return *this; | ||
| 156 | } | ||
| 157 | |||
| 158 | _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& __tp) { | ||
| 159 | // TODO TZDB This seems wrong. | ||
| 160 | // Assigning a non-existent or ambiguous time will throw and not satisfy | ||
| 161 | // the post condition. This seems quite odd; I constructed an object with | ||
| 162 | // choose::earliest and that choice is not respected. | ||
| 163 | // what did LEWG do with this. | ||
| 164 | // MSVC STL and libstdc++ behave the same | ||
| 165 | __tp_ = __zone_->to_sys(__tp); | ||
| 166 | return *this; | ||
| 167 | } | ||
| 168 | |||
| 169 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time<duration>() const { return get_sys_time(); } | ||
| 170 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time<duration>() const { return get_local_time(); } | ||
| 171 | |||
| 172 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { return __zone_; } | ||
| 173 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time<duration> get_local_time() const { return __zone_->to_local(__tp_); } | ||
| 174 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<duration> get_sys_time() const { return __tp_; } | ||
| 175 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return __zone_->get_info(__tp_); } | ||
| 176 | |||
| 177 | private: | ||
| 178 | _TimeZonePtr __zone_; | ||
| 179 | sys_time<duration> __tp_; | ||
| 180 | }; | ||
| 181 | |||
| 182 | zoned_time() -> zoned_time<seconds>; | ||
| 183 | |||
| 184 | template <class _Duration> | ||
| 185 | zoned_time(sys_time<_Duration>) -> zoned_time<common_type_t<_Duration, seconds>>; | ||
| 186 | |||
| 187 | template <class _TimeZonePtrOrName> | ||
| 188 | using __time_zone_representation = | ||
| 189 | conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>, | ||
| 190 | const time_zone*, | ||
| 191 | remove_cvref_t<_TimeZonePtrOrName>>; | ||
| 192 | |||
| 193 | template <class _TimeZonePtrOrName> | ||
| 194 | zoned_time(_TimeZonePtrOrName&&) -> zoned_time<seconds, __time_zone_representation<_TimeZonePtrOrName>>; | ||
| 195 | |||
| 196 | template <class _TimeZonePtrOrName, class _Duration> | ||
| 197 | zoned_time(_TimeZonePtrOrName&&, sys_time<_Duration>) | ||
| 198 | -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; | ||
| 199 | |||
| 200 | template <class _TimeZonePtrOrName, class _Duration> | ||
| 201 | zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest) | ||
| 202 | -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; | ||
| 203 | |||
| 204 | template <class _Duration, class _TimeZonePtrOrName, class TimeZonePtr2> | ||
| 205 | zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = choose::earliest) | ||
| 206 | -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; | ||
| 207 | |||
| 208 | using zoned_seconds = zoned_time<seconds>; | ||
| 209 | |||
| 210 | template <class _Duration1, class _Duration2, class _TimeZonePtr> | ||
| 211 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 212 | operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_Duration2, _TimeZonePtr>& __rhs) { | ||
| 213 | return __lhs.get_time_zone() == __rhs.get_time_zone() && __lhs.get_sys_time() == __rhs.get_sys_time(); | ||
| 214 | } | ||
| 215 | |||
| 216 | } // namespace chrono | ||
| 217 | |||
| 218 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | ||
| 219 | // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 220 | |||
| 221 | _LIBCPP_END_NAMESPACE_STD | ||
| 222 | |||
| 223 | _LIBCPP_POP_MACROS | ||
| 224 | |||
| 225 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | ||
| 226 | |||
| 227 | #endif // _LIBCPP___CHRONO_ZONED_TIME_H | ||
lib/libcxx/include/__compare/partial_order.h+2| ... | @@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | // [cmp.alg] | 29 | // [cmp.alg] |
| 30 | namespace __partial_order { | 30 | namespace __partial_order { |
| 31 | void partial_order() = delete; | ||
| 32 | |||
| 31 | struct __fn { | 33 | struct __fn { |
| 32 | // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here | 34 | // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here |
| 33 | template <class _Tp, class _Up> | 35 | template <class _Tp, class _Up> |
lib/libcxx/include/__compare/strong_order.h+15-10| ... | @@ -13,11 +13,14 @@ | ... | @@ -13,11 +13,14 @@ |
| 13 | #include <__compare/compare_three_way.h> | 13 | #include <__compare/compare_three_way.h> |
| 14 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__math/exponential_functions.h> | ||
| 17 | #include <__math/traits.h> | ||
| 16 | #include <__type_traits/conditional.h> | 18 | #include <__type_traits/conditional.h> |
| 17 | #include <__type_traits/decay.h> | 19 | #include <__type_traits/decay.h> |
| 20 | #include <__type_traits/is_floating_point.h> | ||
| 21 | #include <__type_traits/is_same.h> | ||
| 18 | #include <__utility/forward.h> | 22 | #include <__utility/forward.h> |
| 19 | #include <__utility/priority_tag.h> | 23 | #include <__utility/priority_tag.h> |
| 20 | #include <cmath> | ||
| 21 | #include <cstdint> | 24 | #include <cstdint> |
| 22 | #include <limits> | 25 | #include <limits> |
| 23 | 26 | ||
| ... | @@ -34,6 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -34,6 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 37 | ||
| 35 | // [cmp.alg] | 38 | // [cmp.alg] |
| 36 | namespace __strong_order { | 39 | namespace __strong_order { |
| 40 | void strong_order() = delete; | ||
| 41 | |||
| 37 | struct __fn { | 42 | struct __fn { |
| 38 | // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here | 43 | // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here |
| 39 | template <class _Tp, class _Up> | 44 | template <class _Tp, class _Up> |
| ... | @@ -66,27 +71,27 @@ struct __fn { | ... | @@ -66,27 +71,27 @@ struct __fn { |
| 66 | return strong_ordering::greater; | 71 | return strong_ordering::greater; |
| 67 | } else if (__t == __u) { | 72 | } else if (__t == __u) { |
| 68 | if constexpr (numeric_limits<_Dp>::radix == 2) { | 73 | if constexpr (numeric_limits<_Dp>::radix == 2) { |
| 69 | return std::signbit(__u) <=> std::signbit(__t); | 74 | return __math::signbit(__u) <=> __math::signbit(__t); |
| 70 | } else { | 75 | } else { |
| 71 | // This is bullet 3 of the IEEE754 algorithm, relevant | 76 | // This is bullet 3 of the IEEE754 algorithm, relevant |
| 72 | // only for decimal floating-point; | 77 | // only for decimal floating-point; |
| 73 | // see https://stackoverflow.com/questions/69068075/ | 78 | // see https://stackoverflow.com/questions/69068075/ |
| 74 | if (__t == 0 || std::isinf(__t)) { | 79 | if (__t == 0 || __math::isinf(__t)) { |
| 75 | return std::signbit(__u) <=> std::signbit(__t); | 80 | return __math::signbit(__u) <=> __math::signbit(__t); |
| 76 | } else { | 81 | } else { |
| 77 | int __texp, __uexp; | 82 | int __texp, __uexp; |
| 78 | (void)std::frexp(__t, &__texp); | 83 | (void)__math::frexp(__t, &__texp); |
| 79 | (void)std::frexp(__u, &__uexp); | 84 | (void)__math::frexp(__u, &__uexp); |
| 80 | return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp); | 85 | return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp); |
| 81 | } | 86 | } |
| 82 | } | 87 | } |
| 83 | } else { | 88 | } else { |
| 84 | // They're unordered, so one of them must be a NAN. | 89 | // They're unordered, so one of them must be a NAN. |
| 85 | // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. | 90 | // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. |
| 86 | bool __t_is_nan = std::isnan(__t); | 91 | bool __t_is_nan = __math::isnan(__t); |
| 87 | bool __u_is_nan = std::isnan(__u); | 92 | bool __u_is_nan = __math::isnan(__u); |
| 88 | bool __t_is_negative = std::signbit(__t); | 93 | bool __t_is_negative = __math::signbit(__t); |
| 89 | bool __u_is_negative = std::signbit(__u); | 94 | bool __u_is_negative = __math::signbit(__u); |
| 90 | using _IntType = | 95 | using _IntType = |
| 91 | conditional_t< sizeof(__t) == sizeof(int32_t), | 96 | conditional_t< sizeof(__t) == sizeof(int32_t), |
| 92 | int32_t, | 97 | int32_t, |
lib/libcxx/include/__compare/synth_three_way.h+2-7| ... | @@ -25,12 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -25,12 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | // [expos.only.func] | 26 | // [expos.only.func] |
| 27 | 27 | ||
| 28 | // TODO MODULES restore the lamba to match the Standard. | 28 | _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u) |
| 29 | // See https://github.com/llvm/llvm-project/issues/57222 | ||
| 30 | //_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = | ||
| 31 | // []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u) | ||
| 32 | template <class _Tp, class _Up> | ||
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up& __u) | ||
| 34 | requires requires { | 29 | requires requires { |
| 35 | { __t < __u } -> __boolean_testable; | 30 | { __t < __u } -> __boolean_testable; |
| 36 | { __u < __t } -> __boolean_testable; | 31 | { __u < __t } -> __boolean_testable; |
| ... | @@ -45,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up | ... | @@ -45,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up |
| 45 | return weak_ordering::greater; | 40 | return weak_ordering::greater; |
| 46 | return weak_ordering::equivalent; | 41 | return weak_ordering::equivalent; |
| 47 | } | 42 | } |
| 48 | } | 43 | }; |
| 49 | 44 | ||
| 50 | template <class _Tp, class _Up = _Tp> | 45 | template <class _Tp, class _Up = _Tp> |
| 51 | using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>())); | 46 | using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>())); |
lib/libcxx/include/__compare/weak_order.h+9-5| ... | @@ -13,10 +13,12 @@ | ... | @@ -13,10 +13,12 @@ |
| 13 | #include <__compare/ordering.h> | 13 | #include <__compare/ordering.h> |
| 14 | #include <__compare/strong_order.h> | 14 | #include <__compare/strong_order.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__math/traits.h> | ||
| 16 | #include <__type_traits/decay.h> | 17 | #include <__type_traits/decay.h> |
| 18 | #include <__type_traits/is_floating_point.h> | ||
| 19 | #include <__type_traits/is_same.h> | ||
| 17 | #include <__utility/forward.h> | 20 | #include <__utility/forward.h> |
| 18 | #include <__utility/priority_tag.h> | 21 | #include <__utility/priority_tag.h> |
| 19 | #include <cmath> | ||
| 20 | 22 | ||
| 21 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | 23 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 22 | # pragma GCC system_header | 24 | # pragma GCC system_header |
| ... | @@ -28,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 30 | ||
| 29 | // [cmp.alg] | 31 | // [cmp.alg] |
| 30 | namespace __weak_order { | 32 | namespace __weak_order { |
| 33 | void weak_order() = delete; | ||
| 34 | |||
| 31 | struct __fn { | 35 | struct __fn { |
| 32 | // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here | 36 | // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here |
| 33 | template <class _Tp, class _Up> | 37 | template <class _Tp, class _Up> |
| ... | @@ -51,10 +55,10 @@ struct __fn { | ... | @@ -51,10 +55,10 @@ struct __fn { |
| 51 | return weak_ordering::greater; | 55 | return weak_ordering::greater; |
| 52 | } else { | 56 | } else { |
| 53 | // Otherwise, at least one of them is a NaN. | 57 | // Otherwise, at least one of them is a NaN. |
| 54 | bool __t_is_nan = std::isnan(__t); | 58 | bool __t_is_nan = __math::isnan(__t); |
| 55 | bool __u_is_nan = std::isnan(__u); | 59 | bool __u_is_nan = __math::isnan(__u); |
| 56 | bool __t_is_negative = std::signbit(__t); | 60 | bool __t_is_negative = __math::signbit(__t); |
| 57 | bool __u_is_negative = std::signbit(__u); | 61 | bool __u_is_negative = __math::signbit(__u); |
| 58 | if (__t_is_nan && __u_is_nan) { | 62 | if (__t_is_nan && __u_is_nan) { |
| 59 | return (__u_is_negative <=> __t_is_negative); | 63 | return (__u_is_negative <=> __t_is_negative); |
| 60 | } else if (__t_is_nan) { | 64 | } else if (__t_is_nan) { |
lib/libcxx/include/__concepts/class_or_enum.h-5| ... | @@ -28,11 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,11 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | template <class _Tp> | 28 | template <class _Tp> |
| 29 | concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; | 29 | concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; |
| 30 | 30 | ||
| 31 | // Work around Clang bug https://llvm.org/PR52970 | ||
| 32 | // TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14). | ||
| 33 | template <class _Tp> | ||
| 34 | concept __workaround_52970 = is_class_v<__remove_cvref_t<_Tp>> || is_union_v<__remove_cvref_t<_Tp>>; | ||
| 35 | |||
| 36 | #endif // _LIBCPP_STD_VER >= 20 | 31 | #endif // _LIBCPP_STD_VER >= 20 |
| 37 | 32 | ||
| 38 | _LIBCPP_END_NAMESPACE_STD | 33 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__concepts/swappable.h+2-2| ... | @@ -15,8 +15,8 @@ | ... | @@ -15,8 +15,8 @@ |
| 15 | #include <__concepts/constructible.h> | 15 | #include <__concepts/constructible.h> |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__type_traits/extent.h> | 17 | #include <__type_traits/extent.h> |
| 18 | #include <__type_traits/is_nothrow_move_assignable.h> | 18 | #include <__type_traits/is_nothrow_assignable.h> |
| 19 | #include <__type_traits/is_nothrow_move_constructible.h> | 19 | #include <__type_traits/is_nothrow_constructible.h> |
| 20 | #include <__type_traits/remove_cvref.h> | 20 | #include <__type_traits/remove_cvref.h> |
| 21 | #include <__utility/exchange.h> | 21 | #include <__utility/exchange.h> |
| 22 | #include <__utility/forward.h> | 22 | #include <__utility/forward.h> |
lib/libcxx/include/__condition_variable/condition_variable.h+2-1| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H | 9 | #ifndef _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H |
| 10 | #define _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H | 10 | #define _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H |
| 11 | 11 | ||
| 12 | #include <__chrono/duration.h> | ||
| 12 | #include <__chrono/steady_clock.h> | 13 | #include <__chrono/steady_clock.h> |
| 13 | #include <__chrono/system_clock.h> | 14 | #include <__chrono/system_clock.h> |
| 14 | #include <__chrono/time_point.h> | 15 | #include <__chrono/time_point.h> |
| ... | @@ -16,7 +17,7 @@ | ... | @@ -16,7 +17,7 @@ |
| 16 | #include <__mutex/mutex.h> | 17 | #include <__mutex/mutex.h> |
| 17 | #include <__mutex/unique_lock.h> | 18 | #include <__mutex/unique_lock.h> |
| 18 | #include <__system_error/system_error.h> | 19 | #include <__system_error/system_error.h> |
| 19 | #include <__threading_support> | 20 | #include <__thread/support.h> |
| 20 | #include <__type_traits/enable_if.h> | 21 | #include <__type_traits/enable_if.h> |
| 21 | #include <__type_traits/is_floating_point.h> | 22 | #include <__type_traits/is_floating_point.h> |
| 22 | #include <__utility/move.h> | 23 | #include <__utility/move.h> |
lib/libcxx/include/__config+117-454| ... | @@ -11,58 +11,23 @@ | ... | @@ -11,58 +11,23 @@ |
| 11 | #define _LIBCPP___CONFIG | 11 | #define _LIBCPP___CONFIG |
| 12 | 12 | ||
| 13 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | 13 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ |
| 14 | #include <__configuration/abi.h> | ||
| 15 | #include <__configuration/availability.h> | ||
| 16 | #include <__configuration/compiler.h> | ||
| 17 | #include <__configuration/platform.h> | ||
| 14 | 18 | ||
| 15 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 16 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| 17 | #endif | 21 | #endif |
| 18 | 22 | ||
| 19 | #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | ||
| 20 | # pragma clang deprecated( \ | ||
| 21 | _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES, \ | ||
| 22 | "_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19") | ||
| 23 | #endif | ||
| 24 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | ||
| 25 | # pragma clang deprecated( \ | ||
| 26 | _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES, \ | ||
| 27 | "_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19") | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #if defined(__apple_build_version__) | ||
| 31 | // Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403) | ||
| 32 | # define _LIBCPP_COMPILER_CLANG_BASED | ||
| 33 | # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) | ||
| 34 | #elif defined(__clang__) | ||
| 35 | # define _LIBCPP_COMPILER_CLANG_BASED | ||
| 36 | # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) | ||
| 37 | #elif defined(__GNUC__) | ||
| 38 | # define _LIBCPP_COMPILER_GCC | ||
| 39 | # define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__) | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifdef __cplusplus | 23 | #ifdef __cplusplus |
| 43 | 24 | ||
| 44 | // Warn if a compiler version is used that is not supported anymore | ||
| 45 | // LLVM RELEASE Update the minimum compiler versions | ||
| 46 | # if defined(_LIBCPP_CLANG_VER) | ||
| 47 | # if _LIBCPP_CLANG_VER < 1600 | ||
| 48 | # warning "Libc++ only supports Clang 16 and later" | ||
| 49 | # endif | ||
| 50 | # elif defined(_LIBCPP_APPLE_CLANG_VER) | ||
| 51 | # if _LIBCPP_APPLE_CLANG_VER < 1500 | ||
| 52 | # warning "Libc++ only supports AppleClang 15 and later" | ||
| 53 | # endif | ||
| 54 | # elif defined(_LIBCPP_GCC_VER) | ||
| 55 | # if _LIBCPP_GCC_VER < 1300 | ||
| 56 | # warning "Libc++ only supports GCC 13 and later" | ||
| 57 | # endif | ||
| 58 | # endif | ||
| 59 | |||
| 60 | // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html | 25 | // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html |
| 61 | 26 | ||
| 62 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. | 27 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. |
| 63 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is | 28 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is |
| 64 | // defined to XXYYZZ. | 29 | // defined to XXYYZZ. |
| 65 | # define _LIBCPP_VERSION 180100 | 30 | # define _LIBCPP_VERSION 190100 |
| 66 | 31 | ||
| 67 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y | 32 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y |
| 68 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) | 33 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) |
| ... | @@ -71,170 +36,12 @@ | ... | @@ -71,170 +36,12 @@ |
| 71 | # define _LIBCPP_FREESTANDING | 36 | # define _LIBCPP_FREESTANDING |
| 72 | # endif | 37 | # endif |
| 73 | 38 | ||
| 74 | // NOLINTBEGIN(libcpp-cpp-version-check) | ||
| 75 | # ifndef _LIBCPP_STD_VER | ||
| 76 | # if __cplusplus <= 201103L | ||
| 77 | # define _LIBCPP_STD_VER 11 | ||
| 78 | # elif __cplusplus <= 201402L | ||
| 79 | # define _LIBCPP_STD_VER 14 | ||
| 80 | # elif __cplusplus <= 201703L | ||
| 81 | # define _LIBCPP_STD_VER 17 | ||
| 82 | # elif __cplusplus <= 202002L | ||
| 83 | # define _LIBCPP_STD_VER 20 | ||
| 84 | # elif __cplusplus <= 202302L | ||
| 85 | # define _LIBCPP_STD_VER 23 | ||
| 86 | # else | ||
| 87 | // Expected release year of the next C++ standard | ||
| 88 | # define _LIBCPP_STD_VER 26 | ||
| 89 | # endif | ||
| 90 | # endif // _LIBCPP_STD_VER | ||
| 91 | // NOLINTEND(libcpp-cpp-version-check) | ||
| 92 | |||
| 93 | # if defined(__ELF__) | ||
| 94 | # define _LIBCPP_OBJECT_FORMAT_ELF 1 | ||
| 95 | # elif defined(__MACH__) | ||
| 96 | # define _LIBCPP_OBJECT_FORMAT_MACHO 1 | ||
| 97 | # elif defined(_WIN32) | ||
| 98 | # define _LIBCPP_OBJECT_FORMAT_COFF 1 | ||
| 99 | # elif defined(__wasm__) | ||
| 100 | # define _LIBCPP_OBJECT_FORMAT_WASM 1 | ||
| 101 | # elif defined(_AIX) | ||
| 102 | # define _LIBCPP_OBJECT_FORMAT_XCOFF 1 | ||
| 103 | # else | ||
| 104 | // ... add new file formats here ... | ||
| 105 | # endif | ||
| 106 | |||
| 107 | // ABI { | ||
| 108 | |||
| 109 | # if _LIBCPP_ABI_VERSION >= 2 | ||
| 110 | // Change short string representation so that string data starts at offset 0, | ||
| 111 | // improving its alignment in some cases. | ||
| 112 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 113 | // Fix deque iterator type in order to support incomplete types. | ||
| 114 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | ||
| 115 | // Fix undefined behavior in how std::list stores its linked nodes. | ||
| 116 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | ||
| 117 | // Fix undefined behavior in how __tree stores its end and parent nodes. | ||
| 118 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 119 | // Fix undefined behavior in how __hash_table stores its pointer types. | ||
| 120 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | ||
| 121 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | ||
| 122 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | ||
| 123 | // Define a key function for `bad_function_call` in the library, to centralize | ||
| 124 | // its vtable and typeinfo to libc++ rather than having all other libraries | ||
| 125 | // using that class define their own copies. | ||
| 126 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | ||
| 127 | // Override the default return value of exception::what() for | ||
| 128 | // bad_function_call::what() with a string that is specific to | ||
| 129 | // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break | ||
| 130 | // because it changes the vtable layout of bad_function_call. | ||
| 131 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | ||
| 132 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. | ||
| 133 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 134 | // Give reverse_iterator<T> one data member of type T, not two. | ||
| 135 | // Also, in C++17 and later, don't derive iterator types from std::iterator. | ||
| 136 | # define _LIBCPP_ABI_NO_ITERATOR_BASES | ||
| 137 | // Use the smallest possible integer type to represent the index of the variant. | ||
| 138 | // Previously libc++ used "unsigned int" exclusively. | ||
| 139 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | ||
| 140 | // Unstable attempt to provide a more optimized std::function | ||
| 141 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | ||
| 142 | // All the regex constants must be distinct and nonzero. | ||
| 143 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | ||
| 144 | // Re-worked external template instantiations for std::string with a focus on | ||
| 145 | // performance and fast-path inlining. | ||
| 146 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | ||
| 147 | // Enable clang::trivial_abi on std::unique_ptr. | ||
| 148 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | ||
| 149 | // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr | ||
| 150 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | ||
| 151 | // std::random_device holds some state when it uses an implementation that gets | ||
| 152 | // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this | ||
| 153 | // implementation to another one on a platform that has already shipped | ||
| 154 | // std::random_device, one needs to retain the same object layout to remain ABI | ||
| 155 | // compatible. This switch removes these workarounds for platforms that don't care | ||
| 156 | // about ABI compatibility. | ||
| 157 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | ||
| 158 | // Don't export the legacy __basic_string_common class and its methods from the built library. | ||
| 159 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | ||
| 160 | // Don't export the legacy __vector_base_common class and its methods from the built library. | ||
| 161 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | ||
| 162 | // According to the Standard, `bitset::operator[] const` returns bool | ||
| 163 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | ||
| 164 | // Fix the implementation of CityHash used for std::hash<fundamental-type>. | ||
| 165 | // This is an ABI break because `std::hash` will return a different result, | ||
| 166 | // which means that hashing the same object in translation units built against | ||
| 167 | // different versions of libc++ can return inconsistent results. This is especially | ||
| 168 | // tricky since std::hash is used in the implementation of unordered containers. | ||
| 169 | // | ||
| 170 | // The incorrect implementation of CityHash has the problem that it drops some | ||
| 171 | // bits on the floor. | ||
| 172 | # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION | ||
| 173 | // Remove the base 10 implementation of std::to_chars from the dylib. | ||
| 174 | // The implementation moved to the header, but we still export the symbols from | ||
| 175 | // the dylib for backwards compatibility. | ||
| 176 | # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | ||
| 177 | # elif _LIBCPP_ABI_VERSION == 1 | ||
| 178 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) | ||
| 179 | // Enable compiling copies of now inline methods into the dylib to support | ||
| 180 | // applications compiled against older libraries. This is unnecessary with | ||
| 181 | // COFF dllexport semantics, since dllexport forces a non-inline definition | ||
| 182 | // of inline functions to be emitted anyway. Our own non-inline copy would | ||
| 183 | // conflict with the dllexport-emitted copy, so we disable it. For XCOFF, | ||
| 184 | // the linker will take issue with the symbols in the shared object if the | ||
| 185 | // weak inline methods get visibility (such as from -fvisibility-inlines-hidden), | ||
| 186 | // so disable it. | ||
| 187 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | ||
| 188 | # endif | ||
| 189 | // Feature macros for disabling pre ABI v1 features. All of these options | ||
| 190 | // are deprecated. | ||
| 191 | # if defined(__FreeBSD__) && __FreeBSD__ < 14 | ||
| 192 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR | ||
| 193 | # endif | ||
| 194 | // For XCOFF linkers, we have problems if we see a weak hidden version of a symbol | ||
| 195 | // in user code (like you get with -fvisibility-inlines-hidden) and then a strong def | ||
| 196 | // in the library, so we need to always rely on the library version. | ||
| 197 | # if defined(_AIX) | ||
| 198 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | ||
| 199 | # endif | ||
| 200 | # endif | ||
| 201 | |||
| 202 | # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 | ||
| 203 | // Define a key function for `bad_function_call` in the library, to centralize | ||
| 204 | // its vtable and typeinfo to libc++ rather than having all other libraries | ||
| 205 | // using that class define their own copies. | ||
| 206 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | ||
| 207 | # endif | ||
| 208 | |||
| 209 | // We had some bugs where we use [[no_unique_address]] together with construct_at, | ||
| 210 | // which causes UB as the call on construct_at could write to overlapping subobjects | ||
| 211 | // | ||
| 212 | // https://github.com/llvm/llvm-project/issues/70506 | ||
| 213 | // https://github.com/llvm/llvm-project/issues/70494 | ||
| 214 | // | ||
| 215 | // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions. | ||
| 216 | // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. | ||
| 217 | # define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua"))) | ||
| 218 | |||
| 219 | // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's | ||
| 220 | // within the bounds of the original container and asserts it on every dereference. | ||
| 221 | // | ||
| 222 | // ABI impact: changes the iterator type of the relevant containers. | ||
| 223 | // | ||
| 224 | // Supported containers: | ||
| 225 | // - `span`; | ||
| 226 | // - `string_view`; | ||
| 227 | // - `array`. | ||
| 228 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS | ||
| 229 | |||
| 230 | // } ABI | ||
| 231 | |||
| 232 | // HARDENING { | 39 | // HARDENING { |
| 233 | 40 | ||
| 234 | // TODO(hardening): deprecate this in LLVM 19. | ||
| 235 | // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes) | 41 | // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes) |
| 236 | // equivalent to setting the extensive mode. | 42 | // equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20. |
| 237 | # ifdef _LIBCPP_ENABLE_ASSERTIONS | 43 | # ifdef _LIBCPP_ENABLE_ASSERTIONS |
| 44 | # warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" | ||
| 238 | # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 | 45 | # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 |
| 239 | # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" | 46 | # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" |
| 240 | # endif | 47 | # endif |
| ... | @@ -325,6 +132,12 @@ | ... | @@ -325,6 +132,12 @@ |
| 325 | // clang-format on | 132 | // clang-format on |
| 326 | 133 | ||
| 327 | # ifndef _LIBCPP_HARDENING_MODE | 134 | # ifndef _LIBCPP_HARDENING_MODE |
| 135 | |||
| 136 | # ifndef _LIBCPP_HARDENING_MODE_DEFAULT | ||
| 137 | # error _LIBCPP_HARDENING_MODE_DEFAULT is not defined. This definition should be set at configuration time in the \ | ||
| 138 | `__config_site` header, please make sure your installation of libc++ is not broken. | ||
| 139 | # endif | ||
| 140 | |||
| 328 | # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT | 141 | # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT |
| 329 | # endif | 142 | # endif |
| 330 | 143 | ||
| ... | @@ -339,87 +152,6 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \ | ... | @@ -339,87 +152,6 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \ |
| 339 | _LIBCPP_HARDENING_MODE_DEBUG | 152 | _LIBCPP_HARDENING_MODE_DEBUG |
| 340 | # endif | 153 | # endif |
| 341 | 154 | ||
| 342 | // clang-format off | ||
| 343 | // Fast hardening mode checks. | ||
| 344 | |||
| 345 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST | ||
| 346 | |||
| 347 | // Enabled checks. | ||
| 348 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 349 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 350 | // Disabled checks. | ||
| 351 | // On most modern platforms, dereferencing a null pointer does not lead to an actual memory access. | ||
| 352 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 353 | // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security | ||
| 354 | // vulnerability. | ||
| 355 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) | ||
| 356 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression) | ||
| 357 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 358 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) | ||
| 359 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression) | ||
| 360 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression) | ||
| 361 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | ||
| 362 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 363 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) | ||
| 364 | |||
| 365 | // Extensive hardening mode checks. | ||
| 366 | |||
| 367 | # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE | ||
| 368 | |||
| 369 | // Enabled checks. | ||
| 370 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 371 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 372 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 373 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 374 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 375 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 376 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 377 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 378 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 379 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 380 | // Disabled checks. | ||
| 381 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | ||
| 382 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 383 | |||
| 384 | // Debug hardening mode checks. | ||
| 385 | |||
| 386 | # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | ||
| 387 | |||
| 388 | // All checks enabled. | ||
| 389 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 390 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 391 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 392 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 393 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 394 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 395 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 396 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 397 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 398 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 399 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 400 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) | ||
| 401 | |||
| 402 | // Disable all checks if hardening is not enabled. | ||
| 403 | |||
| 404 | # else | ||
| 405 | |||
| 406 | // All checks disabled. | ||
| 407 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression) | ||
| 408 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression) | ||
| 409 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 410 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) | ||
| 411 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression) | ||
| 412 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 413 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) | ||
| 414 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression) | ||
| 415 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression) | ||
| 416 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | ||
| 417 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | ||
| 418 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) | ||
| 419 | |||
| 420 | # endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST | ||
| 421 | // clang-format on | ||
| 422 | |||
| 423 | // } HARDENING | 155 | // } HARDENING |
| 424 | 156 | ||
| 425 | # define _LIBCPP_TOSTRING2(x) #x | 157 | # define _LIBCPP_TOSTRING2(x) #x |
| ... | @@ -430,30 +162,15 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -430,30 +162,15 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 430 | # define _LIBCPP_CXX03_LANG | 162 | # define _LIBCPP_CXX03_LANG |
| 431 | # endif | 163 | # endif |
| 432 | 164 | ||
| 433 | # ifndef __has_attribute | ||
| 434 | # define __has_attribute(__x) 0 | ||
| 435 | # endif | ||
| 436 | |||
| 437 | # ifndef __has_builtin | ||
| 438 | # define __has_builtin(__x) 0 | ||
| 439 | # endif | ||
| 440 | |||
| 441 | # ifndef __has_extension | ||
| 442 | # define __has_extension(__x) 0 | ||
| 443 | # endif | ||
| 444 | |||
| 445 | # ifndef __has_feature | ||
| 446 | # define __has_feature(__x) 0 | ||
| 447 | # endif | ||
| 448 | |||
| 449 | # ifndef __has_cpp_attribute | ||
| 450 | # define __has_cpp_attribute(__x) 0 | ||
| 451 | # endif | ||
| 452 | |||
| 453 | # ifndef __has_constexpr_builtin | 165 | # ifndef __has_constexpr_builtin |
| 454 | # define __has_constexpr_builtin(x) 0 | 166 | # define __has_constexpr_builtin(x) 0 |
| 455 | # endif | 167 | # endif |
| 456 | 168 | ||
| 169 | // This checks wheter a Clang module is built | ||
| 170 | # ifndef __building_module | ||
| 171 | # define __building_module(...) 0 | ||
| 172 | # endif | ||
| 173 | |||
| 457 | // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by | 174 | // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by |
| 458 | // the compiler and '1' otherwise. | 175 | // the compiler and '1' otherwise. |
| 459 | # ifndef __is_identifier | 176 | # ifndef __is_identifier |
| ... | @@ -466,8 +183,8 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -466,8 +183,8 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 466 | 183 | ||
| 467 | # define __has_keyword(__x) !(__is_identifier(__x)) | 184 | # define __has_keyword(__x) !(__is_identifier(__x)) |
| 468 | 185 | ||
| 469 | # ifndef __has_include | 186 | # ifndef __has_warning |
| 470 | # define __has_include(...) 0 | 187 | # define __has_warning(...) 0 |
| 471 | # endif | 188 | # endif |
| 472 | 189 | ||
| 473 | # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L | 190 | # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L |
| ... | @@ -508,35 +225,14 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -508,35 +225,14 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 508 | # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) | 225 | # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) |
| 509 | # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL | 226 | # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL |
| 510 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN | 227 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN |
| 511 | # define _LIBCPP_HAS_NO_INCOMPLETE_TZDB | 228 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB |
| 512 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM | 229 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM |
| 513 | # endif | 230 | # endif |
| 514 | 231 | ||
| 515 | // Need to detect which libc we're using if we're on Linux. | ||
| 516 | # if defined(__linux__) | ||
| 517 | # include <features.h> | ||
| 518 | # if defined(__GLIBC_PREREQ) | ||
| 519 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) | ||
| 520 | # else | ||
| 521 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 | ||
| 522 | # endif // defined(__GLIBC_PREREQ) | ||
| 523 | # endif // defined(__linux__) | ||
| 524 | |||
| 525 | # if defined(__MVS__) | 232 | # if defined(__MVS__) |
| 526 | # include <features.h> // for __NATIVE_ASCII_F | 233 | # include <features.h> // for __NATIVE_ASCII_F |
| 527 | # endif | 234 | # endif |
| 528 | 235 | ||
| 529 | # ifndef __BYTE_ORDER__ | ||
| 530 | # error \ | ||
| 531 | "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform" | ||
| 532 | # endif | ||
| 533 | |||
| 534 | # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
| 535 | # define _LIBCPP_LITTLE_ENDIAN | ||
| 536 | # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | ||
| 537 | # define _LIBCPP_BIG_ENDIAN | ||
| 538 | # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | ||
| 539 | |||
| 540 | # if defined(_WIN32) | 236 | # if defined(_WIN32) |
| 541 | # define _LIBCPP_WIN32API | 237 | # define _LIBCPP_WIN32API |
| 542 | # define _LIBCPP_SHORT_WCHAR 1 | 238 | # define _LIBCPP_SHORT_WCHAR 1 |
| ... | @@ -618,7 +314,7 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -618,7 +314,7 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 618 | # define _ALIGNAS(x) alignas(x) | 314 | # define _ALIGNAS(x) alignas(x) |
| 619 | # define _LIBCPP_NORETURN [[noreturn]] | 315 | # define _LIBCPP_NORETURN [[noreturn]] |
| 620 | # define _NOEXCEPT noexcept | 316 | # define _NOEXCEPT noexcept |
| 621 | # define _NOEXCEPT_(x) noexcept(x) | 317 | # define _NOEXCEPT_(...) noexcept(__VA_ARGS__) |
| 622 | # define _LIBCPP_CONSTEXPR constexpr | 318 | # define _LIBCPP_CONSTEXPR constexpr |
| 623 | 319 | ||
| 624 | # else | 320 | # else |
| ... | @@ -630,7 +326,7 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -630,7 +326,7 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 630 | # define _LIBCPP_HAS_NO_NOEXCEPT | 326 | # define _LIBCPP_HAS_NO_NOEXCEPT |
| 631 | # define nullptr __nullptr | 327 | # define nullptr __nullptr |
| 632 | # define _NOEXCEPT throw() | 328 | # define _NOEXCEPT throw() |
| 633 | # define _NOEXCEPT_(x) | 329 | # define _NOEXCEPT_(...) |
| 634 | # define static_assert(...) _Static_assert(__VA_ARGS__) | 330 | # define static_assert(...) _Static_assert(__VA_ARGS__) |
| 635 | # define decltype(...) __decltype(__VA_ARGS__) | 331 | # define decltype(...) __decltype(__VA_ARGS__) |
| 636 | # define _LIBCPP_CONSTEXPR | 332 | # define _LIBCPP_CONSTEXPR |
| ... | @@ -640,63 +336,32 @@ typedef __char32_t char32_t; | ... | @@ -640,63 +336,32 @@ typedef __char32_t char32_t; |
| 640 | 336 | ||
| 641 | # endif | 337 | # endif |
| 642 | 338 | ||
| 643 | # if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L | ||
| 644 | # define _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 645 | # endif | ||
| 646 | |||
| 647 | # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) | 339 | # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) |
| 648 | 340 | ||
| 649 | # if defined(_LIBCPP_COMPILER_CLANG_BASED) | ||
| 650 | |||
| 651 | # if defined(__APPLE__) | ||
| 652 | # if defined(__i386__) || defined(__x86_64__) | ||
| 653 | // use old string layout on x86_64 and i386 | ||
| 654 | # elif defined(__arm__) | ||
| 655 | // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs | ||
| 656 | # if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2 | ||
| 657 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 658 | # endif | ||
| 659 | # else | ||
| 660 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 661 | # endif | ||
| 662 | # endif | ||
| 663 | |||
| 664 | // Objective-C++ features (opt-in) | 341 | // Objective-C++ features (opt-in) |
| 665 | # if __has_feature(objc_arc) | 342 | # if __has_feature(objc_arc) |
| 666 | # define _LIBCPP_HAS_OBJC_ARC | 343 | # define _LIBCPP_HAS_OBJC_ARC |
| 667 | # endif | 344 | # endif |
| 668 | |||
| 669 | # if __has_feature(objc_arc_weak) | ||
| 670 | # define _LIBCPP_HAS_OBJC_ARC_WEAK | ||
| 671 | # endif | ||
| 672 | |||
| 673 | # if __has_extension(blocks) | ||
| 674 | # define _LIBCPP_HAS_EXTENSION_BLOCKS | ||
| 675 | # endif | ||
| 676 | |||
| 677 | # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) | ||
| 678 | # define _LIBCPP_HAS_BLOCKS_RUNTIME | ||
| 679 | # endif | ||
| 680 | |||
| 681 | # if !__has_feature(address_sanitizer) | ||
| 682 | # define _LIBCPP_HAS_NO_ASAN | ||
| 683 | # endif | ||
| 684 | |||
| 685 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) | ||
| 686 | 345 | ||
| 687 | # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | 346 | # if __has_feature(objc_arc_weak) |
| 347 | # define _LIBCPP_HAS_OBJC_ARC_WEAK | ||
| 348 | # endif | ||
| 688 | 349 | ||
| 689 | # elif defined(_LIBCPP_COMPILER_GCC) | 350 | # if __has_extension(blocks) |
| 351 | # define _LIBCPP_HAS_EXTENSION_BLOCKS | ||
| 352 | # endif | ||
| 690 | 353 | ||
| 691 | # if !defined(__SANITIZE_ADDRESS__) | 354 | # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) |
| 692 | # define _LIBCPP_HAS_NO_ASAN | 355 | # define _LIBCPP_HAS_BLOCKS_RUNTIME |
| 693 | # endif | 356 | # endif |
| 694 | 357 | ||
| 695 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) | 358 | # if !__has_feature(address_sanitizer) |
| 359 | # define _LIBCPP_HAS_NO_ASAN | ||
| 360 | # endif | ||
| 696 | 361 | ||
| 697 | # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | 362 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) |
| 698 | 363 | ||
| 699 | # endif // _LIBCPP_COMPILER_[CLANG|GCC] | 364 | # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ |
| 700 | 365 | ||
| 701 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) | 366 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| 702 | 367 | ||
| ... | @@ -787,6 +452,23 @@ typedef __char32_t char32_t; | ... | @@ -787,6 +452,23 @@ typedef __char32_t char32_t; |
| 787 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE | 452 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE |
| 788 | # endif | 453 | # endif |
| 789 | 454 | ||
| 455 | # ifdef _LIBCPP_COMPILER_CLANG_BASED | ||
| 456 | # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") | ||
| 457 | # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") | ||
| 458 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) | ||
| 459 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | ||
| 460 | # elif defined(_LIBCPP_COMPILER_GCC) | ||
| 461 | # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") | ||
| 462 | # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") | ||
| 463 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) | ||
| 464 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) | ||
| 465 | # else | ||
| 466 | # define _LIBCPP_DIAGNOSTIC_PUSH | ||
| 467 | # define _LIBCPP_DIAGNOSTIC_POP | ||
| 468 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) | ||
| 469 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | ||
| 470 | # endif | ||
| 471 | |||
| 790 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST | 472 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST |
| 791 | # define _LIBCPP_HARDENING_SIG f | 473 | # define _LIBCPP_HARDENING_SIG f |
| 792 | # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE | 474 | # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE |
| ... | @@ -848,22 +530,24 @@ typedef __char32_t char32_t; | ... | @@ -848,22 +530,24 @@ typedef __char32_t char32_t; |
| 848 | // the implementation of a virtual function in an ABI-incompatible way in the first place, | 530 | // the implementation of a virtual function in an ABI-incompatible way in the first place, |
| 849 | // since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable. | 531 | // since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable. |
| 850 | // | 532 | // |
| 533 | // The macro can be applied to record and enum types. When the tagged type is nested in | ||
| 534 | // a record this "parent" record needs to have the macro too. Another use case for applying | ||
| 535 | // this macro to records and unions is to apply an ABI tag to inline constexpr variables. | ||
| 536 | // This can be useful for inline variables that are implementation details which are expected | ||
| 537 | // to change in the future. | ||
| 538 | // | ||
| 851 | // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing | 539 | // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing |
| 852 | // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and | 540 | // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and |
| 853 | // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. | 541 | // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. |
| 854 | # ifndef _LIBCPP_NO_ABI_TAG | 542 | # ifndef _LIBCPP_NO_ABI_TAG |
| 855 | # define _LIBCPP_HIDE_FROM_ABI \ | 543 | # define _LIBCPP_HIDE_FROM_ABI \ |
| 856 | _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ | 544 | _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ |
| 857 | __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))) | 545 | __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))) |
| 858 | # else | 546 | # else |
| 859 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION | 547 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION |
| 860 | # endif | 548 | # endif |
| 861 | # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION | 549 | # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION |
| 862 | 550 | ||
| 863 | // This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern | ||
| 864 | // "C" function, as those lack mangling. | ||
| 865 | # define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION | ||
| 866 | |||
| 867 | # ifdef _LIBCPP_BUILDING_LIBRARY | 551 | # ifdef _LIBCPP_BUILDING_LIBRARY |
| 868 | # if _LIBCPP_ABI_VERSION > 1 | 552 | # if _LIBCPP_ABI_VERSION > 1 |
| 869 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | 553 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -874,21 +558,51 @@ typedef __char32_t char32_t; | ... | @@ -874,21 +558,51 @@ typedef __char32_t char32_t; |
| 874 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | 558 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
| 875 | # endif | 559 | # endif |
| 876 | 560 | ||
| 877 | // TODO(LLVM-19): Remove _LIBCPP_INLINE_VISIBILITY and _VSTD, which we're keeping around | 561 | // TODO: Remove this workaround once we drop support for Clang 16 |
| 878 | // only to ease the renaming for downstreams. | 562 | # if __has_warning("-Wc++23-extensions") |
| 879 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI | 563 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") |
| 880 | # define _VSTD std | 564 | # else |
| 565 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions") | ||
| 566 | # endif | ||
| 567 | |||
| 568 | // Clang modules take a significant compile time hit when pushing and popping diagnostics. | ||
| 569 | // Since all the headers are marked as system headers in the modulemap, we can simply disable this | ||
| 570 | // pushing and popping when building with clang modules. | ||
| 571 | # if !__has_feature(modules) | ||
| 572 | # define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \ | ||
| 573 | _LIBCPP_DIAGNOSTIC_PUSH \ | ||
| 574 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \ | ||
| 575 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ | ||
| 576 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ | ||
| 577 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ | ||
| 578 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \ | ||
| 579 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ | ||
| 580 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ | ||
| 581 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ | ||
| 582 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions") | ||
| 583 | # define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP | ||
| 584 | # else | ||
| 585 | # define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS | ||
| 586 | # define _LIBCPP_POP_EXTENSION_DIAGNOSTICS | ||
| 587 | # endif | ||
| 881 | 588 | ||
| 882 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. | 589 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. |
| 883 | // clang-format off | 590 | // clang-format off |
| 884 | # define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \ | 591 | # define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \ |
| 592 | namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \ | ||
| 885 | inline namespace _LIBCPP_ABI_NAMESPACE { | 593 | inline namespace _LIBCPP_ABI_NAMESPACE { |
| 886 | # define _LIBCPP_END_NAMESPACE_STD }} | 594 | # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS |
| 887 | 595 | ||
| 596 | #ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE | ||
| 597 | # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem { | ||
| 598 | # define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD | ||
| 599 | #else | ||
| 888 | # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \ | 600 | # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \ |
| 889 | inline namespace __fs { namespace filesystem { | 601 | inline namespace __fs { namespace filesystem { |
| 890 | 602 | ||
| 891 | # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} | 603 | # define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD |
| 604 | #endif | ||
| 605 | |||
| 892 | // clang-format on | 606 | // clang-format on |
| 893 | 607 | ||
| 894 | # if __has_attribute(__enable_if__) | 608 | # if __has_attribute(__enable_if__) |
| ... | @@ -985,6 +699,14 @@ typedef __char32_t char32_t; | ... | @@ -985,6 +699,14 @@ typedef __char32_t char32_t; |
| 985 | # define _LIBCPP_DEPRECATED_(m) | 699 | # define _LIBCPP_DEPRECATED_(m) |
| 986 | # endif | 700 | # endif |
| 987 | 701 | ||
| 702 | # if _LIBCPP_STD_VER < 20 | ||
| 703 | # define _LIBCPP_DEPRECATED_ATOMIC_SYNC \ | ||
| 704 | _LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \ | ||
| 705 | "using -std=c++20 if you need to use these facilities.") | ||
| 706 | # else | ||
| 707 | # define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */ | ||
| 708 | # endif | ||
| 709 | |||
| 988 | # if !defined(_LIBCPP_CXX03_LANG) | 710 | # if !defined(_LIBCPP_CXX03_LANG) |
| 989 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED | 711 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED |
| 990 | # else | 712 | # else |
| ... | @@ -1015,6 +737,12 @@ typedef __char32_t char32_t; | ... | @@ -1015,6 +737,12 @@ typedef __char32_t char32_t; |
| 1015 | # define _LIBCPP_DEPRECATED_IN_CXX23 | 737 | # define _LIBCPP_DEPRECATED_IN_CXX23 |
| 1016 | # endif | 738 | # endif |
| 1017 | 739 | ||
| 740 | # if _LIBCPP_STD_VER >= 26 | ||
| 741 | # define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED | ||
| 742 | # else | ||
| 743 | # define _LIBCPP_DEPRECATED_IN_CXX26 | ||
| 744 | # endif | ||
| 745 | |||
| 1018 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) | 746 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) |
| 1019 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED | 747 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED |
| 1020 | # else | 748 | # else |
| ... | @@ -1068,20 +796,6 @@ typedef __char32_t char32_t; | ... | @@ -1068,20 +796,6 @@ typedef __char32_t char32_t; |
| 1068 | # define _LIBCPP_CONSTEXPR_SINCE_CXX23 | 796 | # define _LIBCPP_CONSTEXPR_SINCE_CXX23 |
| 1069 | # endif | 797 | # endif |
| 1070 | 798 | ||
| 1071 | # ifndef _LIBCPP_HAS_NO_ASAN | ||
| 1072 | extern "C" _LIBCPP_EXPORTED_FROM_ABI void | ||
| 1073 | __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); | ||
| 1074 | extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container( | ||
| 1075 | const void*, const void*, const void*, const void*, const void*, const void*); | ||
| 1076 | extern "C" _LIBCPP_EXPORTED_FROM_ABI int | ||
| 1077 | __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); | ||
| 1078 | # endif | ||
| 1079 | |||
| 1080 | // Try to find out if RTTI is disabled. | ||
| 1081 | # if !defined(__cpp_rtti) || __cpp_rtti < 199711L | ||
| 1082 | # define _LIBCPP_HAS_NO_RTTI | ||
| 1083 | # endif | ||
| 1084 | |||
| 1085 | # ifndef _LIBCPP_WEAK | 799 | # ifndef _LIBCPP_WEAK |
| 1086 | # define _LIBCPP_WEAK __attribute__((__weak__)) | 800 | # define _LIBCPP_WEAK __attribute__((__weak__)) |
| 1087 | # endif | 801 | # endif |
| ... | @@ -1193,9 +907,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c | ... | @@ -1193,9 +907,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c |
| 1193 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE | 907 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE |
| 1194 | # define _LIBCPP_ATOMIC_FLAG_TYPE bool | 908 | # define _LIBCPP_ATOMIC_FLAG_TYPE bool |
| 1195 | # endif | 909 | # endif |
| 1196 | # ifdef _LIBCPP_FREESTANDING | ||
| 1197 | # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS | ||
| 1198 | # endif | ||
| 1199 | # endif | 910 | # endif |
| 1200 | 911 | ||
| 1201 | # if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__) | 912 | # if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__) |
| ... | @@ -1257,23 +968,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c | ... | @@ -1257,23 +968,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c |
| 1257 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ | 968 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ |
| 1258 | # endif | 969 | # endif |
| 1259 | 970 | ||
| 1260 | # if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) | ||
| 1261 | # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR | ||
| 1262 | # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS | ||
| 1263 | # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE | ||
| 1264 | # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS | ||
| 1265 | # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION | ||
| 1266 | # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES | ||
| 1267 | |||
| 1268 | # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) | ||
| 1269 | # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS | ||
| 1270 | # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION | ||
| 1271 | # define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS | ||
| 1272 | # define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS | ||
| 1273 | # define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR | ||
| 1274 | # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS | ||
| 1275 | # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES | ||
| 1276 | |||
| 1277 | // clang-format off | 971 | // clang-format off |
| 1278 | # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh\")") _Pragma("push_macro(\"move\")") _Pragma("push_macro(\"erase\")") | 972 | # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh\")") _Pragma("push_macro(\"move\")") _Pragma("push_macro(\"erase\")") |
| 1279 | # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh\")") _Pragma("pop_macro(\"move\")") _Pragma("pop_macro(\"erase\")") | 973 | # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh\")") _Pragma("pop_macro(\"move\")") _Pragma("pop_macro(\"erase\")") |
| ... | @@ -1322,23 +1016,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c | ... | @@ -1322,23 +1016,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c |
| 1322 | // the ABI inconsistent. | 1016 | // the ABI inconsistent. |
| 1323 | # endif | 1017 | # endif |
| 1324 | 1018 | ||
| 1325 | # ifdef _LIBCPP_COMPILER_CLANG_BASED | ||
| 1326 | # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") | ||
| 1327 | # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") | ||
| 1328 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) | ||
| 1329 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | ||
| 1330 | # elif defined(_LIBCPP_COMPILER_GCC) | ||
| 1331 | # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") | ||
| 1332 | # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") | ||
| 1333 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) | ||
| 1334 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) | ||
| 1335 | # else | ||
| 1336 | # define _LIBCPP_DIAGNOSTIC_PUSH | ||
| 1337 | # define _LIBCPP_DIAGNOSTIC_POP | ||
| 1338 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) | ||
| 1339 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | ||
| 1340 | # endif | ||
| 1341 | |||
| 1342 | // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these | 1019 | // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these |
| 1343 | // functions is gradually being added to existing C libraries. The conditions | 1020 | // functions is gradually being added to existing C libraries. The conditions |
| 1344 | // below check for known C library versions and conditions under which these | 1021 | // below check for known C library versions and conditions under which these |
| ... | @@ -1447,7 +1124,7 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c | ... | @@ -1447,7 +1124,7 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c |
| 1447 | # define _LIBCPP_USING_IF_EXISTS | 1124 | # define _LIBCPP_USING_IF_EXISTS |
| 1448 | # endif | 1125 | # endif |
| 1449 | 1126 | ||
| 1450 | # if __has_cpp_attribute(nodiscard) | 1127 | # if __has_cpp_attribute(__nodiscard__) |
| 1451 | # define _LIBCPP_NODISCARD [[__nodiscard__]] | 1128 | # define _LIBCPP_NODISCARD [[__nodiscard__]] |
| 1452 | # else | 1129 | # else |
| 1453 | // We can't use GCC's [[gnu::warn_unused_result]] and | 1130 | // We can't use GCC's [[gnu::warn_unused_result]] and |
| ... | @@ -1456,27 +1133,13 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c | ... | @@ -1456,27 +1133,13 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c |
| 1456 | # define _LIBCPP_NODISCARD | 1133 | # define _LIBCPP_NODISCARD |
| 1457 | # endif | 1134 | # endif |
| 1458 | 1135 | ||
| 1459 | // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not | ||
| 1460 | // specified as such as an extension. | ||
| 1461 | # if !defined(_LIBCPP_DISABLE_NODISCARD_EXT) | ||
| 1462 | # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD | ||
| 1463 | # else | ||
| 1464 | # define _LIBCPP_NODISCARD_EXT | ||
| 1465 | # endif | ||
| 1466 | |||
| 1467 | # if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT) | ||
| 1468 | # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD | ||
| 1469 | # else | ||
| 1470 | # define _LIBCPP_NODISCARD_AFTER_CXX17 | ||
| 1471 | # endif | ||
| 1472 | |||
| 1473 | # if __has_attribute(__no_destroy__) | 1136 | # if __has_attribute(__no_destroy__) |
| 1474 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) | 1137 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) |
| 1475 | # else | 1138 | # else |
| 1476 | # define _LIBCPP_NO_DESTROY | 1139 | # define _LIBCPP_NO_DESTROY |
| 1477 | # endif | 1140 | # endif |
| 1478 | 1141 | ||
| 1479 | # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) | 1142 | # if __has_attribute(__diagnose_if__) |
| 1480 | # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning"))) | 1143 | # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning"))) |
| 1481 | # else | 1144 | # else |
| 1482 | # define _LIBCPP_DIAGNOSE_WARNING(...) | 1145 | # define _LIBCPP_DIAGNOSE_WARNING(...) |
lib/libcxx/include/__configuration/abi.h created+172| ... | @@ -0,0 +1,172 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CONFIGURATION_ABI_H | ||
| 11 | #define _LIBCPP___CONFIGURATION_ABI_H | ||
| 12 | |||
| 13 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | ||
| 14 | #include <__configuration/compiler.h> | ||
| 15 | #include <__configuration/platform.h> | ||
| 16 | |||
| 17 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #if _LIBCPP_ABI_VERSION >= 2 | ||
| 22 | // Change short string representation so that string data starts at offset 0, | ||
| 23 | // improving its alignment in some cases. | ||
| 24 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 25 | // Fix deque iterator type in order to support incomplete types. | ||
| 26 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | ||
| 27 | // Fix undefined behavior in how std::list stores its linked nodes. | ||
| 28 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | ||
| 29 | // Fix undefined behavior in how __tree stores its end and parent nodes. | ||
| 30 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 31 | // Fix undefined behavior in how __hash_table stores its pointer types. | ||
| 32 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | ||
| 33 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | ||
| 34 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | ||
| 35 | // Override the default return value of exception::what() for bad_function_call::what() | ||
| 36 | // with a string that is specific to bad_function_call (see http://wg21.link/LWG2233). | ||
| 37 | // This is an ABI break on platforms that sign and authenticate vtable function pointers | ||
| 38 | // because it changes the mangling of the virtual function located in the vtable, which | ||
| 39 | // changes how it gets signed. | ||
| 40 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | ||
| 41 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. | ||
| 42 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 43 | // Give reverse_iterator<T> one data member of type T, not two. | ||
| 44 | // Also, in C++17 and later, don't derive iterator types from std::iterator. | ||
| 45 | # define _LIBCPP_ABI_NO_ITERATOR_BASES | ||
| 46 | // Use the smallest possible integer type to represent the index of the variant. | ||
| 47 | // Previously libc++ used "unsigned int" exclusively. | ||
| 48 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | ||
| 49 | // Unstable attempt to provide a more optimized std::function | ||
| 50 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | ||
| 51 | // All the regex constants must be distinct and nonzero. | ||
| 52 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | ||
| 53 | // Re-worked external template instantiations for std::string with a focus on | ||
| 54 | // performance and fast-path inlining. | ||
| 55 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | ||
| 56 | // Enable clang::trivial_abi on std::unique_ptr. | ||
| 57 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | ||
| 58 | // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr | ||
| 59 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | ||
| 60 | // std::random_device holds some state when it uses an implementation that gets | ||
| 61 | // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this | ||
| 62 | // implementation to another one on a platform that has already shipped | ||
| 63 | // std::random_device, one needs to retain the same object layout to remain ABI | ||
| 64 | // compatible. This switch removes these workarounds for platforms that don't care | ||
| 65 | // about ABI compatibility. | ||
| 66 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | ||
| 67 | // Don't export the legacy __basic_string_common class and its methods from the built library. | ||
| 68 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | ||
| 69 | // Don't export the legacy __vector_base_common class and its methods from the built library. | ||
| 70 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | ||
| 71 | // According to the Standard, `bitset::operator[] const` returns bool | ||
| 72 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | ||
| 73 | // Fix the implementation of CityHash used for std::hash<fundamental-type>. | ||
| 74 | // This is an ABI break because `std::hash` will return a different result, | ||
| 75 | // which means that hashing the same object in translation units built against | ||
| 76 | // different versions of libc++ can return inconsistent results. This is especially | ||
| 77 | // tricky since std::hash is used in the implementation of unordered containers. | ||
| 78 | // | ||
| 79 | // The incorrect implementation of CityHash has the problem that it drops some | ||
| 80 | // bits on the floor. | ||
| 81 | # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION | ||
| 82 | // Remove the base 10 implementation of std::to_chars from the dylib. | ||
| 83 | // The implementation moved to the header, but we still export the symbols from | ||
| 84 | // the dylib for backwards compatibility. | ||
| 85 | # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | ||
| 86 | // Define std::array/std::string_view iterators to be __wrap_iters instead of raw | ||
| 87 | // pointers, which prevents people from relying on a non-portable implementation | ||
| 88 | // detail. This is especially useful because enabling bounded iterators hardening | ||
| 89 | // requires code not to make these assumptions. | ||
| 90 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY | ||
| 91 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW | ||
| 92 | // Dont' add an inline namespace for `std::filesystem` | ||
| 93 | # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE | ||
| 94 | // std::basic_ios uses WEOF to indicate that the fill value is | ||
| 95 | // uninitialized. However, on platforms where the size of char_type is | ||
| 96 | // equal to or greater than the size of int_type and char_type is unsigned, | ||
| 97 | // std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF | ||
| 98 | // and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill | ||
| 99 | // value has been initialized using a separate boolean, which changes the ABI. | ||
| 100 | # define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE | ||
| 101 | // Make a std::pair of trivially copyable types trivially copyable. | ||
| 102 | // While this technically doesn't change the layout of pair itself, other types may decide to programatically change | ||
| 103 | // their representation based on whether something is trivially copyable. | ||
| 104 | # define _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
| 105 | #elif _LIBCPP_ABI_VERSION == 1 | ||
| 106 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) | ||
| 107 | // Enable compiling copies of now inline methods into the dylib to support | ||
| 108 | // applications compiled against older libraries. This is unnecessary with | ||
| 109 | // COFF dllexport semantics, since dllexport forces a non-inline definition | ||
| 110 | // of inline functions to be emitted anyway. Our own non-inline copy would | ||
| 111 | // conflict with the dllexport-emitted copy, so we disable it. For XCOFF, | ||
| 112 | // the linker will take issue with the symbols in the shared object if the | ||
| 113 | // weak inline methods get visibility (such as from -fvisibility-inlines-hidden), | ||
| 114 | // so disable it. | ||
| 115 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | ||
| 116 | # endif | ||
| 117 | // Feature macros for disabling pre ABI v1 features. All of these options | ||
| 118 | // are deprecated. | ||
| 119 | # if defined(__FreeBSD__) && __FreeBSD__ < 14 | ||
| 120 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR | ||
| 121 | # endif | ||
| 122 | #endif | ||
| 123 | |||
| 124 | // We had some bugs where we use [[no_unique_address]] together with construct_at, | ||
| 125 | // which causes UB as the call on construct_at could write to overlapping subobjects | ||
| 126 | // | ||
| 127 | // https://github.com/llvm/llvm-project/issues/70506 | ||
| 128 | // https://github.com/llvm/llvm-project/issues/70494 | ||
| 129 | // | ||
| 130 | // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions. | ||
| 131 | // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. | ||
| 132 | #define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua"))) | ||
| 133 | |||
| 134 | // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's | ||
| 135 | // within the bounds of the original container and asserts it on every dereference. | ||
| 136 | // | ||
| 137 | // ABI impact: changes the iterator type of the relevant containers. | ||
| 138 | // | ||
| 139 | // Supported containers: | ||
| 140 | // - `span`; | ||
| 141 | // - `string_view`. | ||
| 142 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS | ||
| 143 | |||
| 144 | // Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds | ||
| 145 | // of the original container and asserts it on every dereference and when performing iterator arithmetics. | ||
| 146 | // | ||
| 147 | // ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`. | ||
| 148 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 149 | |||
| 150 | // Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the | ||
| 151 | // original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't | ||
| 152 | // yet affect `vector<bool>`. | ||
| 153 | // | ||
| 154 | // ABI impact: changes the iterator type of `vector` (except `vector<bool>`). | ||
| 155 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | ||
| 156 | |||
| 157 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) | ||
| 158 | # if defined(__APPLE__) | ||
| 159 | # if defined(__i386__) || defined(__x86_64__) | ||
| 160 | // use old string layout on x86_64 and i386 | ||
| 161 | # elif defined(__arm__) | ||
| 162 | // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs | ||
| 163 | # if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2 | ||
| 164 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 165 | # endif | ||
| 166 | # else | ||
| 167 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 168 | # endif | ||
| 169 | # endif | ||
| 170 | #endif | ||
| 171 | |||
| 172 | #endif // _LIBCPP___CONFIGURATION_ABI_H | ||
lib/libcxx/include/__configuration/availability.h created+400| ... | @@ -0,0 +1,400 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CONFIGURATION_AVAILABILITY_H | ||
| 11 | #define _LIBCPP___CONFIGURATION_AVAILABILITY_H | ||
| 12 | |||
| 13 | #include <__configuration/compiler.h> | ||
| 14 | #include <__configuration/language.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | // Libc++ is shipped by various vendors. In particular, it is used as a system | ||
| 21 | // library on macOS, iOS and other Apple platforms. In order for users to be | ||
| 22 | // able to compile a binary that is intended to be deployed to an older version | ||
| 23 | // of a platform, Clang provides availability attributes [1]. These attributes | ||
| 24 | // can be placed on declarations and are used to describe the life cycle of a | ||
| 25 | // symbol in the library. | ||
| 26 | // | ||
| 27 | // The main goal is to ensure a compile-time error if a symbol that hasn't been | ||
| 28 | // introduced in a previously released library is used in a program that targets | ||
| 29 | // that previously released library. Normally, this would be a load-time error | ||
| 30 | // when one tries to launch the program against the older library. | ||
| 31 | // | ||
| 32 | // For example, the filesystem library was introduced in the dylib in LLVM 9. | ||
| 33 | // On Apple platforms, this corresponds to macOS 10.15. If a user compiles on | ||
| 34 | // a macOS 10.15 host but targets macOS 10.13 with their program, the compiler | ||
| 35 | // would normally not complain (because the required declarations are in the | ||
| 36 | // headers), but the dynamic loader would fail to find the symbols when actually | ||
| 37 | // trying to launch the program on macOS 10.13. To turn this into a compile-time | ||
| 38 | // issue instead, declarations are annotated with when they were introduced, and | ||
| 39 | // the compiler can produce a diagnostic if the program references something that | ||
| 40 | // isn't available on the deployment target. | ||
| 41 | // | ||
| 42 | // This mechanism is general in nature, and any vendor can add their markup to | ||
| 43 | // the library (see below). Whenever a new feature is added that requires support | ||
| 44 | // in the shared library, two macros are added below to allow marking the feature | ||
| 45 | // as unavailable: | ||
| 46 | // 1. A macro named `_LIBCPP_AVAILABILITY_HAS_<feature>` which must be defined | ||
| 47 | // to `_LIBCPP_INTRODUCED_IN_<version>` for the appropriate LLVM version. | ||
| 48 | // 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must be defined to | ||
| 49 | // `_LIBCPP_INTRODUCED_IN_<version>_MARKUP` for the appropriate LLVM version. | ||
| 50 | // | ||
| 51 | // When vendors decide to ship the feature as part of their shared library, they | ||
| 52 | // can update the `_LIBCPP_INTRODUCED_IN_<version>` macro (and the markup counterpart) | ||
| 53 | // based on the platform version they shipped that version of LLVM in. The library | ||
| 54 | // will then use this markup to provide an optimal user experience on these platforms. | ||
| 55 | // | ||
| 56 | // Furthermore, many features in the standard library have corresponding | ||
| 57 | // feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_<feature>` macros | ||
| 58 | // are checked by the corresponding feature-test macros generated by | ||
| 59 | // generate_feature_test_macro_components.py to ensure that the library | ||
| 60 | // doesn't announce a feature as being implemented if it is unavailable on | ||
| 61 | // the deployment target. | ||
| 62 | // | ||
| 63 | // Note that this mechanism is disabled by default in the "upstream" libc++. | ||
| 64 | // Availability annotations are only meaningful when shipping libc++ inside | ||
| 65 | // a platform (i.e. as a system library), and so vendors that want them should | ||
| 66 | // turn those annotations on at CMake configuration time. | ||
| 67 | // | ||
| 68 | // [1]: https://clang.llvm.org/docs/AttributeReference.html#availability | ||
| 69 | |||
| 70 | // For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY | ||
| 71 | // for a while. | ||
| 72 | #if defined(_LIBCPP_DISABLE_AVAILABILITY) | ||
| 73 | # if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
| 74 | # define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS | ||
| 75 | # endif | ||
| 76 | #endif | ||
| 77 | |||
| 78 | // Availability markup is disabled when building the library, or when a non-Clang | ||
| 79 | // compiler is used because only Clang supports the necessary attributes. | ||
| 80 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED) | ||
| 81 | # if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
| 82 | # define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS | ||
| 83 | # endif | ||
| 84 | #endif | ||
| 85 | |||
| 86 | // When availability annotations are disabled, we take for granted that features introduced | ||
| 87 | // in all versions of the library are available. | ||
| 88 | #if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | ||
| 89 | |||
| 90 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 1 | ||
| 91 | # define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */ | ||
| 92 | |||
| 93 | # define _LIBCPP_INTRODUCED_IN_LLVM_18 1 | ||
| 94 | # define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */ | ||
| 95 | |||
| 96 | # define _LIBCPP_INTRODUCED_IN_LLVM_17 1 | ||
| 97 | # define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE /* nothing */ | ||
| 98 | |||
| 99 | # define _LIBCPP_INTRODUCED_IN_LLVM_16 1 | ||
| 100 | # define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */ | ||
| 101 | |||
| 102 | # define _LIBCPP_INTRODUCED_IN_LLVM_15 1 | ||
| 103 | # define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE /* nothing */ | ||
| 104 | |||
| 105 | # define _LIBCPP_INTRODUCED_IN_LLVM_14 1 | ||
| 106 | # define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */ | ||
| 107 | |||
| 108 | # define _LIBCPP_INTRODUCED_IN_LLVM_13 1 | ||
| 109 | # define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE /* nothing */ | ||
| 110 | |||
| 111 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 1 | ||
| 112 | # define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */ | ||
| 113 | |||
| 114 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 1 | ||
| 115 | # define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */ | ||
| 116 | |||
| 117 | # define _LIBCPP_INTRODUCED_IN_LLVM_10 1 | ||
| 118 | # define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE /* nothing */ | ||
| 119 | |||
| 120 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 1 | ||
| 121 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */ | ||
| 122 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */ | ||
| 123 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */ | ||
| 124 | |||
| 125 | # define _LIBCPP_INTRODUCED_IN_LLVM_8 1 | ||
| 126 | # define _LIBCPP_INTRODUCED_IN_LLVM_8_ATTRIBUTE /* nothing */ | ||
| 127 | |||
| 128 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 1 | ||
| 129 | # define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */ | ||
| 130 | |||
| 131 | #elif defined(__APPLE__) | ||
| 132 | |||
| 133 | // clang-format off | ||
| 134 | |||
| 135 | // LLVM 19 | ||
| 136 | // TODO: Fill this in | ||
| 137 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 0 | ||
| 138 | # define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable)) | ||
| 139 | |||
| 140 | // LLVM 18 | ||
| 141 | // TODO: Fill this in | ||
| 142 | # define _LIBCPP_INTRODUCED_IN_LLVM_18 0 | ||
| 143 | # define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE __attribute__((unavailable)) | ||
| 144 | |||
| 145 | // LLVM 17 | ||
| 146 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140400) || \ | ||
| 147 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170400) || \ | ||
| 148 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170400) || \ | ||
| 149 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100400) | ||
| 150 | # define _LIBCPP_INTRODUCED_IN_LLVM_17 0 | ||
| 151 | # else | ||
| 152 | # define _LIBCPP_INTRODUCED_IN_LLVM_17 1 | ||
| 153 | # endif | ||
| 154 | # define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE \ | ||
| 155 | __attribute__((availability(macos, strict, introduced = 14.4))) \ | ||
| 156 | __attribute__((availability(ios, strict, introduced = 17.4))) \ | ||
| 157 | __attribute__((availability(tvos, strict, introduced = 17.4))) \ | ||
| 158 | __attribute__((availability(watchos, strict, introduced = 10.4))) | ||
| 159 | |||
| 160 | // LLVM 16 | ||
| 161 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \ | ||
| 162 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \ | ||
| 163 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \ | ||
| 164 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000) | ||
| 165 | # define _LIBCPP_INTRODUCED_IN_LLVM_16 0 | ||
| 166 | # else | ||
| 167 | # define _LIBCPP_INTRODUCED_IN_LLVM_16 1 | ||
| 168 | # endif | ||
| 169 | # define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE \ | ||
| 170 | __attribute__((availability(macos, strict, introduced = 14.0))) \ | ||
| 171 | __attribute__((availability(ios, strict, introduced = 17.0))) \ | ||
| 172 | __attribute__((availability(tvos, strict, introduced = 17.0))) \ | ||
| 173 | __attribute__((availability(watchos, strict, introduced = 10.0))) | ||
| 174 | |||
| 175 | // LLVM 15 | ||
| 176 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130400) || \ | ||
| 177 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160500) || \ | ||
| 178 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160500) || \ | ||
| 179 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90500) | ||
| 180 | # define _LIBCPP_INTRODUCED_IN_LLVM_15 0 | ||
| 181 | # else | ||
| 182 | # define _LIBCPP_INTRODUCED_IN_LLVM_15 1 | ||
| 183 | # endif | ||
| 184 | # define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE \ | ||
| 185 | __attribute__((availability(macos, strict, introduced = 13.4))) \ | ||
| 186 | __attribute__((availability(ios, strict, introduced = 16.5))) \ | ||
| 187 | __attribute__((availability(tvos, strict, introduced = 16.5))) \ | ||
| 188 | __attribute__((availability(watchos, strict, introduced = 9.5))) | ||
| 189 | |||
| 190 | // LLVM 14 | ||
| 191 | # define _LIBCPP_INTRODUCED_IN_LLVM_14 _LIBCPP_INTRODUCED_IN_LLVM_15 | ||
| 192 | # define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE | ||
| 193 | |||
| 194 | // LLVM 13 | ||
| 195 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 196 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160000) || \ | ||
| 197 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160000) || \ | ||
| 198 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90000) | ||
| 199 | # define _LIBCPP_INTRODUCED_IN_LLVM_13 0 | ||
| 200 | # else | ||
| 201 | # define _LIBCPP_INTRODUCED_IN_LLVM_13 1 | ||
| 202 | # endif | ||
| 203 | # define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE \ | ||
| 204 | __attribute__((availability(macos, strict, introduced = 13.0))) \ | ||
| 205 | __attribute__((availability(ios, strict, introduced = 16.0))) \ | ||
| 206 | __attribute__((availability(tvos, strict, introduced = 16.0))) \ | ||
| 207 | __attribute__((availability(watchos, strict, introduced = 9.0))) | ||
| 208 | |||
| 209 | // LLVM 12 | ||
| 210 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120300) || \ | ||
| 211 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150300) || \ | ||
| 212 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150300) || \ | ||
| 213 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80300) | ||
| 214 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 0 | ||
| 215 | # else | ||
| 216 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 1 | ||
| 217 | # endif | ||
| 218 | # define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE \ | ||
| 219 | __attribute__((availability(macos, strict, introduced = 12.3))) \ | ||
| 220 | __attribute__((availability(ios, strict, introduced = 15.3))) \ | ||
| 221 | __attribute__((availability(tvos, strict, introduced = 15.3))) \ | ||
| 222 | __attribute__((availability(watchos, strict, introduced = 8.3))) | ||
| 223 | |||
| 224 | // LLVM 11 | ||
| 225 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ | ||
| 226 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \ | ||
| 227 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \ | ||
| 228 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000) | ||
| 229 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 0 | ||
| 230 | # else | ||
| 231 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 1 | ||
| 232 | # endif | ||
| 233 | # define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE \ | ||
| 234 | __attribute__((availability(macos, strict, introduced = 11.0))) \ | ||
| 235 | __attribute__((availability(ios, strict, introduced = 14.0))) \ | ||
| 236 | __attribute__((availability(tvos, strict, introduced = 14.0))) \ | ||
| 237 | __attribute__((availability(watchos, strict, introduced = 7.0))) | ||
| 238 | |||
| 239 | // LLVM 10 | ||
| 240 | # define _LIBCPP_INTRODUCED_IN_LLVM_10 _LIBCPP_INTRODUCED_IN_LLVM_11 | ||
| 241 | # define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE | ||
| 242 | |||
| 243 | // LLVM 9 | ||
| 244 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ | ||
| 245 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 246 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 247 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) | ||
| 248 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 0 | ||
| 249 | # else | ||
| 250 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 1 | ||
| 251 | # endif | ||
| 252 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE \ | ||
| 253 | __attribute__((availability(macos, strict, introduced = 10.15))) \ | ||
| 254 | __attribute__((availability(ios, strict, introduced = 13.0))) \ | ||
| 255 | __attribute__((availability(tvos, strict, introduced = 13.0))) \ | ||
| 256 | __attribute__((availability(watchos, strict, introduced = 6.0))) | ||
| 257 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH \ | ||
| 258 | _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \ | ||
| 259 | _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ | ||
| 260 | _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ | ||
| 261 | _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))") | ||
| 262 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP \ | ||
| 263 | _Pragma("clang attribute pop") \ | ||
| 264 | _Pragma("clang attribute pop") \ | ||
| 265 | _Pragma("clang attribute pop") \ | ||
| 266 | _Pragma("clang attribute pop") | ||
| 267 | |||
| 268 | // LLVM 4 | ||
| 269 | # if defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000 | ||
| 270 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 0 | ||
| 271 | # else | ||
| 272 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 1 | ||
| 273 | # endif | ||
| 274 | # define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE __attribute__((availability(watchos, strict, introduced = 5.0))) | ||
| 275 | |||
| 276 | // clang-format on | ||
| 277 | |||
| 278 | #else | ||
| 279 | |||
| 280 | // ...New vendors can add availability markup here... | ||
| 281 | |||
| 282 | # error \ | ||
| 283 | "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!" | ||
| 284 | |||
| 285 | #endif | ||
| 286 | |||
| 287 | // These macros control the availability of std::bad_optional_access and | ||
| 288 | // other exception types. These were put in the shared library to prevent | ||
| 289 | // code bloat from every user program defining the vtable for these exception | ||
| 290 | // types. | ||
| 291 | // | ||
| 292 | // Note that when exceptions are disabled, the methods that normally throw | ||
| 293 | // these exceptions can be used even on older deployment targets, but those | ||
| 294 | // methods will abort instead of throwing. | ||
| 295 | #define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4 | ||
| 296 | #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE | ||
| 297 | |||
| 298 | #define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4 | ||
| 299 | #define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE | ||
| 300 | |||
| 301 | #define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4 | ||
| 302 | #define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE | ||
| 303 | |||
| 304 | // These macros control the availability of all parts of <filesystem> that | ||
| 305 | // depend on something in the dylib. | ||
| 306 | #define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9 | ||
| 307 | #define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE | ||
| 308 | #define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH | ||
| 309 | #define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP | ||
| 310 | |||
| 311 | // This controls the availability of the C++20 synchronization library, | ||
| 312 | // which requires shared library support for various operations | ||
| 313 | // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>, | ||
| 314 | // <semaphore>, and notification functions on std::atomic. | ||
| 315 | #define _LIBCPP_AVAILABILITY_HAS_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11 | ||
| 316 | #define _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE | ||
| 317 | |||
| 318 | // Enable additional explicit instantiations of iostreams components. This | ||
| 319 | // reduces the number of weak definitions generated in programs that use | ||
| 320 | // iostreams by providing a single strong definition in the shared library. | ||
| 321 | // | ||
| 322 | // TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation, | ||
| 323 | // or once libc++ doesn't use the attribute anymore. | ||
| 324 | // TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed. | ||
| 325 | #if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32) | ||
| 326 | # define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 _LIBCPP_INTRODUCED_IN_LLVM_12 | ||
| 327 | #else | ||
| 328 | # define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0 | ||
| 329 | #endif | ||
| 330 | |||
| 331 | // This controls the availability of floating-point std::to_chars functions. | ||
| 332 | // These overloads were added later than the integer overloads. | ||
| 333 | #define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14 | ||
| 334 | #define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE | ||
| 335 | |||
| 336 | // This controls whether the library claims to provide a default verbose | ||
| 337 | // termination function, and consequently whether the headers will try | ||
| 338 | // to use it when the mechanism isn't overriden at compile-time. | ||
| 339 | #define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15 | ||
| 340 | #define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE | ||
| 341 | |||
| 342 | // This controls the availability of the C++17 std::pmr library, | ||
| 343 | // which is implemented in large part in the built library. | ||
| 344 | // | ||
| 345 | // TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed | ||
| 346 | // Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support | ||
| 347 | // it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we | ||
| 348 | // use availability annotations until that bug has been fixed. | ||
| 349 | #define _LIBCPP_AVAILABILITY_HAS_PMR _LIBCPP_INTRODUCED_IN_LLVM_16 | ||
| 350 | #define _LIBCPP_AVAILABILITY_PMR | ||
| 351 | |||
| 352 | // These macros controls the availability of __cxa_init_primary_exception | ||
| 353 | // in the built library, which std::make_exception_ptr might use | ||
| 354 | // (see libcxx/include/__exception/exception_ptr.h). | ||
| 355 | #define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18 | ||
| 356 | #define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE | ||
| 357 | |||
| 358 | // This controls the availability of C++23 <print>, which | ||
| 359 | // has a dependency on the built library (it needs access to | ||
| 360 | // the underlying buffer types of std::cout, std::cerr, and std::clog. | ||
| 361 | #define _LIBCPP_AVAILABILITY_HAS_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18 | ||
| 362 | #define _LIBCPP_AVAILABILITY_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE | ||
| 363 | |||
| 364 | // This controls the availability of the C++20 time zone database. | ||
| 365 | // The parser code is built in the library. | ||
| 366 | #define _LIBCPP_AVAILABILITY_HAS_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19 | ||
| 367 | #define _LIBCPP_AVAILABILITY_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE | ||
| 368 | |||
| 369 | // These macros determine whether we assume that std::bad_function_call and | ||
| 370 | // std::bad_expected_access provide a key function in the dylib. This allows | ||
| 371 | // centralizing their vtable and typeinfo instead of having all TUs provide | ||
| 372 | // a weak definition that then gets deduplicated. | ||
| 373 | #define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19 | ||
| 374 | #define _LIBCPP_AVAILABILITY_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE | ||
| 375 | #define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19 | ||
| 376 | #define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE | ||
| 377 | |||
| 378 | // Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS. | ||
| 379 | // Those are defined in terms of the availability attributes above, and | ||
| 380 | // should not be vendor-specific. | ||
| 381 | #if defined(_LIBCPP_HAS_NO_EXCEPTIONS) | ||
| 382 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST | ||
| 383 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | ||
| 384 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS | ||
| 385 | #else | ||
| 386 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST | ||
| 387 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | ||
| 388 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS | ||
| 389 | #endif | ||
| 390 | |||
| 391 | // Define availability attributes that depend on both | ||
| 392 | // _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI. | ||
| 393 | #if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI) | ||
| 394 | # undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION | ||
| 395 | # undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION | ||
| 396 | # define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 | ||
| 397 | # define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION | ||
| 398 | #endif | ||
| 399 | |||
| 400 | #endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H | ||
lib/libcxx/include/__configuration/compiler.h created+51| ... | @@ -0,0 +1,51 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CONFIGURATION_COMPILER_H | ||
| 11 | #define _LIBCPP___CONFIGURATION_COMPILER_H | ||
| 12 | |||
| 13 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | ||
| 14 | |||
| 15 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #if defined(__apple_build_version__) | ||
| 20 | // Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403) | ||
| 21 | # define _LIBCPP_COMPILER_CLANG_BASED | ||
| 22 | # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) | ||
| 23 | #elif defined(__clang__) | ||
| 24 | # define _LIBCPP_COMPILER_CLANG_BASED | ||
| 25 | # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) | ||
| 26 | #elif defined(__GNUC__) | ||
| 27 | # define _LIBCPP_COMPILER_GCC | ||
| 28 | # define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__) | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | |||
| 33 | // Warn if a compiler version is used that is not supported anymore | ||
| 34 | // LLVM RELEASE Update the minimum compiler versions | ||
| 35 | # if defined(_LIBCPP_CLANG_VER) | ||
| 36 | # if _LIBCPP_CLANG_VER < 1700 | ||
| 37 | # warning "Libc++ only supports Clang 17 and later" | ||
| 38 | # endif | ||
| 39 | # elif defined(_LIBCPP_APPLE_CLANG_VER) | ||
| 40 | # if _LIBCPP_APPLE_CLANG_VER < 1500 | ||
| 41 | # warning "Libc++ only supports AppleClang 15 and later" | ||
| 42 | # endif | ||
| 43 | # elif defined(_LIBCPP_GCC_VER) | ||
| 44 | # if _LIBCPP_GCC_VER < 1400 | ||
| 45 | # warning "Libc++ only supports GCC 14 and later" | ||
| 46 | # endif | ||
| 47 | # endif | ||
| 48 | |||
| 49 | #endif | ||
| 50 | |||
| 51 | #endif // _LIBCPP___CONFIGURATION_COMPILER_H | ||
lib/libcxx/include/__configuration/language.h created+46| ... | @@ -0,0 +1,46 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CONFIGURATION_LANGUAGE_H | ||
| 11 | #define _LIBCPP___CONFIGURATION_LANGUAGE_H | ||
| 12 | |||
| 13 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | ||
| 14 | |||
| 15 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | // NOLINTBEGIN(libcpp-cpp-version-check) | ||
| 20 | #ifdef __cplusplus | ||
| 21 | # if __cplusplus <= 201103L | ||
| 22 | # define _LIBCPP_STD_VER 11 | ||
| 23 | # elif __cplusplus <= 201402L | ||
| 24 | # define _LIBCPP_STD_VER 14 | ||
| 25 | # elif __cplusplus <= 201703L | ||
| 26 | # define _LIBCPP_STD_VER 17 | ||
| 27 | # elif __cplusplus <= 202002L | ||
| 28 | # define _LIBCPP_STD_VER 20 | ||
| 29 | # elif __cplusplus <= 202302L | ||
| 30 | # define _LIBCPP_STD_VER 23 | ||
| 31 | # else | ||
| 32 | // Expected release year of the next C++ standard | ||
| 33 | # define _LIBCPP_STD_VER 26 | ||
| 34 | # endif | ||
| 35 | #endif // __cplusplus | ||
| 36 | // NOLINTEND(libcpp-cpp-version-check) | ||
| 37 | |||
| 38 | #if !defined(__cpp_rtti) || __cpp_rtti < 199711L | ||
| 39 | # define _LIBCPP_HAS_NO_RTTI | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L | ||
| 43 | # define _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #endif // _LIBCPP___CONFIGURATION_LANGUAGE_H | ||
lib/libcxx/include/__configuration/platform.h created+54| ... | @@ -0,0 +1,54 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CONFIGURATION_PLATFORM_H | ||
| 11 | #define _LIBCPP___CONFIGURATION_PLATFORM_H | ||
| 12 | |||
| 13 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | ||
| 14 | |||
| 15 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #if defined(__ELF__) | ||
| 20 | # define _LIBCPP_OBJECT_FORMAT_ELF 1 | ||
| 21 | #elif defined(__MACH__) | ||
| 22 | # define _LIBCPP_OBJECT_FORMAT_MACHO 1 | ||
| 23 | #elif defined(_WIN32) | ||
| 24 | # define _LIBCPP_OBJECT_FORMAT_COFF 1 | ||
| 25 | #elif defined(__wasm__) | ||
| 26 | # define _LIBCPP_OBJECT_FORMAT_WASM 1 | ||
| 27 | #elif defined(_AIX) | ||
| 28 | # define _LIBCPP_OBJECT_FORMAT_XCOFF 1 | ||
| 29 | #else | ||
| 30 | // ... add new file formats here ... | ||
| 31 | #endif | ||
| 32 | |||
| 33 | // Need to detect which libc we're using if we're on Linux. | ||
| 34 | #if defined(__linux__) | ||
| 35 | # include <features.h> | ||
| 36 | # if defined(__GLIBC_PREREQ) | ||
| 37 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) | ||
| 38 | # else | ||
| 39 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 | ||
| 40 | # endif // defined(__GLIBC_PREREQ) | ||
| 41 | #endif // defined(__linux__) | ||
| 42 | |||
| 43 | #ifndef __BYTE_ORDER__ | ||
| 44 | # error \ | ||
| 45 | "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform" | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
| 49 | # define _LIBCPP_LITTLE_ENDIAN | ||
| 50 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | ||
| 51 | # define _LIBCPP_BIG_ENDIAN | ||
| 52 | #endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | ||
| 53 | |||
| 54 | #endif // _LIBCPP___CONFIGURATION_PLATFORM_H | ||
lib/libcxx/include/__debug_utils/sanitizers.h created+104| ... | @@ -0,0 +1,104 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H | ||
| 10 | #define _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | #include <__type_traits/is_constant_evaluated.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #ifndef _LIBCPP_HAS_NO_ASAN | ||
| 21 | |||
| 22 | extern "C" { | ||
| 23 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 24 | __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); | ||
| 25 | _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container( | ||
| 26 | const void*, const void*, const void*, const void*, const void*, const void*); | ||
| 27 | _LIBCPP_EXPORTED_FROM_ABI int | ||
| 28 | __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); | ||
| 29 | } | ||
| 30 | |||
| 31 | #endif // _LIBCPP_HAS_NO_ASAN | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | |||
| 35 | // ASan choices | ||
| 36 | #ifndef _LIBCPP_HAS_NO_ASAN | ||
| 37 | # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS | ||
| 41 | // __asan_annotate_container_with_allocator determines whether containers with custom allocators are annotated. This is | ||
| 42 | // a public customization point to disable annotations if the custom allocator assumes that the memory isn't poisoned. | ||
| 43 | // See the https://libcxx.llvm.org/UsingLibcxx.html#turning-off-asan-annotation-in-containers for more information. | ||
| 44 | template <class _Alloc> | ||
| 45 | struct __asan_annotate_container_with_allocator : true_type {}; | ||
| 46 | #endif | ||
| 47 | |||
| 48 | // Annotate a double-ended contiguous range. | ||
| 49 | // - [__first_storage, __last_storage) is the allocated memory region, | ||
| 50 | // - [__first_old_contained, __last_old_contained) is the previously allowed (unpoisoned) range, and | ||
| 51 | // - [__first_new_contained, __last_new_contained) is the new allowed (unpoisoned) range. | ||
| 52 | template <class _Allocator> | ||
| 53 | _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( | ||
| 54 | const void* __first_storage, | ||
| 55 | const void* __last_storage, | ||
| 56 | const void* __first_old_contained, | ||
| 57 | const void* __last_old_contained, | ||
| 58 | const void* __first_new_contained, | ||
| 59 | const void* __last_new_contained) { | ||
| 60 | #ifdef _LIBCPP_HAS_NO_ASAN | ||
| 61 | (void)__first_storage; | ||
| 62 | (void)__last_storage; | ||
| 63 | (void)__first_old_contained; | ||
| 64 | (void)__last_old_contained; | ||
| 65 | (void)__first_new_contained; | ||
| 66 | (void)__last_new_contained; | ||
| 67 | #else | ||
| 68 | if (__asan_annotate_container_with_allocator<_Allocator>::value && __first_storage != nullptr) | ||
| 69 | __sanitizer_annotate_double_ended_contiguous_container( | ||
| 70 | __first_storage, | ||
| 71 | __last_storage, | ||
| 72 | __first_old_contained, | ||
| 73 | __last_old_contained, | ||
| 74 | __first_new_contained, | ||
| 75 | __last_new_contained); | ||
| 76 | #endif | ||
| 77 | } | ||
| 78 | |||
| 79 | // Annotate a contiguous range. | ||
| 80 | // [__first_storage, __last_storage) is the allocated memory region, | ||
| 81 | // __old_last_contained is the previously last allowed (unpoisoned) element, and | ||
| 82 | // __new_last_contained is the new last allowed (unpoisoned) element. | ||
| 83 | template <class _Allocator> | ||
| 84 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_container( | ||
| 85 | const void* __first_storage, | ||
| 86 | const void* __last_storage, | ||
| 87 | const void* __old_last_contained, | ||
| 88 | const void* __new_last_contained) { | ||
| 89 | #ifdef _LIBCPP_HAS_NO_ASAN | ||
| 90 | (void)__first_storage; | ||
| 91 | (void)__last_storage; | ||
| 92 | (void)__old_last_contained; | ||
| 93 | (void)__new_last_contained; | ||
| 94 | #else | ||
| 95 | if (!__libcpp_is_constant_evaluated() && __asan_annotate_container_with_allocator<_Allocator>::value && | ||
| 96 | __first_storage != nullptr) | ||
| 97 | __sanitizer_annotate_contiguous_container( | ||
| 98 | __first_storage, __last_storage, __old_last_contained, __new_last_contained); | ||
| 99 | #endif | ||
| 100 | } | ||
| 101 | |||
| 102 | _LIBCPP_END_NAMESPACE_STD | ||
| 103 | |||
| 104 | #endif // _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H | ||
lib/libcxx/include/__exception/exception_ptr.h+26-8| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H | 9 | #ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H |
| 10 | #define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H | 10 | #define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <__exception/operations.h> | 13 | #include <__exception/operations.h> |
| 15 | #include <__memory/addressof.h> | 14 | #include <__memory/addressof.h> |
| ... | @@ -26,6 +25,8 @@ | ... | @@ -26,6 +25,8 @@ |
| 26 | 25 | ||
| 27 | #ifndef _LIBCPP_ABI_MICROSOFT | 26 | #ifndef _LIBCPP_ABI_MICROSOFT |
| 28 | 27 | ||
| 28 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION | ||
| 29 | |||
| 29 | namespace __cxxabiv1 { | 30 | namespace __cxxabiv1 { |
| 30 | 31 | ||
| 31 | extern "C" { | 32 | extern "C" { |
| ... | @@ -36,15 +37,20 @@ struct __cxa_exception; | ... | @@ -36,15 +37,20 @@ struct __cxa_exception; |
| 36 | _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception( | 37 | _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception( |
| 37 | void*, | 38 | void*, |
| 38 | std::type_info*, | 39 | std::type_info*, |
| 39 | void( | 40 | # if defined(_WIN32) |
| 40 | # if defined(_WIN32) | 41 | void(__thiscall*)(void*)) throw(); |
| 41 | __thiscall | 42 | # elif defined(__wasm__) |
| 42 | # endif | 43 | // In Wasm, a destructor returns its argument |
| 43 | *)(void*)) throw(); | 44 | void* (*)(void*)) throw(); |
| 45 | # else | ||
| 46 | void (*)(void*)) throw(); | ||
| 47 | # endif | ||
| 44 | } | 48 | } |
| 45 | 49 | ||
| 46 | } // namespace __cxxabiv1 | 50 | } // namespace __cxxabiv1 |
| 47 | 51 | ||
| 52 | # endif | ||
| 53 | |||
| 48 | #endif | 54 | #endif |
| 49 | 55 | ||
| 50 | namespace std { // purposefully not using versioning namespace | 56 | namespace std { // purposefully not using versioning namespace |
| ... | @@ -60,6 +66,9 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { | ... | @@ -60,6 +66,9 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { |
| 60 | friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT; | 66 | friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT; |
| 61 | 67 | ||
| 62 | public: | 68 | public: |
| 69 | // exception_ptr is basically a COW string. | ||
| 70 | using __trivially_relocatable = exception_ptr; | ||
| 71 | |||
| 63 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} | 72 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} |
| 64 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} | 73 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} |
| 65 | 74 | ||
| ... | @@ -88,9 +97,18 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ... | @@ -88,9 +97,18 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { |
| 88 | using _Ep2 = __decay_t<_Ep>; | 97 | using _Ep2 = __decay_t<_Ep>; |
| 89 | 98 | ||
| 90 | void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep)); | 99 | void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep)); |
| 100 | # ifdef __wasm__ | ||
| 101 | // In Wasm, a destructor returns its argument | ||
| 102 | (void)__cxxabiv1::__cxa_init_primary_exception( | ||
| 103 | __ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* { | ||
| 104 | # else | ||
| 91 | (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) { | 105 | (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) { |
| 92 | std::__destroy_at(static_cast<_Ep2*>(__p)); | 106 | # endif |
| 93 | }); | 107 | std::__destroy_at(static_cast<_Ep2*>(__p)); |
| 108 | # ifdef __wasm__ | ||
| 109 | return __p; | ||
| 110 | # endif | ||
| 111 | }); | ||
| 94 | 112 | ||
| 95 | try { | 113 | try { |
| 96 | ::new (__ex) _Ep2(__e); | 114 | ::new (__ex) _Ep2(__e); |
lib/libcxx/include/__exception/nested_exception.h+5-7| ... | @@ -15,8 +15,8 @@ | ... | @@ -15,8 +15,8 @@ |
| 15 | #include <__type_traits/decay.h> | 15 | #include <__type_traits/decay.h> |
| 16 | #include <__type_traits/is_base_of.h> | 16 | #include <__type_traits/is_base_of.h> |
| 17 | #include <__type_traits/is_class.h> | 17 | #include <__type_traits/is_class.h> |
| 18 | #include <__type_traits/is_constructible.h> | ||
| 18 | #include <__type_traits/is_convertible.h> | 19 | #include <__type_traits/is_convertible.h> |
| 19 | #include <__type_traits/is_copy_constructible.h> | ||
| 20 | #include <__type_traits/is_final.h> | 20 | #include <__type_traits/is_final.h> |
| 21 | #include <__type_traits/is_polymorphic.h> | 21 | #include <__type_traits/is_polymorphic.h> |
| 22 | #include <__utility/forward.h> | 22 | #include <__utility/forward.h> |
| ... | @@ -84,17 +84,15 @@ struct __can_dynamic_cast | ... | @@ -84,17 +84,15 @@ struct __can_dynamic_cast |
| 84 | : _BoolConstant< is_polymorphic<_From>::value && | 84 | : _BoolConstant< is_polymorphic<_From>::value && |
| 85 | (!is_base_of<_To, _From>::value || is_convertible<const _From*, const _To*>::value)> {}; | 85 | (!is_base_of<_To, _From>::value || is_convertible<const _From*, const _To*>::value)> {}; |
| 86 | 86 | ||
| 87 | template <class _Ep> | 87 | template <class _Ep, __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value, int> = 0> |
| 88 | inline _LIBCPP_HIDE_FROM_ABI void | 88 | inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep& __e) { |
| 89 | rethrow_if_nested(const _Ep& __e, __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value>* = 0) { | ||
| 90 | const nested_exception* __nep = dynamic_cast<const nested_exception*>(std::addressof(__e)); | 89 | const nested_exception* __nep = dynamic_cast<const nested_exception*>(std::addressof(__e)); |
| 91 | if (__nep) | 90 | if (__nep) |
| 92 | __nep->rethrow_nested(); | 91 | __nep->rethrow_nested(); |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | template <class _Ep> | 94 | template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0> |
| 96 | inline _LIBCPP_HIDE_FROM_ABI void | 95 | inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {} |
| 97 | rethrow_if_nested(const _Ep&, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value>* = 0) {} | ||
| 98 | 96 | ||
| 99 | } // namespace std | 97 | } // namespace std |
| 100 | 98 |
lib/libcxx/include/__exception/operations.h-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___EXCEPTION_OPERATIONS_H | 9 | #ifndef _LIBCPP___EXCEPTION_OPERATIONS_H |
| 10 | #define _LIBCPP___EXCEPTION_OPERATIONS_H | 10 | #define _LIBCPP___EXCEPTION_OPERATIONS_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <cstddef> | 13 | #include <cstddef> |
| 15 | 14 |
lib/libcxx/include/__expected/bad_expected_access.h+16-11| ... | @@ -27,23 +27,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,23 +27,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | template <class _Err> | 27 | template <class _Err> |
| 28 | class bad_expected_access; | 28 | class bad_expected_access; |
| 29 | 29 | ||
| 30 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 31 | # if !_LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION | ||
| 32 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables") | ||
| 33 | # endif | ||
| 30 | template <> | 34 | template <> |
| 31 | class bad_expected_access<void> : public exception { | 35 | class _LIBCPP_EXPORTED_FROM_ABI bad_expected_access<void> : public exception { |
| 32 | protected: | 36 | protected: |
| 33 | _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default; | 37 | _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default; |
| 34 | _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) = default; | 38 | _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) noexcept = default; |
| 35 | _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) = default; | 39 | _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) noexcept = default; |
| 36 | _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) = default; | 40 | _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) noexcept = default; |
| 37 | _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) = default; | 41 | _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) noexcept = default; |
| 38 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_expected_access() override = default; | 42 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_expected_access() override = default; |
| 39 | 43 | ||
| 40 | public: | 44 | public: |
| 41 | // The way this has been designed (by using a class template below) means that we'll already | 45 | # if _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION |
| 42 | // have a profusion of these vtables in TUs, and the dynamic linker will already have a bunch | 46 | const char* what() const noexcept override; |
| 43 | // of work to do. So it is not worth hiding the <void> specialization in the dylib, given that | 47 | # else |
| 44 | // it adds deployment target restrictions. | ||
| 45 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { return "bad access to std::expected"; } | 48 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { return "bad access to std::expected"; } |
| 49 | # endif | ||
| 46 | }; | 50 | }; |
| 51 | _LIBCPP_DIAGNOSTIC_POP | ||
| 47 | 52 | ||
| 48 | template <class _Err> | 53 | template <class _Err> |
| 49 | class bad_expected_access : public bad_expected_access<void> { | 54 | class bad_expected_access : public bad_expected_access<void> { |
lib/libcxx/include/__expected/expected.h+11-13| ... | @@ -23,24 +23,15 @@ | ... | @@ -23,24 +23,15 @@ |
| 23 | #include <__type_traits/is_assignable.h> | 23 | #include <__type_traits/is_assignable.h> |
| 24 | #include <__type_traits/is_constructible.h> | 24 | #include <__type_traits/is_constructible.h> |
| 25 | #include <__type_traits/is_convertible.h> | 25 | #include <__type_traits/is_convertible.h> |
| 26 | #include <__type_traits/is_copy_assignable.h> | ||
| 27 | #include <__type_traits/is_copy_constructible.h> | ||
| 28 | #include <__type_traits/is_default_constructible.h> | ||
| 29 | #include <__type_traits/is_function.h> | 26 | #include <__type_traits/is_function.h> |
| 30 | #include <__type_traits/is_move_assignable.h> | 27 | #include <__type_traits/is_nothrow_assignable.h> |
| 31 | #include <__type_traits/is_move_constructible.h> | ||
| 32 | #include <__type_traits/is_nothrow_constructible.h> | 28 | #include <__type_traits/is_nothrow_constructible.h> |
| 33 | #include <__type_traits/is_nothrow_copy_assignable.h> | ||
| 34 | #include <__type_traits/is_nothrow_copy_constructible.h> | ||
| 35 | #include <__type_traits/is_nothrow_default_constructible.h> | ||
| 36 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 37 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 38 | #include <__type_traits/is_reference.h> | 29 | #include <__type_traits/is_reference.h> |
| 39 | #include <__type_traits/is_same.h> | 30 | #include <__type_traits/is_same.h> |
| 40 | #include <__type_traits/is_swappable.h> | 31 | #include <__type_traits/is_swappable.h> |
| 41 | #include <__type_traits/is_trivially_copy_constructible.h> | 32 | #include <__type_traits/is_trivially_constructible.h> |
| 42 | #include <__type_traits/is_trivially_destructible.h> | 33 | #include <__type_traits/is_trivially_destructible.h> |
| 43 | #include <__type_traits/is_trivially_move_constructible.h> | 34 | #include <__type_traits/is_trivially_relocatable.h> |
| 44 | #include <__type_traits/is_void.h> | 35 | #include <__type_traits/is_void.h> |
| 45 | #include <__type_traits/lazy.h> | 36 | #include <__type_traits/lazy.h> |
| 46 | #include <__type_traits/negation.h> | 37 | #include <__type_traits/negation.h> |
| ... | @@ -473,6 +464,11 @@ public: | ... | @@ -473,6 +464,11 @@ public: |
| 473 | using error_type = _Err; | 464 | using error_type = _Err; |
| 474 | using unexpected_type = unexpected<_Err>; | 465 | using unexpected_type = unexpected<_Err>; |
| 475 | 466 | ||
| 467 | using __trivially_relocatable = | ||
| 468 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value, | ||
| 469 | expected, | ||
| 470 | void>; | ||
| 471 | |||
| 476 | template <class _Up> | 472 | template <class _Up> |
| 477 | using rebind = expected<_Up, error_type>; | 473 | using rebind = expected<_Up, error_type>; |
| 478 | 474 | ||
| ... | @@ -511,7 +507,9 @@ private: | ... | @@ -511,7 +507,9 @@ private: |
| 511 | _And< is_constructible<_Tp, _UfQual>, | 507 | _And< is_constructible<_Tp, _UfQual>, |
| 512 | is_constructible<_Err, _OtherErrQual>, | 508 | is_constructible<_Err, _OtherErrQual>, |
| 513 | _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, | 509 | _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, |
| 514 | _And< _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, | 510 | _And< |
| 511 | _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676 | ||
| 512 | _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, | ||
| 515 | _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, | 513 | _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, |
| 516 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, | 514 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, |
| 517 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, | 515 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, |
lib/libcxx/include/__filesystem/copy_options.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_COPY_OPTIONS_H | 10 | #ifndef _LIBCPP___FILESYSTEM_COPY_OPTIONS_H |
| 11 | #define _LIBCPP___FILESYSTEM_COPY_OPTIONS_H | 11 | #define _LIBCPP___FILESYSTEM_COPY_OPTIONS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__filesystem/directory_entry.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H | 10 | #ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H |
| 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H | 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__chrono/time_point.h> | 13 | #include <__chrono/time_point.h> |
| 15 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 16 | #include <__config> | 15 | #include <__config> |
lib/libcxx/include/__filesystem/directory_iterator.h-1| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H | 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H |
| 12 | 12 | ||
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__availability> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__filesystem/directory_entry.h> | 15 | #include <__filesystem/directory_entry.h> |
| 17 | #include <__filesystem/directory_options.h> | 16 | #include <__filesystem/directory_options.h> |
lib/libcxx/include/__filesystem/directory_options.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H | 10 | #ifndef _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H |
| 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H | 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__filesystem/file_status.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_FILE_STATUS_H | 10 | #ifndef _LIBCPP___FILESYSTEM_FILE_STATUS_H |
| 11 | #define _LIBCPP___FILESYSTEM_FILE_STATUS_H | 11 | #define _LIBCPP___FILESYSTEM_FILE_STATUS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__filesystem/file_type.h> | 14 | #include <__filesystem/file_type.h> |
| 16 | #include <__filesystem/perms.h> | 15 | #include <__filesystem/perms.h> |
lib/libcxx/include/__filesystem/file_time_type.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H | 10 | #ifndef _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H |
| 11 | #define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H | 11 | #define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__chrono/file_clock.h> | 13 | #include <__chrono/file_clock.h> |
| 15 | #include <__chrono/time_point.h> | 14 | #include <__chrono/time_point.h> |
| 16 | #include <__config> | 15 | #include <__config> |
lib/libcxx/include/__filesystem/file_type.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_FILE_TYPE_H | 10 | #ifndef _LIBCPP___FILESYSTEM_FILE_TYPE_H |
| 11 | #define _LIBCPP___FILESYSTEM_FILE_TYPE_H | 11 | #define _LIBCPP___FILESYSTEM_FILE_TYPE_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__filesystem/filesystem_error.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H | 10 | #ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H |
| 11 | #define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H | 11 | #define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__filesystem/path.h> | 14 | #include <__filesystem/path.h> |
| 16 | #include <__memory/shared_ptr.h> | 15 | #include <__memory/shared_ptr.h> |
lib/libcxx/include/__filesystem/operations.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H | 10 | #ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H |
| 11 | #define _LIBCPP___FILESYSTEM_OPERATIONS_H | 11 | #define _LIBCPP___FILESYSTEM_OPERATIONS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__chrono/time_point.h> | 13 | #include <__chrono/time_point.h> |
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__filesystem/copy_options.h> | 15 | #include <__filesystem/copy_options.h> |
lib/libcxx/include/__filesystem/path.h+2-4| ... | @@ -12,11 +12,9 @@ | ... | @@ -12,11 +12,9 @@ |
| 12 | 12 | ||
| 13 | #include <__algorithm/replace.h> | 13 | #include <__algorithm/replace.h> |
| 14 | #include <__algorithm/replace_copy.h> | 14 | #include <__algorithm/replace_copy.h> |
| 15 | #include <__availability> | ||
| 16 | #include <__config> | 15 | #include <__config> |
| 17 | #include <__functional/hash.h> | ||
| 18 | #include <__functional/unary_function.h> | 16 | #include <__functional/unary_function.h> |
| 19 | #include <__fwd/hash.h> | 17 | #include <__fwd/functional.h> |
| 20 | #include <__iterator/back_insert_iterator.h> | 18 | #include <__iterator/back_insert_iterator.h> |
| 21 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__type_traits/decay.h> | 20 | #include <__type_traits/decay.h> |
| ... | @@ -813,7 +811,7 @@ public: | ... | @@ -813,7 +811,7 @@ public: |
| 813 | _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); } | 811 | _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); } |
| 814 | 812 | ||
| 815 | // query | 813 | // query |
| 816 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } | 814 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } |
| 817 | 815 | ||
| 818 | _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); } | 816 | _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); } |
| 819 | _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); } | 817 | _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); } |
lib/libcxx/include/__filesystem/path_iterator.h-1| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | #define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H | 11 | #define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H |
| 12 | 12 | ||
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__availability> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__filesystem/path.h> | 15 | #include <__filesystem/path.h> |
| 17 | #include <__iterator/iterator_traits.h> | 16 | #include <__iterator/iterator_traits.h> |
lib/libcxx/include/__filesystem/perm_options.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_PERM_OPTIONS_H | 10 | #ifndef _LIBCPP___FILESYSTEM_PERM_OPTIONS_H |
| 11 | #define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H | 11 | #define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__filesystem/perms.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_PERMS_H | 10 | #ifndef _LIBCPP___FILESYSTEM_PERMS_H |
| 11 | #define _LIBCPP___FILESYSTEM_PERMS_H | 11 | #define _LIBCPP___FILESYSTEM_PERMS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__filesystem/recursive_directory_iterator.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H | 10 | #ifndef _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H |
| 11 | #define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H | 11 | #define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__filesystem/directory_entry.h> | 14 | #include <__filesystem/directory_entry.h> |
| 16 | #include <__filesystem/directory_options.h> | 15 | #include <__filesystem/directory_options.h> |
lib/libcxx/include/__filesystem/space_info.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FILESYSTEM_SPACE_INFO_H | 10 | #ifndef _LIBCPP___FILESYSTEM_SPACE_INFO_H |
| 11 | #define _LIBCPP___FILESYSTEM_SPACE_INFO_H | 11 | #define _LIBCPP___FILESYSTEM_SPACE_INFO_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <cstdint> | 14 | #include <cstdint> |
| 16 | 15 |
lib/libcxx/include/__filesystem/u8path.h-1| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | #define _LIBCPP___FILESYSTEM_U8PATH_H | 11 | #define _LIBCPP___FILESYSTEM_U8PATH_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/unwrap_iter.h> | 13 | #include <__algorithm/unwrap_iter.h> |
| 14 | #include <__availability> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__filesystem/path.h> | 15 | #include <__filesystem/path.h> |
| 17 | #include <string> | 16 | #include <string> |
lib/libcxx/include/__format/concepts.h+4-2| ... | @@ -13,12 +13,14 @@ | ... | @@ -13,12 +13,14 @@ |
| 13 | #include <__concepts/same_as.h> | 13 | #include <__concepts/same_as.h> |
| 14 | #include <__concepts/semiregular.h> | 14 | #include <__concepts/semiregular.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__format/format_fwd.h> | ||
| 17 | #include <__format/format_parse_context.h> | 16 | #include <__format/format_parse_context.h> |
| 17 | #include <__fwd/format.h> | ||
| 18 | #include <__fwd/tuple.h> | ||
| 19 | #include <__tuple/tuple_size.h> | ||
| 18 | #include <__type_traits/is_specialization.h> | 20 | #include <__type_traits/is_specialization.h> |
| 19 | #include <__type_traits/remove_const.h> | 21 | #include <__type_traits/remove_const.h> |
| 22 | #include <__type_traits/remove_reference.h> | ||
| 20 | #include <__utility/pair.h> | 23 | #include <__utility/pair.h> |
| 21 | #include <tuple> | ||
| 22 | 24 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | # pragma GCC system_header | 26 | # pragma GCC system_header |
lib/libcxx/include/__format/container_adaptor.h+2-2| ... | @@ -18,11 +18,11 @@ | ... | @@ -18,11 +18,11 @@ |
| 18 | #include <__format/concepts.h> | 18 | #include <__format/concepts.h> |
| 19 | #include <__format/formatter.h> | 19 | #include <__format/formatter.h> |
| 20 | #include <__format/range_default_formatter.h> | 20 | #include <__format/range_default_formatter.h> |
| 21 | #include <__fwd/queue.h> | ||
| 22 | #include <__fwd/stack.h> | ||
| 21 | #include <__ranges/ref_view.h> | 23 | #include <__ranges/ref_view.h> |
| 22 | #include <__type_traits/is_const.h> | 24 | #include <__type_traits/is_const.h> |
| 23 | #include <__type_traits/maybe_const.h> | 25 | #include <__type_traits/maybe_const.h> |
| 24 | #include <queue> | ||
| 25 | #include <stack> | ||
| 26 | 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 |
lib/libcxx/include/__format/escaped_output_table.h+736-913| ... | @@ -80,10 +80,9 @@ namespace __escaped_output_table { | ... | @@ -80,10 +80,9 @@ namespace __escaped_output_table { |
| 80 | /// The entries of the characters to escape in format's debug string. | 80 | /// The entries of the characters to escape in format's debug string. |
| 81 | /// | 81 | /// |
| 82 | /// Contains the entries for [format.string.escaped]/2.2.1.2.1 | 82 | /// Contains the entries for [format.string.escaped]/2.2.1.2.1 |
| 83 | /// CE is a Unicode encoding and C corresponds to either a UCS scalar value | 83 | /// CE is a Unicode encoding and C corresponds to a UCS scalar value whose |
| 84 | /// whose Unicode property General_Category has a value in the groups | 84 | /// Unicode property General_Category has a value in the groups Separator (Z) |
| 85 | /// Separator (Z) or Other (C) or to a UCS scalar value which has the Unicode | 85 | /// or Other (C), as described by table 12 of UAX #44 |
| 86 | /// property Grapheme_Extend=Yes, as described by table 12 of UAX #44 | ||
| 87 | /// | 86 | /// |
| 88 | /// Separator (Z) consists of General_Category | 87 | /// Separator (Z) consists of General_Category |
| 89 | /// - Space_Separator, | 88 | /// - Space_Separator, |
| ... | @@ -98,7 +97,6 @@ namespace __escaped_output_table { | ... | @@ -98,7 +97,6 @@ namespace __escaped_output_table { |
| 98 | /// - Unassigned. | 97 | /// - Unassigned. |
| 99 | /// | 98 | /// |
| 100 | /// The data is generated from | 99 | /// The data is generated from |
| 101 | /// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt | ||
| 102 | /// - https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt | 100 | /// - https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt |
| 103 | /// | 101 | /// |
| 104 | /// The table is similar to the table | 102 | /// The table is similar to the table |
| ... | @@ -107,926 +105,751 @@ namespace __escaped_output_table { | ... | @@ -107,926 +105,751 @@ namespace __escaped_output_table { |
| 107 | /// table lacks a property, thus having more bits available for the size. | 105 | /// table lacks a property, thus having more bits available for the size. |
| 108 | /// | 106 | /// |
| 109 | /// The data has 2 values: | 107 | /// The data has 2 values: |
| 110 | /// - bits [0, 10] The size of the range, allowing 2048 elements. | 108 | /// - bits [0, 13] The size of the range, allowing 16384 elements. |
| 111 | /// - bits [11, 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 |
| 112 | /// the range is lower bound + size. | 110 | /// the range is lower bound + size. Note the code expects code units the fit |
| 113 | inline constexpr uint32_t __entries[893] = { | 111 | /// into 18 bits, instead of the 21 bits needed for the full Unicode range. |
| 114 | 0x00000020, | 112 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 115 | 0x0003f821, | 113 | 0x00000020 /* 00000000 - 00000020 [ 33] */, |
| 116 | 0x00056800, | 114 | 0x001fc021 /* 0000007f - 000000a0 [ 34] */, |
| 117 | 0x0018006f, | 115 | 0x002b4000 /* 000000ad - 000000ad [ 1] */, |
| 118 | 0x001bc001, | 116 | 0x00de0001 /* 00000378 - 00000379 [ 2] */, |
| 119 | 0x001c0003, | 117 | 0x00e00003 /* 00000380 - 00000383 [ 4] */, |
| 120 | 0x001c5800, | 118 | 0x00e2c000 /* 0000038b - 0000038b [ 1] */, |
| 121 | 0x001c6800, | 119 | 0x00e34000 /* 0000038d - 0000038d [ 1] */, |
| 122 | 0x001d1000, | 120 | 0x00e88000 /* 000003a2 - 000003a2 [ 1] */, |
| 123 | 0x00241806, | 121 | 0x014c0000 /* 00000530 - 00000530 [ 1] */, |
| 124 | 0x00298000, | 122 | 0x0155c001 /* 00000557 - 00000558 [ 2] */, |
| 125 | 0x002ab801, | 123 | 0x0162c001 /* 0000058b - 0000058c [ 2] */, |
| 126 | 0x002c5801, | 124 | 0x01640000 /* 00000590 - 00000590 [ 1] */, |
| 127 | 0x002c802d, | 125 | 0x01720007 /* 000005c8 - 000005cf [ 8] */, |
| 128 | 0x002df800, | 126 | 0x017ac003 /* 000005eb - 000005ee [ 4] */, |
| 129 | 0x002e0801, | 127 | 0x017d4010 /* 000005f5 - 00000605 [ 17] */, |
| 130 | 0x002e2001, | 128 | 0x01870000 /* 0000061c - 0000061c [ 1] */, |
| 131 | 0x002e3808, | 129 | 0x01b74000 /* 000006dd - 000006dd [ 1] */, |
| 132 | 0x002f5803, | 130 | 0x01c38001 /* 0000070e - 0000070f [ 2] */, |
| 133 | 0x002fa810, | 131 | 0x01d2c001 /* 0000074b - 0000074c [ 2] */, |
| 134 | 0x0030800a, | 132 | 0x01ec800d /* 000007b2 - 000007bf [ 14] */, |
| 135 | 0x0030e000, | 133 | 0x01fec001 /* 000007fb - 000007fc [ 2] */, |
| 136 | 0x00325814, | 134 | 0x020b8001 /* 0000082e - 0000082f [ 2] */, |
| 137 | 0x00338000, | 135 | 0x020fc000 /* 0000083f - 0000083f [ 1] */, |
| 138 | 0x0036b007, | 136 | 0x02170001 /* 0000085c - 0000085d [ 2] */, |
| 139 | 0x0036f805, | 137 | 0x0217c000 /* 0000085f - 0000085f [ 1] */, |
| 140 | 0x00373801, | 138 | 0x021ac004 /* 0000086b - 0000086f [ 5] */, |
| 141 | 0x00375003, | 139 | 0x0223c008 /* 0000088f - 00000897 [ 9] */, |
| 142 | 0x00387001, | 140 | 0x02388000 /* 000008e2 - 000008e2 [ 1] */, |
| 143 | 0x00388800, | 141 | 0x02610000 /* 00000984 - 00000984 [ 1] */, |
| 144 | 0x0039801c, | 142 | 0x02634001 /* 0000098d - 0000098e [ 2] */, |
| 145 | 0x003d300a, | 143 | 0x02644001 /* 00000991 - 00000992 [ 2] */, |
| 146 | 0x003d900d, | 144 | 0x026a4000 /* 000009a9 - 000009a9 [ 1] */, |
| 147 | 0x003f5808, | 145 | 0x026c4000 /* 000009b1 - 000009b1 [ 1] */, |
| 148 | 0x003fd802, | 146 | 0x026cc002 /* 000009b3 - 000009b5 [ 3] */, |
| 149 | 0x0040b003, | 147 | 0x026e8001 /* 000009ba - 000009bb [ 2] */, |
| 150 | 0x0040d808, | 148 | 0x02714001 /* 000009c5 - 000009c6 [ 2] */, |
| 151 | 0x00412802, | 149 | 0x02724001 /* 000009c9 - 000009ca [ 2] */, |
| 152 | 0x00414806, | 150 | 0x0273c007 /* 000009cf - 000009d6 [ 8] */, |
| 153 | 0x0041f800, | 151 | 0x02760003 /* 000009d8 - 000009db [ 4] */, |
| 154 | 0x0042c804, | 152 | 0x02778000 /* 000009de - 000009de [ 1] */, |
| 155 | 0x0042f800, | 153 | 0x02790001 /* 000009e4 - 000009e5 [ 2] */, |
| 156 | 0x00435804, | 154 | 0x027fc001 /* 000009ff - 00000a00 [ 2] */, |
| 157 | 0x00447810, | 155 | 0x02810000 /* 00000a04 - 00000a04 [ 1] */, |
| 158 | 0x00465038, | 156 | 0x0282c003 /* 00000a0b - 00000a0e [ 4] */, |
| 159 | 0x0049d000, | 157 | 0x02844001 /* 00000a11 - 00000a12 [ 2] */, |
| 160 | 0x0049e000, | 158 | 0x028a4000 /* 00000a29 - 00000a29 [ 1] */, |
| 161 | 0x004a0807, | 159 | 0x028c4000 /* 00000a31 - 00000a31 [ 1] */, |
| 162 | 0x004a6800, | 160 | 0x028d0000 /* 00000a34 - 00000a34 [ 1] */, |
| 163 | 0x004a8806, | 161 | 0x028dc000 /* 00000a37 - 00000a37 [ 1] */, |
| 164 | 0x004b1001, | 162 | 0x028e8001 /* 00000a3a - 00000a3b [ 2] */, |
| 165 | 0x004c0800, | 163 | 0x028f4000 /* 00000a3d - 00000a3d [ 1] */, |
| 166 | 0x004c2000, | 164 | 0x0290c003 /* 00000a43 - 00000a46 [ 4] */, |
| 167 | 0x004c6801, | 165 | 0x02924001 /* 00000a49 - 00000a4a [ 2] */, |
| 168 | 0x004c8801, | 166 | 0x02938002 /* 00000a4e - 00000a50 [ 3] */, |
| 169 | 0x004d4800, | 167 | 0x02948006 /* 00000a52 - 00000a58 [ 7] */, |
| 170 | 0x004d8800, | 168 | 0x02974000 /* 00000a5d - 00000a5d [ 1] */, |
| 171 | 0x004d9802, | 169 | 0x0297c006 /* 00000a5f - 00000a65 [ 7] */, |
| 172 | 0x004dd002, | 170 | 0x029dc009 /* 00000a77 - 00000a80 [ 10] */, |
| 173 | 0x004df000, | 171 | 0x02a10000 /* 00000a84 - 00000a84 [ 1] */, |
| 174 | 0x004e0805, | 172 | 0x02a38000 /* 00000a8e - 00000a8e [ 1] */, |
| 175 | 0x004e4801, | 173 | 0x02a48000 /* 00000a92 - 00000a92 [ 1] */, |
| 176 | 0x004e6800, | 174 | 0x02aa4000 /* 00000aa9 - 00000aa9 [ 1] */, |
| 177 | 0x004e780c, | 175 | 0x02ac4000 /* 00000ab1 - 00000ab1 [ 1] */, |
| 178 | 0x004ef000, | 176 | 0x02ad0000 /* 00000ab4 - 00000ab4 [ 1] */, |
| 179 | 0x004f1003, | 177 | 0x02ae8001 /* 00000aba - 00000abb [ 2] */, |
| 180 | 0x004ff004, | 178 | 0x02b18000 /* 00000ac6 - 00000ac6 [ 1] */, |
| 181 | 0x00502000, | 179 | 0x02b28000 /* 00000aca - 00000aca [ 1] */, |
| 182 | 0x00505803, | 180 | 0x02b38001 /* 00000ace - 00000acf [ 2] */, |
| 183 | 0x00508801, | 181 | 0x02b4400e /* 00000ad1 - 00000adf [ 15] */, |
| 184 | 0x00514800, | 182 | 0x02b90001 /* 00000ae4 - 00000ae5 [ 2] */, |
| 185 | 0x00518800, | 183 | 0x02bc8006 /* 00000af2 - 00000af8 [ 7] */, |
| 186 | 0x0051a000, | 184 | 0x02c00000 /* 00000b00 - 00000b00 [ 1] */, |
| 187 | 0x0051b800, | 185 | 0x02c10000 /* 00000b04 - 00000b04 [ 1] */, |
| 188 | 0x0051d003, | 186 | 0x02c34001 /* 00000b0d - 00000b0e [ 2] */, |
| 189 | 0x00520817, | 187 | 0x02c44001 /* 00000b11 - 00000b12 [ 2] */, |
| 190 | 0x0052e800, | 188 | 0x02ca4000 /* 00000b29 - 00000b29 [ 1] */, |
| 191 | 0x0052f806, | 189 | 0x02cc4000 /* 00000b31 - 00000b31 [ 1] */, |
| 192 | 0x00538001, | 190 | 0x02cd0000 /* 00000b34 - 00000b34 [ 1] */, |
| 193 | 0x0053a800, | 191 | 0x02ce8001 /* 00000b3a - 00000b3b [ 2] */, |
| 194 | 0x0053b80b, | 192 | 0x02d14001 /* 00000b45 - 00000b46 [ 2] */, |
| 195 | 0x00542000, | 193 | 0x02d24001 /* 00000b49 - 00000b4a [ 2] */, |
| 196 | 0x00547000, | 194 | 0x02d38006 /* 00000b4e - 00000b54 [ 7] */, |
| 197 | 0x00549000, | 195 | 0x02d60003 /* 00000b58 - 00000b5b [ 4] */, |
| 198 | 0x00554800, | 196 | 0x02d78000 /* 00000b5e - 00000b5e [ 1] */, |
| 199 | 0x00558800, | 197 | 0x02d90001 /* 00000b64 - 00000b65 [ 2] */, |
| 200 | 0x0055a000, | 198 | 0x02de0009 /* 00000b78 - 00000b81 [ 10] */, |
| 201 | 0x0055d002, | 199 | 0x02e10000 /* 00000b84 - 00000b84 [ 1] */, |
| 202 | 0x00560807, | 200 | 0x02e2c002 /* 00000b8b - 00000b8d [ 3] */, |
| 203 | 0x00565000, | 201 | 0x02e44000 /* 00000b91 - 00000b91 [ 1] */, |
| 204 | 0x00566802, | 202 | 0x02e58002 /* 00000b96 - 00000b98 [ 3] */, |
| 205 | 0x0056880e, | 203 | 0x02e6c000 /* 00000b9b - 00000b9b [ 1] */, |
| 206 | 0x00571003, | 204 | 0x02e74000 /* 00000b9d - 00000b9d [ 1] */, |
| 207 | 0x00579006, | 205 | 0x02e80002 /* 00000ba0 - 00000ba2 [ 3] */, |
| 208 | 0x0057d007, | 206 | 0x02e94002 /* 00000ba5 - 00000ba7 [ 3] */, |
| 209 | 0x00582000, | 207 | 0x02eac002 /* 00000bab - 00000bad [ 3] */, |
| 210 | 0x00586801, | 208 | 0x02ee8003 /* 00000bba - 00000bbd [ 4] */, |
| 211 | 0x00588801, | 209 | 0x02f0c002 /* 00000bc3 - 00000bc5 [ 3] */, |
| 212 | 0x00594800, | 210 | 0x02f24000 /* 00000bc9 - 00000bc9 [ 1] */, |
| 213 | 0x00598800, | 211 | 0x02f38001 /* 00000bce - 00000bcf [ 2] */, |
| 214 | 0x0059a000, | 212 | 0x02f44005 /* 00000bd1 - 00000bd6 [ 6] */, |
| 215 | 0x0059d002, | 213 | 0x02f6000d /* 00000bd8 - 00000be5 [ 14] */, |
| 216 | 0x0059f001, | 214 | 0x02fec004 /* 00000bfb - 00000bff [ 5] */, |
| 217 | 0x005a0805, | 215 | 0x03034000 /* 00000c0d - 00000c0d [ 1] */, |
| 218 | 0x005a4801, | 216 | 0x03044000 /* 00000c11 - 00000c11 [ 1] */, |
| 219 | 0x005a680e, | 217 | 0x030a4000 /* 00000c29 - 00000c29 [ 1] */, |
| 220 | 0x005af000, | 218 | 0x030e8001 /* 00000c3a - 00000c3b [ 2] */, |
| 221 | 0x005b1003, | 219 | 0x03114000 /* 00000c45 - 00000c45 [ 1] */, |
| 222 | 0x005bc00a, | 220 | 0x03124000 /* 00000c49 - 00000c49 [ 1] */, |
| 223 | 0x005c2000, | 221 | 0x03138006 /* 00000c4e - 00000c54 [ 7] */, |
| 224 | 0x005c5802, | 222 | 0x0315c000 /* 00000c57 - 00000c57 [ 1] */, |
| 225 | 0x005c8800, | 223 | 0x0316c001 /* 00000c5b - 00000c5c [ 2] */, |
| 226 | 0x005cb002, | 224 | 0x03178001 /* 00000c5e - 00000c5f [ 2] */, |
| 227 | 0x005cd800, | 225 | 0x03190001 /* 00000c64 - 00000c65 [ 2] */, |
| 228 | 0x005ce800, | 226 | 0x031c0006 /* 00000c70 - 00000c76 [ 7] */, |
| 229 | 0x005d0002, | 227 | 0x03234000 /* 00000c8d - 00000c8d [ 1] */, |
| 230 | 0x005d2802, | 228 | 0x03244000 /* 00000c91 - 00000c91 [ 1] */, |
| 231 | 0x005d5802, | 229 | 0x032a4000 /* 00000ca9 - 00000ca9 [ 1] */, |
| 232 | 0x005dd004, | 230 | 0x032d0000 /* 00000cb4 - 00000cb4 [ 1] */, |
| 233 | 0x005e0000, | 231 | 0x032e8001 /* 00000cba - 00000cbb [ 2] */, |
| 234 | 0x005e1802, | 232 | 0x03314000 /* 00000cc5 - 00000cc5 [ 1] */, |
| 235 | 0x005e4800, | 233 | 0x03324000 /* 00000cc9 - 00000cc9 [ 1] */, |
| 236 | 0x005e6802, | 234 | 0x03338006 /* 00000cce - 00000cd4 [ 7] */, |
| 237 | 0x005e8814, | 235 | 0x0335c005 /* 00000cd7 - 00000cdc [ 6] */, |
| 238 | 0x005fd805, | 236 | 0x0337c000 /* 00000cdf - 00000cdf [ 1] */, |
| 239 | 0x00602000, | 237 | 0x03390001 /* 00000ce4 - 00000ce5 [ 2] */, |
| 240 | 0x00606800, | 238 | 0x033c0000 /* 00000cf0 - 00000cf0 [ 1] */, |
| 241 | 0x00608800, | 239 | 0x033d000b /* 00000cf4 - 00000cff [ 12] */, |
| 242 | 0x00614800, | 240 | 0x03434000 /* 00000d0d - 00000d0d [ 1] */, |
| 243 | 0x0061d002, | 241 | 0x03444000 /* 00000d11 - 00000d11 [ 1] */, |
| 244 | 0x0061f002, | 242 | 0x03514000 /* 00000d45 - 00000d45 [ 1] */, |
| 245 | 0x00622812, | 243 | 0x03524000 /* 00000d49 - 00000d49 [ 1] */, |
| 246 | 0x0062d801, | 244 | 0x03540003 /* 00000d50 - 00000d53 [ 4] */, |
| 247 | 0x0062f001, | 245 | 0x03590001 /* 00000d64 - 00000d65 [ 2] */, |
| 248 | 0x00631003, | 246 | 0x03600000 /* 00000d80 - 00000d80 [ 1] */, |
| 249 | 0x00638006, | 247 | 0x03610000 /* 00000d84 - 00000d84 [ 1] */, |
| 250 | 0x00640800, | 248 | 0x0365c002 /* 00000d97 - 00000d99 [ 3] */, |
| 251 | 0x00646800, | 249 | 0x036c8000 /* 00000db2 - 00000db2 [ 1] */, |
| 252 | 0x00648800, | 250 | 0x036f0000 /* 00000dbc - 00000dbc [ 1] */, |
| 253 | 0x00654800, | 251 | 0x036f8001 /* 00000dbe - 00000dbf [ 2] */, |
| 254 | 0x0065a000, | 252 | 0x0371c002 /* 00000dc7 - 00000dc9 [ 3] */, |
| 255 | 0x0065d002, | 253 | 0x0372c003 /* 00000dcb - 00000dce [ 4] */, |
| 256 | 0x0065f800, | 254 | 0x03754000 /* 00000dd5 - 00000dd5 [ 1] */, |
| 257 | 0x00661000, | 255 | 0x0375c000 /* 00000dd7 - 00000dd7 [ 1] */, |
| 258 | 0x00662801, | 256 | 0x03780005 /* 00000de0 - 00000de5 [ 6] */, |
| 259 | 0x00664800, | 257 | 0x037c0001 /* 00000df0 - 00000df1 [ 2] */, |
| 260 | 0x00666010, | 258 | 0x037d400b /* 00000df5 - 00000e00 [ 12] */, |
| 261 | 0x0066f800, | 259 | 0x038ec003 /* 00000e3b - 00000e3e [ 4] */, |
| 262 | 0x00671003, | 260 | 0x03970024 /* 00000e5c - 00000e80 [ 37] */, |
| 263 | 0x00678000, | 261 | 0x03a0c000 /* 00000e83 - 00000e83 [ 1] */, |
| 264 | 0x0067a00d, | 262 | 0x03a14000 /* 00000e85 - 00000e85 [ 1] */, |
| 265 | 0x00686800, | 263 | 0x03a2c000 /* 00000e8b - 00000e8b [ 1] */, |
| 266 | 0x00688800, | 264 | 0x03a90000 /* 00000ea4 - 00000ea4 [ 1] */, |
| 267 | 0x0069d801, | 265 | 0x03a98000 /* 00000ea6 - 00000ea6 [ 1] */, |
| 268 | 0x0069f000, | 266 | 0x03af8001 /* 00000ebe - 00000ebf [ 2] */, |
| 269 | 0x006a0804, | 267 | 0x03b14000 /* 00000ec5 - 00000ec5 [ 1] */, |
| 270 | 0x006a4800, | 268 | 0x03b1c000 /* 00000ec7 - 00000ec7 [ 1] */, |
| 271 | 0x006a6800, | 269 | 0x03b3c000 /* 00000ecf - 00000ecf [ 1] */, |
| 272 | 0x006a8003, | 270 | 0x03b68001 /* 00000eda - 00000edb [ 2] */, |
| 273 | 0x006ab800, | 271 | 0x03b8001f /* 00000ee0 - 00000eff [ 32] */, |
| 274 | 0x006b1003, | 272 | 0x03d20000 /* 00000f48 - 00000f48 [ 1] */, |
| 275 | 0x006c0001, | 273 | 0x03db4003 /* 00000f6d - 00000f70 [ 4] */, |
| 276 | 0x006c2000, | 274 | 0x03e60000 /* 00000f98 - 00000f98 [ 1] */, |
| 277 | 0x006cb802, | 275 | 0x03ef4000 /* 00000fbd - 00000fbd [ 1] */, |
| 278 | 0x006d9000, | 276 | 0x03f34000 /* 00000fcd - 00000fcd [ 1] */, |
| 279 | 0x006de000, | 277 | 0x03f6c024 /* 00000fdb - 00000fff [ 37] */, |
| 280 | 0x006df001, | 278 | 0x04318000 /* 000010c6 - 000010c6 [ 1] */, |
| 281 | 0x006e3808, | 279 | 0x04320004 /* 000010c8 - 000010cc [ 5] */, |
| 282 | 0x006e9005, | 280 | 0x04338001 /* 000010ce - 000010cf [ 2] */, |
| 283 | 0x006ef806, | 281 | 0x04924000 /* 00001249 - 00001249 [ 1] */, |
| 284 | 0x006f8001, | 282 | 0x04938001 /* 0000124e - 0000124f [ 2] */, |
| 285 | 0x006fa80b, | 283 | 0x0495c000 /* 00001257 - 00001257 [ 1] */, |
| 286 | 0x00718800, | 284 | 0x04964000 /* 00001259 - 00001259 [ 1] */, |
| 287 | 0x0071a00a, | 285 | 0x04978001 /* 0000125e - 0000125f [ 2] */, |
| 288 | 0x00723807, | 286 | 0x04a24000 /* 00001289 - 00001289 [ 1] */, |
| 289 | 0x0072e024, | 287 | 0x04a38001 /* 0000128e - 0000128f [ 2] */, |
| 290 | 0x00741800, | 288 | 0x04ac4000 /* 000012b1 - 000012b1 [ 1] */, |
| 291 | 0x00742800, | 289 | 0x04ad8001 /* 000012b6 - 000012b7 [ 2] */, |
| 292 | 0x00745800, | 290 | 0x04afc000 /* 000012bf - 000012bf [ 1] */, |
| 293 | 0x00752000, | 291 | 0x04b04000 /* 000012c1 - 000012c1 [ 1] */, |
| 294 | 0x00753000, | 292 | 0x04b18001 /* 000012c6 - 000012c7 [ 2] */, |
| 295 | 0x00758800, | 293 | 0x04b5c000 /* 000012d7 - 000012d7 [ 1] */, |
| 296 | 0x0075a008, | 294 | 0x04c44000 /* 00001311 - 00001311 [ 1] */, |
| 297 | 0x0075f001, | 295 | 0x04c58001 /* 00001316 - 00001317 [ 2] */, |
| 298 | 0x00762800, | 296 | 0x04d6c001 /* 0000135b - 0000135c [ 2] */, |
| 299 | 0x00763808, | 297 | 0x04df4002 /* 0000137d - 0000137f [ 3] */, |
| 300 | 0x0076d001, | 298 | 0x04e68005 /* 0000139a - 0000139f [ 6] */, |
| 301 | 0x0077001f, | 299 | 0x04fd8001 /* 000013f6 - 000013f7 [ 2] */, |
| 302 | 0x0078c001, | 300 | 0x04ff8001 /* 000013fe - 000013ff [ 2] */, |
| 303 | 0x0079a800, | 301 | 0x05a00000 /* 00001680 - 00001680 [ 1] */, |
| 304 | 0x0079b800, | 302 | 0x05a74002 /* 0000169d - 0000169f [ 3] */, |
| 305 | 0x0079c800, | 303 | 0x05be4006 /* 000016f9 - 000016ff [ 7] */, |
| 306 | 0x007a4000, | 304 | 0x05c58008 /* 00001716 - 0000171e [ 9] */, |
| 307 | 0x007b6811, | 305 | 0x05cdc008 /* 00001737 - 0000173f [ 9] */, |
| 308 | 0x007c0004, | 306 | 0x05d5000b /* 00001754 - 0000175f [ 12] */, |
| 309 | 0x007c3001, | 307 | 0x05db4000 /* 0000176d - 0000176d [ 1] */, |
| 310 | 0x007c6830, | 308 | 0x05dc4000 /* 00001771 - 00001771 [ 1] */, |
| 311 | 0x007e3000, | 309 | 0x05dd000b /* 00001774 - 0000177f [ 12] */, |
| 312 | 0x007e6800, | 310 | 0x05f78001 /* 000017de - 000017df [ 2] */, |
| 313 | 0x007ed824, | 311 | 0x05fa8005 /* 000017ea - 000017ef [ 6] */, |
| 314 | 0x00816803, | 312 | 0x05fe8005 /* 000017fa - 000017ff [ 6] */, |
| 315 | 0x00819005, | 313 | 0x06038000 /* 0000180e - 0000180e [ 1] */, |
| 316 | 0x0081c801, | 314 | 0x06068005 /* 0000181a - 0000181f [ 6] */, |
| 317 | 0x0081e801, | 315 | 0x061e4006 /* 00001879 - 0000187f [ 7] */, |
| 318 | 0x0082c001, | 316 | 0x062ac004 /* 000018ab - 000018af [ 5] */, |
| 319 | 0x0082f002, | 317 | 0x063d8009 /* 000018f6 - 000018ff [ 10] */, |
| 320 | 0x00838803, | 318 | 0x0647c000 /* 0000191f - 0000191f [ 1] */, |
| 321 | 0x00841000, | 319 | 0x064b0003 /* 0000192c - 0000192f [ 4] */, |
| 322 | 0x00842801, | 320 | 0x064f0003 /* 0000193c - 0000193f [ 4] */, |
| 323 | 0x00846800, | 321 | 0x06504002 /* 00001941 - 00001943 [ 3] */, |
| 324 | 0x0084e800, | 322 | 0x065b8001 /* 0000196e - 0000196f [ 2] */, |
| 325 | 0x00863000, | 323 | 0x065d400a /* 00001975 - 0000197f [ 11] */, |
| 326 | 0x00864004, | 324 | 0x066b0003 /* 000019ac - 000019af [ 4] */, |
| 327 | 0x00867001, | 325 | 0x06728005 /* 000019ca - 000019cf [ 6] */, |
| 328 | 0x00924800, | 326 | 0x0676c002 /* 000019db - 000019dd [ 3] */, |
| 329 | 0x00927001, | 327 | 0x06870001 /* 00001a1c - 00001a1d [ 2] */, |
| 330 | 0x0092b800, | 328 | 0x0697c000 /* 00001a5f - 00001a5f [ 1] */, |
| 331 | 0x0092c800, | 329 | 0x069f4001 /* 00001a7d - 00001a7e [ 2] */, |
| 332 | 0x0092f001, | 330 | 0x06a28005 /* 00001a8a - 00001a8f [ 6] */, |
| 333 | 0x00944800, | 331 | 0x06a68005 /* 00001a9a - 00001a9f [ 6] */, |
| 334 | 0x00947001, | 332 | 0x06ab8001 /* 00001aae - 00001aaf [ 2] */, |
| 335 | 0x00958800, | 333 | 0x06b3c030 /* 00001acf - 00001aff [ 49] */, |
| 336 | 0x0095b001, | 334 | 0x06d34002 /* 00001b4d - 00001b4f [ 3] */, |
| 337 | 0x0095f800, | 335 | 0x06dfc000 /* 00001b7f - 00001b7f [ 1] */, |
| 338 | 0x00960800, | 336 | 0x06fd0007 /* 00001bf4 - 00001bfb [ 8] */, |
| 339 | 0x00963001, | 337 | 0x070e0002 /* 00001c38 - 00001c3a [ 3] */, |
| 340 | 0x0096b800, | 338 | 0x07128002 /* 00001c4a - 00001c4c [ 3] */, |
| 341 | 0x00988800, | 339 | 0x07224006 /* 00001c89 - 00001c8f [ 7] */, |
| 342 | 0x0098b001, | 340 | 0x072ec001 /* 00001cbb - 00001cbc [ 2] */, |
| 343 | 0x009ad804, | 341 | 0x07320007 /* 00001cc8 - 00001ccf [ 8] */, |
| 344 | 0x009be802, | 342 | 0x073ec004 /* 00001cfb - 00001cff [ 5] */, |
| 345 | 0x009cd005, | 343 | 0x07c58001 /* 00001f16 - 00001f17 [ 2] */, |
| 346 | 0x009fb001, | 344 | 0x07c78001 /* 00001f1e - 00001f1f [ 2] */, |
| 347 | 0x009ff001, | 345 | 0x07d18001 /* 00001f46 - 00001f47 [ 2] */, |
| 348 | 0x00b40000, | 346 | 0x07d38001 /* 00001f4e - 00001f4f [ 2] */, |
| 349 | 0x00b4e802, | 347 | 0x07d60000 /* 00001f58 - 00001f58 [ 1] */, |
| 350 | 0x00b7c806, | 348 | 0x07d68000 /* 00001f5a - 00001f5a [ 1] */, |
| 351 | 0x00b89002, | 349 | 0x07d70000 /* 00001f5c - 00001f5c [ 1] */, |
| 352 | 0x00b8b008, | 350 | 0x07d78000 /* 00001f5e - 00001f5e [ 1] */, |
| 353 | 0x00b99001, | 351 | 0x07df8001 /* 00001f7e - 00001f7f [ 2] */, |
| 354 | 0x00b9b808, | 352 | 0x07ed4000 /* 00001fb5 - 00001fb5 [ 1] */, |
| 355 | 0x00ba900d, | 353 | 0x07f14000 /* 00001fc5 - 00001fc5 [ 1] */, |
| 356 | 0x00bb6800, | 354 | 0x07f50001 /* 00001fd4 - 00001fd5 [ 2] */, |
| 357 | 0x00bb880e, | 355 | 0x07f70000 /* 00001fdc - 00001fdc [ 1] */, |
| 358 | 0x00bda001, | 356 | 0x07fc0001 /* 00001ff0 - 00001ff1 [ 2] */, |
| 359 | 0x00bdb806, | 357 | 0x07fd4000 /* 00001ff5 - 00001ff5 [ 1] */, |
| 360 | 0x00be3000, | 358 | 0x07ffc010 /* 00001fff - 0000200f [ 17] */, |
| 361 | 0x00be480a, | 359 | 0x080a0007 /* 00002028 - 0000202f [ 8] */, |
| 362 | 0x00bee802, | 360 | 0x0817c010 /* 0000205f - 0000206f [ 17] */, |
| 363 | 0x00bf5005, | 361 | 0x081c8001 /* 00002072 - 00002073 [ 2] */, |
| 364 | 0x00bfd005, | 362 | 0x0823c000 /* 0000208f - 0000208f [ 1] */, |
| 365 | 0x00c05804, | 363 | 0x08274002 /* 0000209d - 0000209f [ 3] */, |
| 366 | 0x00c0d005, | 364 | 0x0830400e /* 000020c1 - 000020cf [ 15] */, |
| 367 | 0x00c3c806, | 365 | 0x083c400e /* 000020f1 - 000020ff [ 15] */, |
| 368 | 0x00c42801, | 366 | 0x08630003 /* 0000218c - 0000218f [ 4] */, |
| 369 | 0x00c54800, | 367 | 0x0909c018 /* 00002427 - 0000243f [ 25] */, |
| 370 | 0x00c55804, | 368 | 0x0912c014 /* 0000244b - 0000245f [ 21] */, |
| 371 | 0x00c7b009, | 369 | 0x0add0001 /* 00002b74 - 00002b75 [ 2] */, |
| 372 | 0x00c8f803, | 370 | 0x0ae58000 /* 00002b96 - 00002b96 [ 1] */, |
| 373 | 0x00c93801, | 371 | 0x0b3d0004 /* 00002cf4 - 00002cf8 [ 5] */, |
| 374 | 0x00c96003, | 372 | 0x0b498000 /* 00002d26 - 00002d26 [ 1] */, |
| 375 | 0x00c99000, | 373 | 0x0b4a0004 /* 00002d28 - 00002d2c [ 5] */, |
| 376 | 0x00c9c806, | 374 | 0x0b4b8001 /* 00002d2e - 00002d2f [ 2] */, |
| 377 | 0x00ca0802, | 375 | 0x0b5a0006 /* 00002d68 - 00002d6e [ 7] */, |
| 378 | 0x00cb7001, | 376 | 0x0b5c400d /* 00002d71 - 00002d7e [ 14] */, |
| 379 | 0x00cba80a, | 377 | 0x0b65c008 /* 00002d97 - 00002d9f [ 9] */, |
| 380 | 0x00cd6003, | 378 | 0x0b69c000 /* 00002da7 - 00002da7 [ 1] */, |
| 381 | 0x00ce5005, | 379 | 0x0b6bc000 /* 00002daf - 00002daf [ 1] */, |
| 382 | 0x00ced802, | 380 | 0x0b6dc000 /* 00002db7 - 00002db7 [ 1] */, |
| 383 | 0x00d0b801, | 381 | 0x0b6fc000 /* 00002dbf - 00002dbf [ 1] */, |
| 384 | 0x00d0d802, | 382 | 0x0b71c000 /* 00002dc7 - 00002dc7 [ 1] */, |
| 385 | 0x00d2b000, | 383 | 0x0b73c000 /* 00002dcf - 00002dcf [ 1] */, |
| 386 | 0x00d2c008, | 384 | 0x0b75c000 /* 00002dd7 - 00002dd7 [ 1] */, |
| 387 | 0x00d31000, | 385 | 0x0b77c000 /* 00002ddf - 00002ddf [ 1] */, |
| 388 | 0x00d32807, | 386 | 0x0b978021 /* 00002e5e - 00002e7f [ 34] */, |
| 389 | 0x00d3980c, | 387 | 0x0ba68000 /* 00002e9a - 00002e9a [ 1] */, |
| 390 | 0x00d45005, | 388 | 0x0bbd000b /* 00002ef4 - 00002eff [ 12] */, |
| 391 | 0x00d4d005, | 389 | 0x0bf58019 /* 00002fd6 - 00002fef [ 26] */, |
| 392 | 0x00d57055, | 390 | 0x0c000000 /* 00003000 - 00003000 [ 1] */, |
| 393 | 0x00d9a006, | 391 | 0x0c100000 /* 00003040 - 00003040 [ 1] */, |
| 394 | 0x00d9e000, | 392 | 0x0c25c001 /* 00003097 - 00003098 [ 2] */, |
| 395 | 0x00da1000, | 393 | 0x0c400004 /* 00003100 - 00003104 [ 5] */, |
| 396 | 0x00da6802, | 394 | 0x0c4c0000 /* 00003130 - 00003130 [ 1] */, |
| 397 | 0x00db5808, | 395 | 0x0c63c000 /* 0000318f - 0000318f [ 1] */, |
| 398 | 0x00dbf802, | 396 | 0x0c79000a /* 000031e4 - 000031ee [ 11] */, |
| 399 | 0x00dd1003, | 397 | 0x0c87c000 /* 0000321f - 0000321f [ 1] */, |
| 400 | 0x00dd4001, | 398 | 0x29234002 /* 0000a48d - 0000a48f [ 3] */, |
| 401 | 0x00dd5802, | 399 | 0x2931c008 /* 0000a4c7 - 0000a4cf [ 9] */, |
| 402 | 0x00df3000, | 400 | 0x298b0013 /* 0000a62c - 0000a63f [ 20] */, |
| 403 | 0x00df4001, | 401 | 0x29be0007 /* 0000a6f8 - 0000a6ff [ 8] */, |
| 404 | 0x00df6800, | 402 | 0x29f2c004 /* 0000a7cb - 0000a7cf [ 5] */, |
| 405 | 0x00df7802, | 403 | 0x29f48000 /* 0000a7d2 - 0000a7d2 [ 1] */, |
| 406 | 0x00dfa007, | 404 | 0x29f50000 /* 0000a7d4 - 0000a7d4 [ 1] */, |
| 407 | 0x00e16007, | 405 | 0x29f68017 /* 0000a7da - 0000a7f1 [ 24] */, |
| 408 | 0x00e1b004, | 406 | 0x2a0b4002 /* 0000a82d - 0000a82f [ 3] */, |
| 409 | 0x00e25002, | 407 | 0x2a0e8005 /* 0000a83a - 0000a83f [ 6] */, |
| 410 | 0x00e44806, | 408 | 0x2a1e0007 /* 0000a878 - 0000a87f [ 8] */, |
| 411 | 0x00e5d801, | 409 | 0x2a318007 /* 0000a8c6 - 0000a8cd [ 8] */, |
| 412 | 0x00e6400a, | 410 | 0x2a368005 /* 0000a8da - 0000a8df [ 6] */, |
| 413 | 0x00e6a00c, | 411 | 0x2a55000a /* 0000a954 - 0000a95e [ 11] */, |
| 414 | 0x00e71006, | 412 | 0x2a5f4002 /* 0000a97d - 0000a97f [ 3] */, |
| 415 | 0x00e76800, | 413 | 0x2a738000 /* 0000a9ce - 0000a9ce [ 1] */, |
| 416 | 0x00e7a000, | 414 | 0x2a768003 /* 0000a9da - 0000a9dd [ 4] */, |
| 417 | 0x00e7c001, | 415 | 0x2a7fc000 /* 0000a9ff - 0000a9ff [ 1] */, |
| 418 | 0x00e7d804, | 416 | 0x2a8dc008 /* 0000aa37 - 0000aa3f [ 9] */, |
| 419 | 0x00ee003f, | 417 | 0x2a938001 /* 0000aa4e - 0000aa4f [ 2] */, |
| 420 | 0x00f8b001, | 418 | 0x2a968001 /* 0000aa5a - 0000aa5b [ 2] */, |
| 421 | 0x00f8f001, | 419 | 0x2ab0c017 /* 0000aac3 - 0000aada [ 24] */, |
| 422 | 0x00fa3001, | 420 | 0x2abdc009 /* 0000aaf7 - 0000ab00 [ 10] */, |
| 423 | 0x00fa7001, | 421 | 0x2ac1c001 /* 0000ab07 - 0000ab08 [ 2] */, |
| 424 | 0x00fac000, | 422 | 0x2ac3c001 /* 0000ab0f - 0000ab10 [ 2] */, |
| 425 | 0x00fad000, | 423 | 0x2ac5c008 /* 0000ab17 - 0000ab1f [ 9] */, |
| 426 | 0x00fae000, | 424 | 0x2ac9c000 /* 0000ab27 - 0000ab27 [ 1] */, |
| 427 | 0x00faf000, | 425 | 0x2acbc000 /* 0000ab2f - 0000ab2f [ 1] */, |
| 428 | 0x00fbf001, | 426 | 0x2adb0003 /* 0000ab6c - 0000ab6f [ 4] */, |
| 429 | 0x00fda800, | 427 | 0x2afb8001 /* 0000abee - 0000abef [ 2] */, |
| 430 | 0x00fe2800, | 428 | 0x2afe8005 /* 0000abfa - 0000abff [ 6] */, |
| 431 | 0x00fea001, | 429 | 0x35e9000b /* 0000d7a4 - 0000d7af [ 12] */, |
| 432 | 0x00fee000, | 430 | 0x35f1c003 /* 0000d7c7 - 0000d7ca [ 4] */, |
| 433 | 0x00ff8001, | 431 | 0x35ff2103 /* 0000d7fc - 0000f8ff [ 8452] */, |
| 434 | 0x00ffa800, | 432 | 0x3e9b8001 /* 0000fa6e - 0000fa6f [ 2] */, |
| 435 | 0x00fff810, | 433 | 0x3eb68025 /* 0000fada - 0000faff [ 38] */, |
| 436 | 0x01014007, | 434 | 0x3ec1c00b /* 0000fb07 - 0000fb12 [ 12] */, |
| 437 | 0x0102f810, | 435 | 0x3ec60004 /* 0000fb18 - 0000fb1c [ 5] */, |
| 438 | 0x01039001, | 436 | 0x3ecdc000 /* 0000fb37 - 0000fb37 [ 1] */, |
| 439 | 0x01047800, | 437 | 0x3ecf4000 /* 0000fb3d - 0000fb3d [ 1] */, |
| 440 | 0x0104e802, | 438 | 0x3ecfc000 /* 0000fb3f - 0000fb3f [ 1] */, |
| 441 | 0x0106083e, | 439 | 0x3ed08000 /* 0000fb42 - 0000fb42 [ 1] */, |
| 442 | 0x010c6003, | 440 | 0x3ed14000 /* 0000fb45 - 0000fb45 [ 1] */, |
| 443 | 0x01213818, | 441 | 0x3ef0c00f /* 0000fbc3 - 0000fbd2 [ 16] */, |
| 444 | 0x01225814, | 442 | 0x3f640001 /* 0000fd90 - 0000fd91 [ 2] */, |
| 445 | 0x015ba001, | 443 | 0x3f720006 /* 0000fdc8 - 0000fdce [ 7] */, |
| 446 | 0x015cb000, | 444 | 0x3f74001f /* 0000fdd0 - 0000fdef [ 32] */, |
| 447 | 0x01677802, | 445 | 0x3f868005 /* 0000fe1a - 0000fe1f [ 6] */, |
| 448 | 0x0167a004, | 446 | 0x3f94c000 /* 0000fe53 - 0000fe53 [ 1] */, |
| 449 | 0x01693000, | 447 | 0x3f99c000 /* 0000fe67 - 0000fe67 [ 1] */, |
| 450 | 0x01694004, | 448 | 0x3f9b0003 /* 0000fe6c - 0000fe6f [ 4] */, |
| 451 | 0x01697001, | 449 | 0x3f9d4000 /* 0000fe75 - 0000fe75 [ 1] */, |
| 452 | 0x016b4006, | 450 | 0x3fbf4003 /* 0000fefd - 0000ff00 [ 4] */, |
| 453 | 0x016b880e, | 451 | 0x3fefc002 /* 0000ffbf - 0000ffc1 [ 3] */, |
| 454 | 0x016cb808, | 452 | 0x3ff20001 /* 0000ffc8 - 0000ffc9 [ 2] */, |
| 455 | 0x016d3800, | 453 | 0x3ff40001 /* 0000ffd0 - 0000ffd1 [ 2] */, |
| 456 | 0x016d7800, | 454 | 0x3ff60001 /* 0000ffd8 - 0000ffd9 [ 2] */, |
| 457 | 0x016db800, | 455 | 0x3ff74002 /* 0000ffdd - 0000ffdf [ 3] */, |
| 458 | 0x016df800, | 456 | 0x3ff9c000 /* 0000ffe7 - 0000ffe7 [ 1] */, |
| 459 | 0x016e3800, | 457 | 0x3ffbc00c /* 0000ffef - 0000fffb [ 13] */, |
| 460 | 0x016e7800, | 458 | 0x3fff8001 /* 0000fffe - 0000ffff [ 2] */, |
| 461 | 0x016eb800, | 459 | 0x40030000 /* 0001000c - 0001000c [ 1] */, |
| 462 | 0x016ef820, | 460 | 0x4009c000 /* 00010027 - 00010027 [ 1] */, |
| 463 | 0x0172f021, | 461 | 0x400ec000 /* 0001003b - 0001003b [ 1] */, |
| 464 | 0x0174d000, | 462 | 0x400f8000 /* 0001003e - 0001003e [ 1] */, |
| 465 | 0x0177a00b, | 463 | 0x40138001 /* 0001004e - 0001004f [ 2] */, |
| 466 | 0x017eb019, | 464 | 0x40178021 /* 0001005e - 0001007f [ 34] */, |
| 467 | 0x017fe004, | 465 | 0x403ec004 /* 000100fb - 000100ff [ 5] */, |
| 468 | 0x01815005, | 466 | 0x4040c003 /* 00010103 - 00010106 [ 4] */, |
| 469 | 0x01820000, | 467 | 0x404d0002 /* 00010134 - 00010136 [ 3] */, |
| 470 | 0x0184b803, | 468 | 0x4063c000 /* 0001018f - 0001018f [ 1] */, |
| 471 | 0x01880004, | 469 | 0x40674002 /* 0001019d - 0001019f [ 3] */, |
| 472 | 0x01898000, | 470 | 0x4068402e /* 000101a1 - 000101cf [ 47] */, |
| 473 | 0x018c7800, | 471 | 0x407f8081 /* 000101fe - 0001027f [ 130] */, |
| 474 | 0x018f200b, | 472 | 0x40a74002 /* 0001029d - 0001029f [ 3] */, |
| 475 | 0x0190f800, | 473 | 0x40b4400e /* 000102d1 - 000102df [ 15] */, |
| 476 | 0x05246802, | 474 | 0x40bf0003 /* 000102fc - 000102ff [ 4] */, |
| 477 | 0x05263808, | 475 | 0x40c90008 /* 00010324 - 0001032c [ 9] */, |
| 478 | 0x05316013, | 476 | 0x40d2c004 /* 0001034b - 0001034f [ 5] */, |
| 479 | 0x05337803, | 477 | 0x40dec004 /* 0001037b - 0001037f [ 5] */, |
| 480 | 0x0533a009, | 478 | 0x40e78000 /* 0001039e - 0001039e [ 1] */, |
| 481 | 0x0534f001, | 479 | 0x40f10003 /* 000103c4 - 000103c7 [ 4] */, |
| 482 | 0x05378001, | 480 | 0x40f58029 /* 000103d6 - 000103ff [ 42] */, |
| 483 | 0x0537c007, | 481 | 0x41278001 /* 0001049e - 0001049f [ 2] */, |
| 484 | 0x053e5804, | 482 | 0x412a8005 /* 000104aa - 000104af [ 6] */, |
| 485 | 0x053e9000, | 483 | 0x41350003 /* 000104d4 - 000104d7 [ 4] */, |
| 486 | 0x053ea000, | 484 | 0x413f0003 /* 000104fc - 000104ff [ 4] */, |
| 487 | 0x053ed017, | 485 | 0x414a0007 /* 00010528 - 0001052f [ 8] */, |
| 488 | 0x05401000, | 486 | 0x4159000a /* 00010564 - 0001056e [ 11] */, |
| 489 | 0x05403000, | 487 | 0x415ec000 /* 0001057b - 0001057b [ 1] */, |
| 490 | 0x05405800, | 488 | 0x4162c000 /* 0001058b - 0001058b [ 1] */, |
| 491 | 0x05412801, | 489 | 0x4164c000 /* 00010593 - 00010593 [ 1] */, |
| 492 | 0x05416003, | 490 | 0x41658000 /* 00010596 - 00010596 [ 1] */, |
| 493 | 0x0541d005, | 491 | 0x41688000 /* 000105a2 - 000105a2 [ 1] */, |
| 494 | 0x0543c007, | 492 | 0x416c8000 /* 000105b2 - 000105b2 [ 1] */, |
| 495 | 0x05462009, | 493 | 0x416e8000 /* 000105ba - 000105ba [ 1] */, |
| 496 | 0x0546d017, | 494 | 0x416f4042 /* 000105bd - 000105ff [ 67] */, |
| 497 | 0x0547f800, | 495 | 0x41cdc008 /* 00010737 - 0001073f [ 9] */, |
| 498 | 0x05493007, | 496 | 0x41d58009 /* 00010756 - 0001075f [ 10] */, |
| 499 | 0x054a380a, | 497 | 0x41da0017 /* 00010768 - 0001077f [ 24] */, |
| 500 | 0x054aa00a, | 498 | 0x41e18000 /* 00010786 - 00010786 [ 1] */, |
| 501 | 0x054be805, | 499 | 0x41ec4000 /* 000107b1 - 000107b1 [ 1] */, |
| 502 | 0x054d9800, | 500 | 0x41eec044 /* 000107bb - 000107ff [ 69] */, |
| 503 | 0x054db003, | 501 | 0x42018001 /* 00010806 - 00010807 [ 2] */, |
| 504 | 0x054de001, | 502 | 0x42024000 /* 00010809 - 00010809 [ 1] */, |
| 505 | 0x054e7000, | 503 | 0x420d8000 /* 00010836 - 00010836 [ 1] */, |
| 506 | 0x054ed003, | 504 | 0x420e4002 /* 00010839 - 0001083b [ 3] */, |
| 507 | 0x054f2800, | 505 | 0x420f4001 /* 0001083d - 0001083e [ 2] */, |
| 508 | 0x054ff800, | 506 | 0x42158000 /* 00010856 - 00010856 [ 1] */, |
| 509 | 0x05514805, | 507 | 0x4227c007 /* 0001089f - 000108a6 [ 8] */, |
| 510 | 0x05518801, | 508 | 0x422c002f /* 000108b0 - 000108df [ 48] */, |
| 511 | 0x0551a80a, | 509 | 0x423cc000 /* 000108f3 - 000108f3 [ 1] */, |
| 512 | 0x05521800, | 510 | 0x423d8004 /* 000108f6 - 000108fa [ 5] */, |
| 513 | 0x05526000, | 511 | 0x42470002 /* 0001091c - 0001091e [ 3] */, |
| 514 | 0x05527001, | 512 | 0x424e8004 /* 0001093a - 0001093e [ 5] */, |
| 515 | 0x0552d001, | 513 | 0x4250003f /* 00010940 - 0001097f [ 64] */, |
| 516 | 0x0553e000, | 514 | 0x426e0003 /* 000109b8 - 000109bb [ 4] */, |
| 517 | 0x05558000, | 515 | 0x42740001 /* 000109d0 - 000109d1 [ 2] */, |
| 518 | 0x05559002, | 516 | 0x42810000 /* 00010a04 - 00010a04 [ 1] */, |
| 519 | 0x0555b801, | 517 | 0x4281c004 /* 00010a07 - 00010a0b [ 5] */, |
| 520 | 0x0555f001, | 518 | 0x42850000 /* 00010a14 - 00010a14 [ 1] */, |
| 521 | 0x05560800, | 519 | 0x42860000 /* 00010a18 - 00010a18 [ 1] */, |
| 522 | 0x05561817, | 520 | 0x428d8001 /* 00010a36 - 00010a37 [ 2] */, |
| 523 | 0x05576001, | 521 | 0x428ec003 /* 00010a3b - 00010a3e [ 4] */, |
| 524 | 0x0557b00a, | 522 | 0x42924006 /* 00010a49 - 00010a4f [ 7] */, |
| 525 | 0x05583801, | 523 | 0x42964006 /* 00010a59 - 00010a5f [ 7] */, |
| 526 | 0x05587801, | 524 | 0x42a8001f /* 00010aa0 - 00010abf [ 32] */, |
| 527 | 0x0558b808, | 525 | 0x42b9c003 /* 00010ae7 - 00010aea [ 4] */, |
| 528 | 0x05593800, | 526 | 0x42bdc008 /* 00010af7 - 00010aff [ 9] */, |
| 529 | 0x05597800, | 527 | 0x42cd8002 /* 00010b36 - 00010b38 [ 3] */, |
| 530 | 0x055b6003, | 528 | 0x42d58001 /* 00010b56 - 00010b57 [ 2] */, |
| 531 | 0x055f2800, | 529 | 0x42dcc004 /* 00010b73 - 00010b77 [ 5] */, |
| 532 | 0x055f4000, | 530 | 0x42e48006 /* 00010b92 - 00010b98 [ 7] */, |
| 533 | 0x055f6802, | 531 | 0x42e7400b /* 00010b9d - 00010ba8 [ 12] */, |
| 534 | 0x055fd005, | 532 | 0x42ec004f /* 00010bb0 - 00010bff [ 80] */, |
| 535 | 0x06bd200b, | 533 | 0x43124036 /* 00010c49 - 00010c7f [ 55] */, |
| 536 | 0x06be3803, | 534 | 0x432cc00c /* 00010cb3 - 00010cbf [ 13] */, |
| 537 | 0x06bfe7ff, | 535 | 0x433cc006 /* 00010cf3 - 00010cf9 [ 7] */, |
| 538 | 0x06ffe7ff, | 536 | 0x434a0007 /* 00010d28 - 00010d2f [ 8] */, |
| 539 | 0x073fe7ff, | 537 | 0x434e8125 /* 00010d3a - 00010e5f [ 294] */, |
| 540 | 0x077fe7ff, | 538 | 0x439fc000 /* 00010e7f - 00010e7f [ 1] */, |
| 541 | 0x07bfe103, | 539 | 0x43aa8000 /* 00010eaa - 00010eaa [ 1] */, |
| 542 | 0x07d37001, | 540 | 0x43ab8001 /* 00010eae - 00010eaf [ 2] */, |
| 543 | 0x07d6d025, | 541 | 0x43ac804a /* 00010eb2 - 00010efc [ 75] */, |
| 544 | 0x07d8380b, | 542 | 0x43ca0007 /* 00010f28 - 00010f2f [ 8] */, |
| 545 | 0x07d8c004, | 543 | 0x43d68015 /* 00010f5a - 00010f6f [ 22] */, |
| 546 | 0x07d8f000, | 544 | 0x43e28025 /* 00010f8a - 00010faf [ 38] */, |
| 547 | 0x07d9b800, | 545 | 0x43f30013 /* 00010fcc - 00010fdf [ 20] */, |
| 548 | 0x07d9e800, | 546 | 0x43fdc008 /* 00010ff7 - 00010fff [ 9] */, |
| 549 | 0x07d9f800, | 547 | 0x44138003 /* 0001104e - 00011051 [ 4] */, |
| 550 | 0x07da1000, | 548 | 0x441d8008 /* 00011076 - 0001107e [ 9] */, |
| 551 | 0x07da2800, | 549 | 0x442f4000 /* 000110bd - 000110bd [ 1] */, |
| 552 | 0x07de180f, | 550 | 0x4430c00c /* 000110c3 - 000110cf [ 13] */, |
| 553 | 0x07ec8001, | 551 | 0x443a4006 /* 000110e9 - 000110ef [ 7] */, |
| 554 | 0x07ee4006, | 552 | 0x443e8005 /* 000110fa - 000110ff [ 6] */, |
| 555 | 0x07ee801f, | 553 | 0x444d4000 /* 00011135 - 00011135 [ 1] */, |
| 556 | 0x07f0000f, | 554 | 0x44520007 /* 00011148 - 0001114f [ 8] */, |
| 557 | 0x07f0d015, | 555 | 0x445dc008 /* 00011177 - 0001117f [ 9] */, |
| 558 | 0x07f29800, | 556 | 0x44780000 /* 000111e0 - 000111e0 [ 1] */, |
| 559 | 0x07f33800, | 557 | 0x447d400a /* 000111f5 - 000111ff [ 11] */, |
| 560 | 0x07f36003, | 558 | 0x44848000 /* 00011212 - 00011212 [ 1] */, |
| 561 | 0x07f3a800, | 559 | 0x4490803d /* 00011242 - 0001127f [ 62] */, |
| 562 | 0x07f7e803, | 560 | 0x44a1c000 /* 00011287 - 00011287 [ 1] */, |
| 563 | 0x07fcf001, | 561 | 0x44a24000 /* 00011289 - 00011289 [ 1] */, |
| 564 | 0x07fdf802, | 562 | 0x44a38000 /* 0001128e - 0001128e [ 1] */, |
| 565 | 0x07fe4001, | 563 | 0x44a78000 /* 0001129e - 0001129e [ 1] */, |
| 566 | 0x07fe8001, | 564 | 0x44aa8005 /* 000112aa - 000112af [ 6] */, |
| 567 | 0x07fec001, | 565 | 0x44bac004 /* 000112eb - 000112ef [ 5] */, |
| 568 | 0x07fee802, | 566 | 0x44be8005 /* 000112fa - 000112ff [ 6] */, |
| 569 | 0x07ff3800, | 567 | 0x44c10000 /* 00011304 - 00011304 [ 1] */, |
| 570 | 0x07ff780c, | 568 | 0x44c34001 /* 0001130d - 0001130e [ 2] */, |
| 571 | 0x07fff001, | 569 | 0x44c44001 /* 00011311 - 00011312 [ 2] */, |
| 572 | 0x08006000, | 570 | 0x44ca4000 /* 00011329 - 00011329 [ 1] */, |
| 573 | 0x08013800, | 571 | 0x44cc4000 /* 00011331 - 00011331 [ 1] */, |
| 574 | 0x0801d800, | 572 | 0x44cd0000 /* 00011334 - 00011334 [ 1] */, |
| 575 | 0x0801f000, | 573 | 0x44ce8000 /* 0001133a - 0001133a [ 1] */, |
| 576 | 0x08027001, | 574 | 0x44d14001 /* 00011345 - 00011346 [ 2] */, |
| 577 | 0x0802f021, | 575 | 0x44d24001 /* 00011349 - 0001134a [ 2] */, |
| 578 | 0x0807d804, | 576 | 0x44d38001 /* 0001134e - 0001134f [ 2] */, |
| 579 | 0x08081803, | 577 | 0x44d44005 /* 00011351 - 00011356 [ 6] */, |
| 580 | 0x0809a002, | 578 | 0x44d60004 /* 00011358 - 0001135c [ 5] */, |
| 581 | 0x080c7800, | 579 | 0x44d90001 /* 00011364 - 00011365 [ 2] */, |
| 582 | 0x080ce802, | 580 | 0x44db4002 /* 0001136d - 0001136f [ 3] */, |
| 583 | 0x080d082e, | 581 | 0x44dd408a /* 00011375 - 000113ff [ 139] */, |
| 584 | 0x080fe882, | 582 | 0x45170000 /* 0001145c - 0001145c [ 1] */, |
| 585 | 0x0814e802, | 583 | 0x4518801d /* 00011462 - 0001147f [ 30] */, |
| 586 | 0x0816880f, | 584 | 0x45320007 /* 000114c8 - 000114cf [ 8] */, |
| 587 | 0x0817e003, | 585 | 0x453680a5 /* 000114da - 0001157f [ 166] */, |
| 588 | 0x08192008, | 586 | 0x456d8001 /* 000115b6 - 000115b7 [ 2] */, |
| 589 | 0x081a5804, | 587 | 0x45778021 /* 000115de - 000115ff [ 34] */, |
| 590 | 0x081bb009, | 588 | 0x4591400a /* 00011645 - 0001164f [ 11] */, |
| 591 | 0x081cf000, | 589 | 0x45968005 /* 0001165a - 0001165f [ 6] */, |
| 592 | 0x081e2003, | 590 | 0x459b4012 /* 0001166d - 0001167f [ 19] */, |
| 593 | 0x081eb029, | 591 | 0x45ae8005 /* 000116ba - 000116bf [ 6] */, |
| 594 | 0x0824f001, | 592 | 0x45b28035 /* 000116ca - 000116ff [ 54] */, |
| 595 | 0x08255005, | 593 | 0x45c6c001 /* 0001171b - 0001171c [ 2] */, |
| 596 | 0x0826a003, | 594 | 0x45cb0003 /* 0001172c - 0001172f [ 4] */, |
| 597 | 0x0827e003, | 595 | 0x45d1c0b8 /* 00011747 - 000117ff [ 185] */, |
| 598 | 0x08294007, | 596 | 0x460f0063 /* 0001183c - 0001189f [ 100] */, |
| 599 | 0x082b200a, | 597 | 0x463cc00b /* 000118f3 - 000118fe [ 12] */, |
| 600 | 0x082bd800, | 598 | 0x4641c001 /* 00011907 - 00011908 [ 2] */, |
| 601 | 0x082c5800, | 599 | 0x46428001 /* 0001190a - 0001190b [ 2] */, |
| 602 | 0x082c9800, | 600 | 0x46450000 /* 00011914 - 00011914 [ 1] */, |
| 603 | 0x082cb000, | 601 | 0x4645c000 /* 00011917 - 00011917 [ 1] */, |
| 604 | 0x082d1000, | 602 | 0x464d8000 /* 00011936 - 00011936 [ 1] */, |
| 605 | 0x082d9000, | 603 | 0x464e4001 /* 00011939 - 0001193a [ 2] */, |
| 606 | 0x082dd000, | 604 | 0x4651c008 /* 00011947 - 0001194f [ 9] */, |
| 607 | 0x082de842, | 605 | 0x46568045 /* 0001195a - 0001199f [ 70] */, |
| 608 | 0x0839b808, | 606 | 0x466a0001 /* 000119a8 - 000119a9 [ 2] */, |
| 609 | 0x083ab009, | 607 | 0x46760001 /* 000119d8 - 000119d9 [ 2] */, |
| 610 | 0x083b4017, | 608 | 0x4679401a /* 000119e5 - 000119ff [ 27] */, |
| 611 | 0x083c3000, | 609 | 0x46920007 /* 00011a48 - 00011a4f [ 8] */, |
| 612 | 0x083d8800, | 610 | 0x46a8c00c /* 00011aa3 - 00011aaf [ 13] */, |
| 613 | 0x083dd844, | 611 | 0x46be4006 /* 00011af9 - 00011aff [ 7] */, |
| 614 | 0x08403001, | 612 | 0x46c280f5 /* 00011b0a - 00011bff [ 246] */, |
| 615 | 0x08404800, | 613 | 0x47024000 /* 00011c09 - 00011c09 [ 1] */, |
| 616 | 0x0841b000, | 614 | 0x470dc000 /* 00011c37 - 00011c37 [ 1] */, |
| 617 | 0x0841c802, | 615 | 0x47118009 /* 00011c46 - 00011c4f [ 10] */, |
| 618 | 0x0841e801, | 616 | 0x471b4002 /* 00011c6d - 00011c6f [ 3] */, |
| 619 | 0x0842b000, | 617 | 0x47240001 /* 00011c90 - 00011c91 [ 2] */, |
| 620 | 0x0844f807, | 618 | 0x472a0000 /* 00011ca8 - 00011ca8 [ 1] */, |
| 621 | 0x0845802f, | 619 | 0x472dc048 /* 00011cb7 - 00011cff [ 73] */, |
| 622 | 0x08479800, | 620 | 0x4741c000 /* 00011d07 - 00011d07 [ 1] */, |
| 623 | 0x0847b004, | 621 | 0x47428000 /* 00011d0a - 00011d0a [ 1] */, |
| 624 | 0x0848e002, | 622 | 0x474dc002 /* 00011d37 - 00011d39 [ 3] */, |
| 625 | 0x0849d004, | 623 | 0x474ec000 /* 00011d3b - 00011d3b [ 1] */, |
| 626 | 0x084a003f, | 624 | 0x474f8000 /* 00011d3e - 00011d3e [ 1] */, |
| 627 | 0x084dc003, | 625 | 0x47520007 /* 00011d48 - 00011d4f [ 8] */, |
| 628 | 0x084e8001, | 626 | 0x47568005 /* 00011d5a - 00011d5f [ 6] */, |
| 629 | 0x0850080e, | 627 | 0x47598000 /* 00011d66 - 00011d66 [ 1] */, |
| 630 | 0x0850a000, | 628 | 0x475a4000 /* 00011d69 - 00011d69 [ 1] */, |
| 631 | 0x0850c000, | 629 | 0x4763c000 /* 00011d8f - 00011d8f [ 1] */, |
| 632 | 0x0851b009, | 630 | 0x47648000 /* 00011d92 - 00011d92 [ 1] */, |
| 633 | 0x08524806, | 631 | 0x47664006 /* 00011d99 - 00011d9f [ 7] */, |
| 634 | 0x0852c806, | 632 | 0x476a8135 /* 00011daa - 00011edf [ 310] */, |
| 635 | 0x0855001f, | 633 | 0x47be4006 /* 00011ef9 - 00011eff [ 7] */, |
| 636 | 0x08572805, | 634 | 0x47c44000 /* 00011f11 - 00011f11 [ 1] */, |
| 637 | 0x0857b808, | 635 | 0x47cec002 /* 00011f3b - 00011f3d [ 3] */, |
| 638 | 0x0859b002, | 636 | 0x47d68055 /* 00011f5a - 00011faf [ 86] */, |
| 639 | 0x085ab001, | 637 | 0x47ec400e /* 00011fb1 - 00011fbf [ 15] */, |
| 640 | 0x085b9804, | 638 | 0x47fc800c /* 00011ff2 - 00011ffe [ 13] */, |
| 641 | 0x085c9006, | 639 | 0x48e68065 /* 0001239a - 000123ff [ 102] */, |
| 642 | 0x085ce80b, | 640 | 0x491bc000 /* 0001246f - 0001246f [ 1] */, |
| 643 | 0x085d804f, | 641 | 0x491d400a /* 00012475 - 0001247f [ 11] */, |
| 644 | 0x08624836, | 642 | 0x49510a4b /* 00012544 - 00012f8f [ 2636] */, |
| 645 | 0x0865980c, | 643 | 0x4bfcc00c /* 00012ff3 - 00012fff [ 13] */, |
| 646 | 0x08679806, | 644 | 0x4d0c000f /* 00013430 - 0001343f [ 16] */, |
| 647 | 0x0869200b, | 645 | 0x4d158fa9 /* 00013456 - 000143ff [ 4010] */, |
| 648 | 0x0869d125, | 646 | 0x5191e1b8 /* 00014647 - 000167ff [ 8633] */, |
| 649 | 0x0873f800, | 647 | 0x5a8e4006 /* 00016a39 - 00016a3f [ 7] */, |
| 650 | 0x08755002, | 648 | 0x5a97c000 /* 00016a5f - 00016a5f [ 1] */, |
| 651 | 0x08757001, | 649 | 0x5a9a8003 /* 00016a6a - 00016a6d [ 4] */, |
| 652 | 0x0875904d, | 650 | 0x5aafc000 /* 00016abf - 00016abf [ 1] */, |
| 653 | 0x08794007, | 651 | 0x5ab28005 /* 00016aca - 00016acf [ 6] */, |
| 654 | 0x087a300a, | 652 | 0x5abb8001 /* 00016aee - 00016aef [ 2] */, |
| 655 | 0x087ad015, | 653 | 0x5abd8009 /* 00016af6 - 00016aff [ 10] */, |
| 656 | 0x087c1003, | 654 | 0x5ad18009 /* 00016b46 - 00016b4f [ 10] */, |
| 657 | 0x087c5025, | 655 | 0x5ad68000 /* 00016b5a - 00016b5a [ 1] */, |
| 658 | 0x087e6013, | 656 | 0x5ad88000 /* 00016b62 - 00016b62 [ 1] */, |
| 659 | 0x087fb808, | 657 | 0x5ade0004 /* 00016b78 - 00016b7c [ 5] */, |
| 660 | 0x08800800, | 658 | 0x5ae402af /* 00016b90 - 00016e3f [ 688] */, |
| 661 | 0x0881c00e, | 659 | 0x5ba6c064 /* 00016e9b - 00016eff [ 101] */, |
| 662 | 0x08827003, | 660 | 0x5bd2c003 /* 00016f4b - 00016f4e [ 4] */, |
| 663 | 0x08838000, | 661 | 0x5be20006 /* 00016f88 - 00016f8e [ 7] */, |
| 664 | 0x08839801, | 662 | 0x5be8003f /* 00016fa0 - 00016fdf [ 64] */, |
| 665 | 0x0883b00b, | 663 | 0x5bf9400a /* 00016fe5 - 00016fef [ 11] */, |
| 666 | 0x08859803, | 664 | 0x5bfc800d /* 00016ff2 - 00016fff [ 14] */, |
| 667 | 0x0885c801, | 665 | 0x61fe0007 /* 000187f8 - 000187ff [ 8] */, |
| 668 | 0x0885e800, | 666 | 0x63358029 /* 00018cd6 - 00018cff [ 42] */, |
| 669 | 0x0886100d, | 667 | 0x634262e6 /* 00018d09 - 0001afef [ 8935] */, |
| 670 | 0x08874806, | 668 | 0x6bfd0000 /* 0001aff4 - 0001aff4 [ 1] */, |
| 671 | 0x0887d008, | 669 | 0x6bff0000 /* 0001affc - 0001affc [ 1] */, |
| 672 | 0x08893804, | 670 | 0x6bffc000 /* 0001afff - 0001afff [ 1] */, |
| 673 | 0x08896808, | 671 | 0x6c48c00e /* 0001b123 - 0001b131 [ 15] */, |
| 674 | 0x088a4007, | 672 | 0x6c4cc01c /* 0001b133 - 0001b14f [ 29] */, |
| 675 | 0x088b9800, | 673 | 0x6c54c001 /* 0001b153 - 0001b154 [ 2] */, |
| 676 | 0x088bb80a, | 674 | 0x6c55800d /* 0001b156 - 0001b163 [ 14] */, |
| 677 | 0x088db008, | 675 | 0x6c5a0007 /* 0001b168 - 0001b16f [ 8] */, |
| 678 | 0x088e4803, | 676 | 0x6cbf0903 /* 0001b2fc - 0001bbff [ 2308] */, |
| 679 | 0x088e7800, | 677 | 0x6f1ac004 /* 0001bc6b - 0001bc6f [ 5] */, |
| 680 | 0x088f0000, | 678 | 0x6f1f4002 /* 0001bc7d - 0001bc7f [ 3] */, |
| 681 | 0x088fa80a, | 679 | 0x6f224006 /* 0001bc89 - 0001bc8f [ 7] */, |
| 682 | 0x08909000, | 680 | 0x6f268001 /* 0001bc9a - 0001bc9b [ 2] */, |
| 683 | 0x08917802, | 681 | 0x6f28125f /* 0001bca0 - 0001ceff [ 4704] */, |
| 684 | 0x0891a000, | 682 | 0x73cb8001 /* 0001cf2e - 0001cf2f [ 2] */, |
| 685 | 0x0891b001, | 683 | 0x73d1c008 /* 0001cf47 - 0001cf4f [ 9] */, |
| 686 | 0x0891f000, | 684 | 0x73f1003b /* 0001cfc4 - 0001cfff [ 60] */, |
| 687 | 0x0892083e, | 685 | 0x743d8009 /* 0001d0f6 - 0001d0ff [ 10] */, |
| 688 | 0x08943800, | 686 | 0x7449c001 /* 0001d127 - 0001d128 [ 2] */, |
| 689 | 0x08944800, | 687 | 0x745cc007 /* 0001d173 - 0001d17a [ 8] */, |
| 690 | 0x08947000, | 688 | 0x747ac014 /* 0001d1eb - 0001d1ff [ 21] */, |
| 691 | 0x0894f000, | 689 | 0x74918079 /* 0001d246 - 0001d2bf [ 122] */, |
| 692 | 0x08955005, | 690 | 0x74b5000b /* 0001d2d4 - 0001d2df [ 12] */, |
| 693 | 0x0896f800, | 691 | 0x74bd000b /* 0001d2f4 - 0001d2ff [ 12] */, |
| 694 | 0x0897180c, | 692 | 0x74d5c008 /* 0001d357 - 0001d35f [ 9] */, |
| 695 | 0x0897d007, | 693 | 0x74de4086 /* 0001d379 - 0001d3ff [ 135] */, |
| 696 | 0x08982000, | 694 | 0x75154000 /* 0001d455 - 0001d455 [ 1] */, |
| 697 | 0x08986801, | 695 | 0x75274000 /* 0001d49d - 0001d49d [ 1] */, |
| 698 | 0x08988801, | 696 | 0x75280001 /* 0001d4a0 - 0001d4a1 [ 2] */, |
| 699 | 0x08994800, | 697 | 0x7528c001 /* 0001d4a3 - 0001d4a4 [ 2] */, |
| 700 | 0x08998800, | 698 | 0x7529c001 /* 0001d4a7 - 0001d4a8 [ 2] */, |
| 701 | 0x0899a000, | 699 | 0x752b4000 /* 0001d4ad - 0001d4ad [ 1] */, |
| 702 | 0x0899d002, | 700 | 0x752e8000 /* 0001d4ba - 0001d4ba [ 1] */, |
| 703 | 0x0899f000, | 701 | 0x752f0000 /* 0001d4bc - 0001d4bc [ 1] */, |
| 704 | 0x089a0000, | 702 | 0x75310000 /* 0001d4c4 - 0001d4c4 [ 1] */, |
| 705 | 0x089a2801, | 703 | 0x75418000 /* 0001d506 - 0001d506 [ 1] */, |
| 706 | 0x089a4801, | 704 | 0x7542c001 /* 0001d50b - 0001d50c [ 2] */, |
| 707 | 0x089a7001, | 705 | 0x75454000 /* 0001d515 - 0001d515 [ 1] */, |
| 708 | 0x089a880b, | 706 | 0x75474000 /* 0001d51d - 0001d51d [ 1] */, |
| 709 | 0x089b209b, | 707 | 0x754e8000 /* 0001d53a - 0001d53a [ 1] */, |
| 710 | 0x08a1c007, | 708 | 0x754fc000 /* 0001d53f - 0001d53f [ 1] */, |
| 711 | 0x08a21002, | 709 | 0x75514000 /* 0001d545 - 0001d545 [ 1] */, |
| 712 | 0x08a23000, | 710 | 0x7551c002 /* 0001d547 - 0001d549 [ 3] */, |
| 713 | 0x08a2e000, | 711 | 0x75544000 /* 0001d551 - 0001d551 [ 1] */, |
| 714 | 0x08a2f000, | 712 | 0x75a98001 /* 0001d6a6 - 0001d6a7 [ 2] */, |
| 715 | 0x08a3101d, | 713 | 0x75f30001 /* 0001d7cc - 0001d7cd [ 2] */, |
| 716 | 0x08a58000, | 714 | 0x76a3000e /* 0001da8c - 0001da9a [ 15] */, |
| 717 | 0x08a59805, | 715 | 0x76a80000 /* 0001daa0 - 0001daa0 [ 1] */, |
| 718 | 0x08a5d000, | 716 | 0x76ac044f /* 0001dab0 - 0001deff [ 1104] */, |
| 719 | 0x08a5e800, | 717 | 0x77c7c005 /* 0001df1f - 0001df24 [ 6] */, |
| 720 | 0x08a5f801, | 718 | 0x77cac0d4 /* 0001df2b - 0001dfff [ 213] */, |
| 721 | 0x08a61001, | 719 | 0x7801c000 /* 0001e007 - 0001e007 [ 1] */, |
| 722 | 0x08a64007, | 720 | 0x78064001 /* 0001e019 - 0001e01a [ 2] */, |
| 723 | 0x08a6d0a5, | 721 | 0x78088000 /* 0001e022 - 0001e022 [ 1] */, |
| 724 | 0x08ad7800, | 722 | 0x78094000 /* 0001e025 - 0001e025 [ 1] */, |
| 725 | 0x08ad9005, | 723 | 0x780ac004 /* 0001e02b - 0001e02f [ 5] */, |
| 726 | 0x08ade001, | 724 | 0x781b8020 /* 0001e06e - 0001e08e [ 33] */, |
| 727 | 0x08adf801, | 725 | 0x7824006f /* 0001e090 - 0001e0ff [ 112] */, |
| 728 | 0x08aee023, | 726 | 0x784b4002 /* 0001e12d - 0001e12f [ 3] */, |
| 729 | 0x08b19807, | 727 | 0x784f8001 /* 0001e13e - 0001e13f [ 2] */, |
| 730 | 0x08b1e800, | 728 | 0x78528003 /* 0001e14a - 0001e14d [ 4] */, |
| 731 | 0x08b1f801, | 729 | 0x7854013f /* 0001e150 - 0001e28f [ 320] */, |
| 732 | 0x08b2280a, | 730 | 0x78abc010 /* 0001e2af - 0001e2bf [ 17] */, |
| 733 | 0x08b2d005, | 731 | 0x78be8004 /* 0001e2fa - 0001e2fe [ 5] */, |
| 734 | 0x08b36812, | 732 | 0x78c001cf /* 0001e300 - 0001e4cf [ 464] */, |
| 735 | 0x08b55800, | 733 | 0x793e82e5 /* 0001e4fa - 0001e7df [ 742] */, |
| 736 | 0x08b56800, | 734 | 0x79f9c000 /* 0001e7e7 - 0001e7e7 [ 1] */, |
| 737 | 0x08b58005, | 735 | 0x79fb0000 /* 0001e7ec - 0001e7ec [ 1] */, |
| 738 | 0x08b5b800, | 736 | 0x79fbc000 /* 0001e7ef - 0001e7ef [ 1] */, |
| 739 | 0x08b5d005, | 737 | 0x79ffc000 /* 0001e7ff - 0001e7ff [ 1] */, |
| 740 | 0x08b65035, | 738 | 0x7a314001 /* 0001e8c5 - 0001e8c6 [ 2] */, |
| 741 | 0x08b8d804, | 739 | 0x7a35c028 /* 0001e8d7 - 0001e8ff [ 41] */, |
| 742 | 0x08b91003, | 740 | 0x7a530003 /* 0001e94c - 0001e94f [ 4] */, |
| 743 | 0x08b93808, | 741 | 0x7a568003 /* 0001e95a - 0001e95d [ 4] */, |
| 744 | 0x08ba38b8, | 742 | 0x7a580310 /* 0001e960 - 0001ec70 [ 785] */, |
| 745 | 0x08c17808, | 743 | 0x7b2d404b /* 0001ecb5 - 0001ed00 [ 76] */, |
| 746 | 0x08c1c801, | 744 | 0x7b4f80c1 /* 0001ed3e - 0001edff [ 194] */, |
| 747 | 0x08c1e063, | 745 | 0x7b810000 /* 0001ee04 - 0001ee04 [ 1] */, |
| 748 | 0x08c7980b, | 746 | 0x7b880000 /* 0001ee20 - 0001ee20 [ 1] */, |
| 749 | 0x08c83801, | 747 | 0x7b88c000 /* 0001ee23 - 0001ee23 [ 1] */, |
| 750 | 0x08c85001, | 748 | 0x7b894001 /* 0001ee25 - 0001ee26 [ 2] */, |
| 751 | 0x08c8a000, | 749 | 0x7b8a0000 /* 0001ee28 - 0001ee28 [ 1] */, |
| 752 | 0x08c8b800, | 750 | 0x7b8cc000 /* 0001ee33 - 0001ee33 [ 1] */, |
| 753 | 0x08c98000, | 751 | 0x7b8e0000 /* 0001ee38 - 0001ee38 [ 1] */, |
| 754 | 0x08c9b000, | 752 | 0x7b8e8000 /* 0001ee3a - 0001ee3a [ 1] */, |
| 755 | 0x08c9c803, | 753 | 0x7b8f0005 /* 0001ee3c - 0001ee41 [ 6] */, |
| 756 | 0x08c9f000, | 754 | 0x7b90c003 /* 0001ee43 - 0001ee46 [ 4] */, |
| 757 | 0x08ca1800, | 755 | 0x7b920000 /* 0001ee48 - 0001ee48 [ 1] */, |
| 758 | 0x08ca3808, | 756 | 0x7b928000 /* 0001ee4a - 0001ee4a [ 1] */, |
| 759 | 0x08cad045, | 757 | 0x7b930000 /* 0001ee4c - 0001ee4c [ 1] */, |
| 760 | 0x08cd4001, | 758 | 0x7b940000 /* 0001ee50 - 0001ee50 [ 1] */, |
| 761 | 0x08cea007, | 759 | 0x7b94c000 /* 0001ee53 - 0001ee53 [ 1] */, |
| 762 | 0x08cf0000, | 760 | 0x7b954001 /* 0001ee55 - 0001ee56 [ 2] */, |
| 763 | 0x08cf281a, | 761 | 0x7b960000 /* 0001ee58 - 0001ee58 [ 1] */, |
| 764 | 0x08d00809, | 762 | 0x7b968000 /* 0001ee5a - 0001ee5a [ 1] */, |
| 765 | 0x08d19805, | 763 | 0x7b970000 /* 0001ee5c - 0001ee5c [ 1] */, |
| 766 | 0x08d1d803, | 764 | 0x7b978000 /* 0001ee5e - 0001ee5e [ 1] */, |
| 767 | 0x08d23808, | 765 | 0x7b980000 /* 0001ee60 - 0001ee60 [ 1] */, |
| 768 | 0x08d28805, | 766 | 0x7b98c000 /* 0001ee63 - 0001ee63 [ 1] */, |
| 769 | 0x08d2c802, | 767 | 0x7b994001 /* 0001ee65 - 0001ee66 [ 2] */, |
| 770 | 0x08d4500c, | 768 | 0x7b9ac000 /* 0001ee6b - 0001ee6b [ 1] */, |
| 771 | 0x08d4c001, | 769 | 0x7b9cc000 /* 0001ee73 - 0001ee73 [ 1] */, |
| 772 | 0x08d5180c, | 770 | 0x7b9e0000 /* 0001ee78 - 0001ee78 [ 1] */, |
| 773 | 0x08d7c806, | 771 | 0x7b9f4000 /* 0001ee7d - 0001ee7d [ 1] */, |
| 774 | 0x08d850f5, | 772 | 0x7b9fc000 /* 0001ee7f - 0001ee7f [ 1] */, |
| 775 | 0x08e04800, | 773 | 0x7ba28000 /* 0001ee8a - 0001ee8a [ 1] */, |
| 776 | 0x08e1800d, | 774 | 0x7ba70004 /* 0001ee9c - 0001eea0 [ 5] */, |
| 777 | 0x08e1f800, | 775 | 0x7ba90000 /* 0001eea4 - 0001eea4 [ 1] */, |
| 778 | 0x08e23009, | 776 | 0x7baa8000 /* 0001eeaa - 0001eeaa [ 1] */, |
| 779 | 0x08e36802, | 777 | 0x7baf0033 /* 0001eebc - 0001eeef [ 52] */, |
| 780 | 0x08e48018, | 778 | 0x7bbc810d /* 0001eef2 - 0001efff [ 270] */, |
| 781 | 0x08e55006, | 779 | 0x7c0b0003 /* 0001f02c - 0001f02f [ 4] */, |
| 782 | 0x08e59001, | 780 | 0x7c25000b /* 0001f094 - 0001f09f [ 12] */, |
| 783 | 0x08e5a84a, | 781 | 0x7c2bc001 /* 0001f0af - 0001f0b0 [ 2] */, |
| 784 | 0x08e83800, | 782 | 0x7c300000 /* 0001f0c0 - 0001f0c0 [ 1] */, |
| 785 | 0x08e85000, | 783 | 0x7c340000 /* 0001f0d0 - 0001f0d0 [ 1] */, |
| 786 | 0x08e98814, | 784 | 0x7c3d8009 /* 0001f0f6 - 0001f0ff [ 10] */, |
| 787 | 0x08ea3808, | 785 | 0x7c6b8037 /* 0001f1ae - 0001f1e5 [ 56] */, |
| 788 | 0x08ead005, | 786 | 0x7c80c00c /* 0001f203 - 0001f20f [ 13] */, |
| 789 | 0x08eb3000, | 787 | 0x7c8f0003 /* 0001f23c - 0001f23f [ 4] */, |
| 790 | 0x08eb4800, | 788 | 0x7c924006 /* 0001f249 - 0001f24f [ 7] */, |
| 791 | 0x08ec7803, | 789 | 0x7c94800d /* 0001f252 - 0001f25f [ 14] */, |
| 792 | 0x08eca800, | 790 | 0x7c998099 /* 0001f266 - 0001f2ff [ 154] */, |
| 793 | 0x08ecb800, | 791 | 0x7db60003 /* 0001f6d8 - 0001f6db [ 4] */, |
| 794 | 0x08ecc806, | 792 | 0x7dbb4002 /* 0001f6ed - 0001f6ef [ 3] */, |
| 795 | 0x08ed5135, | 793 | 0x7dbf4002 /* 0001f6fd - 0001f6ff [ 3] */, |
| 796 | 0x08f79801, | 794 | 0x7dddc003 /* 0001f777 - 0001f77a [ 4] */, |
| 797 | 0x08f7c808, | 795 | 0x7df68005 /* 0001f7da - 0001f7df [ 6] */, |
| 798 | 0x08f88800, | 796 | 0x7dfb0003 /* 0001f7ec - 0001f7ef [ 4] */, |
| 799 | 0x08f9b007, | 797 | 0x7dfc400e /* 0001f7f1 - 0001f7ff [ 15] */, |
| 800 | 0x08fa0000, | 798 | 0x7e030003 /* 0001f80c - 0001f80f [ 4] */, |
| 801 | 0x08fa1000, | 799 | 0x7e120007 /* 0001f848 - 0001f84f [ 8] */, |
| 802 | 0x08fad055, | 800 | 0x7e168005 /* 0001f85a - 0001f85f [ 6] */, |
| 803 | 0x08fd880e, | 801 | 0x7e220007 /* 0001f888 - 0001f88f [ 8] */, |
| 804 | 0x08ff900c, | 802 | 0x7e2b8001 /* 0001f8ae - 0001f8af [ 2] */, |
| 805 | 0x091cd065, | 803 | 0x7e2c804d /* 0001f8b2 - 0001f8ff [ 78] */, |
| 806 | 0x09237800, | 804 | 0x7e95000b /* 0001fa54 - 0001fa5f [ 12] */, |
| 807 | 0x0923a80a, | 805 | 0x7e9b8001 /* 0001fa6e - 0001fa6f [ 2] */, |
| 808 | 0x092a27ff, | 806 | 0x7e9f4002 /* 0001fa7d - 0001fa7f [ 3] */, |
| 809 | 0x096a224b, | 807 | 0x7ea24006 /* 0001fa89 - 0001fa8f [ 7] */, |
| 810 | 0x097f980c, | 808 | 0x7eaf8000 /* 0001fabe - 0001fabe [ 1] */, |
| 811 | 0x09a18010, | 809 | 0x7eb18007 /* 0001fac6 - 0001facd [ 8] */, |
| 812 | 0x09a23fff, | 810 | 0x7eb70003 /* 0001fadc - 0001fadf [ 4] */, |
| 813 | 0x09e23fb8, | 811 | 0x7eba4006 /* 0001fae9 - 0001faef [ 7] */, |
| 814 | 0x0a323fff, | 812 | 0x7ebe4006 /* 0001faf9 - 0001faff [ 7] */, |
| 815 | 0x0a723fff, | 813 | 0x7ee4c000 /* 0001fb93 - 0001fb93 [ 1] */, |
| 816 | 0x0ab23fff, | 814 | 0x7ef2c024 /* 0001fbcb - 0001fbef [ 37] */, |
| 817 | 0x0af23fff, | 815 | 0x7efe8405 /* 0001fbfa - 0001ffff [ 1030] */, |
| 818 | 0x0b3239b8, | 816 | 0xa9b8001f /* 0002a6e0 - 0002a6ff [ 32] */, |
| 819 | 0x0b51c806, | 817 | 0xadce8005 /* 0002b73a - 0002b73f [ 6] */, |
| 820 | 0x0b52f800, | 818 | 0xae078001 /* 0002b81e - 0002b81f [ 2] */, |
| 821 | 0x0b535003, | 819 | 0xb3a8800d /* 0002cea2 - 0002ceaf [ 14] */, |
| 822 | 0x0b55f800, | 820 | 0xbaf8400e /* 0002ebe1 - 0002ebef [ 15] */, |
| 823 | 0x0b565005, | 821 | 0xbb9789a1 /* 0002ee5e - 0002f7ff [ 2466] */, |
| 824 | 0x0b577006, | 822 | 0xbe8785e1 /* 0002fa1e - 0002ffff [ 1506] */, |
| 825 | 0x0b57b009, | 823 | 0xc4d2c004 /* 0003134b - 0003134f [ 5] */}; |
| 826 | 0x0b598006, | ||
| 827 | 0x0b5a3009, | ||
| 828 | 0x0b5ad000, | ||
| 829 | 0x0b5b1000, | ||
| 830 | 0x0b5bc004, | ||
| 831 | 0x0b5c82af, | ||
| 832 | 0x0b74d864, | ||
| 833 | 0x0b7a5804, | ||
| 834 | 0x0b7c400a, | ||
| 835 | 0x0b7d003f, | ||
| 836 | 0x0b7f200b, | ||
| 837 | 0x0b7f900d, | ||
| 838 | 0x0c3fc007, | ||
| 839 | 0x0c66b029, | ||
| 840 | 0x0c684fff, | ||
| 841 | 0x0ca84fff, | ||
| 842 | 0x0ce84fff, | ||
| 843 | 0x0d284fff, | ||
| 844 | 0x0d684ae6, | ||
| 845 | 0x0d7fa000, | ||
| 846 | 0x0d7fe000, | ||
| 847 | 0x0d7ff800, | ||
| 848 | 0x0d89180e, | ||
| 849 | 0x0d89981c, | ||
| 850 | 0x0d8a9801, | ||
| 851 | 0x0d8ab00d, | ||
| 852 | 0x0d8b4007, | ||
| 853 | 0x0d97e7ff, | ||
| 854 | 0x0dd7e103, | ||
| 855 | 0x0de35804, | ||
| 856 | 0x0de3e802, | ||
| 857 | 0x0de44806, | ||
| 858 | 0x0de4d001, | ||
| 859 | 0x0de4e801, | ||
| 860 | 0x0de507ff, | ||
| 861 | 0x0e2507ff, | ||
| 862 | 0x0e6502af, | ||
| 863 | 0x0e7e203b, | ||
| 864 | 0x0e87b009, | ||
| 865 | 0x0e893801, | ||
| 866 | 0x0e8b2800, | ||
| 867 | 0x0e8b3802, | ||
| 868 | 0x0e8b7014, | ||
| 869 | 0x0e8c2806, | ||
| 870 | 0x0e8d5003, | ||
| 871 | 0x0e8f5814, | ||
| 872 | 0x0e921002, | ||
| 873 | 0x0e923079, | ||
| 874 | 0x0e96a00b, | ||
| 875 | 0x0e97a00b, | ||
| 876 | 0x0e9ab808, | ||
| 877 | 0x0e9bc886, | ||
| 878 | 0x0ea2a800, | ||
| 879 | 0x0ea4e800, | ||
| 880 | 0x0ea50001, | ||
| 881 | 0x0ea51801, | ||
| 882 | 0x0ea53801, | ||
| 883 | 0x0ea56800, | ||
| 884 | 0x0ea5d000, | ||
| 885 | 0x0ea5e000, | ||
| 886 | 0x0ea62000, | ||
| 887 | 0x0ea83000, | ||
| 888 | 0x0ea85801, | ||
| 889 | 0x0ea8a800, | ||
| 890 | 0x0ea8e800, | ||
| 891 | 0x0ea9d000, | ||
| 892 | 0x0ea9f800, | ||
| 893 | 0x0eaa2800, | ||
| 894 | 0x0eaa3802, | ||
| 895 | 0x0eaa8800, | ||
| 896 | 0x0eb53001, | ||
| 897 | 0x0ebe6001, | ||
| 898 | 0x0ed00036, | ||
| 899 | 0x0ed1d831, | ||
| 900 | 0x0ed3a800, | ||
| 901 | 0x0ed42000, | ||
| 902 | 0x0ed46473, | ||
| 903 | 0x0ef8f805, | ||
| 904 | 0x0ef95904, | ||
| 905 | 0x0f037091, | ||
| 906 | 0x0f096809, | ||
| 907 | 0x0f09f001, | ||
| 908 | 0x0f0a5003, | ||
| 909 | 0x0f0a813f, | ||
| 910 | 0x0f157011, | ||
| 911 | 0x0f176003, | ||
| 912 | 0x0f17d004, | ||
| 913 | 0x0f1801cf, | ||
| 914 | 0x0f276003, | ||
| 915 | 0x0f27d2e5, | ||
| 916 | 0x0f3f3800, | ||
| 917 | 0x0f3f6000, | ||
| 918 | 0x0f3f7800, | ||
| 919 | 0x0f3ff800, | ||
| 920 | 0x0f462801, | ||
| 921 | 0x0f46802f, | ||
| 922 | 0x0f4a2006, | ||
| 923 | 0x0f4a6003, | ||
| 924 | 0x0f4ad003, | ||
| 925 | 0x0f4b0310, | ||
| 926 | 0x0f65a84b, | ||
| 927 | 0x0f69f0c1, | ||
| 928 | 0x0f702000, | ||
| 929 | 0x0f710000, | ||
| 930 | 0x0f711800, | ||
| 931 | 0x0f712801, | ||
| 932 | 0x0f714000, | ||
| 933 | 0x0f719800, | ||
| 934 | 0x0f71c000, | ||
| 935 | 0x0f71d000, | ||
| 936 | 0x0f71e005, | ||
| 937 | 0x0f721803, | ||
| 938 | 0x0f724000, | ||
| 939 | 0x0f725000, | ||
| 940 | 0x0f726000, | ||
| 941 | 0x0f728000, | ||
| 942 | 0x0f729800, | ||
| 943 | 0x0f72a801, | ||
| 944 | 0x0f72c000, | ||
| 945 | 0x0f72d000, | ||
| 946 | 0x0f72e000, | ||
| 947 | 0x0f72f000, | ||
| 948 | 0x0f730000, | ||
| 949 | 0x0f731800, | ||
| 950 | 0x0f732801, | ||
| 951 | 0x0f735800, | ||
| 952 | 0x0f739800, | ||
| 953 | 0x0f73c000, | ||
| 954 | 0x0f73e800, | ||
| 955 | 0x0f73f800, | ||
| 956 | 0x0f745000, | ||
| 957 | 0x0f74e004, | ||
| 958 | 0x0f752000, | ||
| 959 | 0x0f755000, | ||
| 960 | 0x0f75e033, | ||
| 961 | 0x0f77910d, | ||
| 962 | 0x0f816003, | ||
| 963 | 0x0f84a00b, | ||
| 964 | 0x0f857801, | ||
| 965 | 0x0f860000, | ||
| 966 | 0x0f868000, | ||
| 967 | 0x0f87b009, | ||
| 968 | 0x0f8d7037, | ||
| 969 | 0x0f90180c, | ||
| 970 | 0x0f91e003, | ||
| 971 | 0x0f924806, | ||
| 972 | 0x0f92900d, | ||
| 973 | 0x0f933099, | ||
| 974 | 0x0fb6c003, | ||
| 975 | 0x0fb76802, | ||
| 976 | 0x0fb7e802, | ||
| 977 | 0x0fbbb803, | ||
| 978 | 0x0fbed005, | ||
| 979 | 0x0fbf6003, | ||
| 980 | 0x0fbf880e, | ||
| 981 | 0x0fc06003, | ||
| 982 | 0x0fc24007, | ||
| 983 | 0x0fc2d005, | ||
| 984 | 0x0fc44007, | ||
| 985 | 0x0fc57001, | ||
| 986 | 0x0fc5904d, | ||
| 987 | 0x0fd2a00b, | ||
| 988 | 0x0fd37001, | ||
| 989 | 0x0fd3e802, | ||
| 990 | 0x0fd44806, | ||
| 991 | 0x0fd5f000, | ||
| 992 | 0x0fd63007, | ||
| 993 | 0x0fd6e003, | ||
| 994 | 0x0fd74806, | ||
| 995 | 0x0fd7c806, | ||
| 996 | 0x0fdc9800, | ||
| 997 | 0x0fde5824, | ||
| 998 | 0x0fdfd405, | ||
| 999 | 0x1537001f, | ||
| 1000 | 0x15b9d005, | ||
| 1001 | 0x15c0f001, | ||
| 1002 | 0x1675100d, | ||
| 1003 | 0x175f0fff, | ||
| 1004 | 0x179f0c1e, | ||
| 1005 | 0x17d0f5e1, | ||
| 1006 | 0x189a5804}; | ||
| 1007 | 824 | ||
| 825 | /// Returns whether the code unit needs to be escaped. | ||
| 826 | /// | ||
| 1008 | /// At the end of the valid Unicode code points space a lot of code points are | 827 | /// At the end of the valid Unicode code points space a lot of code points are |
| 1009 | /// either reserved or a noncharacter. Adding all these entries to the | 828 | /// either reserved or a noncharacter. Adding all these entries to the |
| 1010 | /// lookup table would add 446 entries to the table (in Unicode 14). | 829 | /// lookup table would greatly increase the size of the table. Instead these |
| 1011 | /// Instead the only the start of the region is stored, every code point in | 830 | /// entries are manually processed. In this large area of reserved code points, |
| 1012 | /// this region needs to be escaped. | 831 | /// there is a small area of extended graphemes that should not be escaped |
| 1013 | inline constexpr uint32_t __unallocated_region_lower_bound = 0x000323b0; | 832 | /// unconditionally. This is also manually coded. See the generation script for |
| 833 | /// more details. | ||
| 1014 | 834 | ||
| 1015 | /// Returns whether the code unit needs to be escaped. | ||
| 1016 | /// | 835 | /// |
| 1017 | /// \pre The code point is a valid Unicode code point. | 836 | /// \\pre The code point is a valid Unicode code point. |
| 1018 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __needs_escape(const char32_t __code_point) noexcept { | 837 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __needs_escape(const char32_t __code_point) noexcept { |
| 1019 | // Since __unallocated_region_lower_bound contains the unshifted range do the | 838 | |
| 1020 | // comparison without shifting. | 839 | // The entries in the gap at the end. |
| 1021 | if (__code_point >= __unallocated_region_lower_bound) | 840 | if(__code_point >= 0x000e0100 && __code_point <= 0x000e01ef) |
| 841 | return false; | ||
| 842 | |||
| 843 | // The entries at the end. | ||
| 844 | if (__code_point >= 0x000323b0) | ||
| 1022 | return true; | 845 | return true; |
| 1023 | 846 | ||
| 1024 | ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries; | 847 | ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 14) | 0x3fffu) - __entries; |
| 1025 | if (__i == 0) | 848 | if (__i == 0) |
| 1026 | return false; | 849 | return false; |
| 1027 | 850 | ||
| 1028 | --__i; | 851 | --__i; |
| 1029 | uint32_t __upper_bound = (__entries[__i] >> 11) + (__entries[__i] & 0x7ffu); | 852 | uint32_t __upper_bound = (__entries[__i] >> 14) + (__entries[__i] & 0x3fffu); |
| 1030 | return __code_point <= __upper_bound; | 853 | return __code_point <= __upper_bound; |
| 1031 | } | 854 | } |
| 1032 | 855 |
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+1-1| ... | @@ -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 | inline constexpr uint32_t __entries[1496] = { | 128 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 129 | 0x00000091, | 129 | 0x00000091, |
| 130 | 0x00005005, | 130 | 0x00005005, |
| 131 | 0x00005811, | 131 | 0x00005811, |
lib/libcxx/include/__format/format_arg.h+108-4| ... | @@ -14,11 +14,12 @@ | ... | @@ -14,11 +14,12 @@ |
| 14 | #include <__concepts/arithmetic.h> | 14 | #include <__concepts/arithmetic.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__format/concepts.h> | 16 | #include <__format/concepts.h> |
| 17 | #include <__format/format_fwd.h> | ||
| 18 | #include <__format/format_parse_context.h> | 17 | #include <__format/format_parse_context.h> |
| 19 | #include <__functional/invoke.h> | 18 | #include <__functional/invoke.h> |
| 19 | #include <__fwd/format.h> | ||
| 20 | #include <__memory/addressof.h> | 20 | #include <__memory/addressof.h> |
| 21 | #include <__type_traits/conditional.h> | 21 | #include <__type_traits/conditional.h> |
| 22 | #include <__type_traits/remove_const.h> | ||
| 22 | #include <__utility/forward.h> | 23 | #include <__utility/forward.h> |
| 23 | #include <__utility/move.h> | 24 | #include <__utility/move.h> |
| 24 | #include <__utility/unreachable.h> | 25 | #include <__utility/unreachable.h> |
| ... | @@ -96,7 +97,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t __get_packed_type(uint64_t __types, size | ... | @@ -96,7 +97,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t __get_packed_type(uint64_t __types, size |
| 96 | 97 | ||
| 97 | } // namespace __format | 98 | } // namespace __format |
| 98 | 99 | ||
| 99 | // This function is not user obervable, so it can directly use the non-standard | 100 | // This function is not user observable, so it can directly use the non-standard |
| 100 | // types of the "variant". See __arg_t for more details. | 101 | // types of the "variant". See __arg_t for more details. |
| 101 | template <class _Visitor, class _Context> | 102 | template <class _Visitor, class _Context> |
| 102 | _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | 103 | _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { |
| ... | @@ -147,6 +148,59 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ | ... | @@ -147,6 +148,59 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ |
| 147 | __libcpp_unreachable(); | 148 | __libcpp_unreachable(); |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 151 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | ||
| 152 | |||
| 153 | template <class _Rp, class _Visitor, class _Context> | ||
| 154 | _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | ||
| 155 | switch (__arg.__type_) { | ||
| 156 | case __format::__arg_t::__none: | ||
| 157 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__monostate_); | ||
| 158 | case __format::__arg_t::__boolean: | ||
| 159 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__boolean_); | ||
| 160 | case __format::__arg_t::__char_type: | ||
| 161 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__char_type_); | ||
| 162 | case __format::__arg_t::__int: | ||
| 163 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__int_); | ||
| 164 | case __format::__arg_t::__long_long: | ||
| 165 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_); | ||
| 166 | case __format::__arg_t::__i128: | ||
| 167 | # ifndef _LIBCPP_HAS_NO_INT128 | ||
| 168 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__i128_); | ||
| 169 | # else | ||
| 170 | __libcpp_unreachable(); | ||
| 171 | # endif | ||
| 172 | case __format::__arg_t::__unsigned: | ||
| 173 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_); | ||
| 174 | case __format::__arg_t::__unsigned_long_long: | ||
| 175 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); | ||
| 176 | case __format::__arg_t::__u128: | ||
| 177 | # ifndef _LIBCPP_HAS_NO_INT128 | ||
| 178 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__u128_); | ||
| 179 | # else | ||
| 180 | __libcpp_unreachable(); | ||
| 181 | # endif | ||
| 182 | case __format::__arg_t::__float: | ||
| 183 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__float_); | ||
| 184 | case __format::__arg_t::__double: | ||
| 185 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__double_); | ||
| 186 | case __format::__arg_t::__long_double: | ||
| 187 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_double_); | ||
| 188 | case __format::__arg_t::__const_char_type_ptr: | ||
| 189 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_); | ||
| 190 | case __format::__arg_t::__string_view: | ||
| 191 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__string_view_); | ||
| 192 | case __format::__arg_t::__ptr: | ||
| 193 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__ptr_); | ||
| 194 | case __format::__arg_t::__handle: | ||
| 195 | return std::invoke_r<_Rp>( | ||
| 196 | std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_}); | ||
| 197 | } | ||
| 198 | |||
| 199 | __libcpp_unreachable(); | ||
| 200 | } | ||
| 201 | |||
| 202 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | ||
| 203 | |||
| 150 | /// Contains the values used in basic_format_arg. | 204 | /// Contains the values used in basic_format_arg. |
| 151 | /// | 205 | /// |
| 152 | /// This is a separate type so it's possible to store the values and types in | 206 | /// This is a separate type so it's possible to store the values and types in |
| ... | @@ -230,6 +284,52 @@ public: | ... | @@ -230,6 +284,52 @@ public: |
| 230 | 284 | ||
| 231 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } | 285 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } |
| 232 | 286 | ||
| 287 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | ||
| 288 | |||
| 289 | // This function is user facing, so it must wrap the non-standard types of | ||
| 290 | // the "variant" in a handle to stay conforming. See __arg_t for more details. | ||
| 291 | template <class _Visitor> | ||
| 292 | _LIBCPP_HIDE_FROM_ABI decltype(auto) visit(this basic_format_arg __arg, _Visitor&& __vis) { | ||
| 293 | switch (__arg.__type_) { | ||
| 294 | # ifndef _LIBCPP_HAS_NO_INT128 | ||
| 295 | case __format::__arg_t::__i128: { | ||
| 296 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; | ||
| 297 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); | ||
| 298 | } | ||
| 299 | |||
| 300 | case __format::__arg_t::__u128: { | ||
| 301 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; | ||
| 302 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); | ||
| 303 | } | ||
| 304 | # endif | ||
| 305 | default: | ||
| 306 | return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); | ||
| 307 | } | ||
| 308 | } | ||
| 309 | |||
| 310 | // This function is user facing, so it must wrap the non-standard types of | ||
| 311 | // the "variant" in a handle to stay conforming. See __arg_t for more details. | ||
| 312 | template <class _Rp, class _Visitor> | ||
| 313 | _LIBCPP_HIDE_FROM_ABI _Rp visit(this basic_format_arg __arg, _Visitor&& __vis) { | ||
| 314 | switch (__arg.__type_) { | ||
| 315 | # ifndef _LIBCPP_HAS_NO_INT128 | ||
| 316 | case __format::__arg_t::__i128: { | ||
| 317 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; | ||
| 318 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); | ||
| 319 | } | ||
| 320 | |||
| 321 | case __format::__arg_t::__u128: { | ||
| 322 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; | ||
| 323 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); | ||
| 324 | } | ||
| 325 | # endif | ||
| 326 | default: | ||
| 327 | return std::__visit_format_arg<_Rp>(std::forward<_Visitor>(__vis), __arg); | ||
| 328 | } | ||
| 329 | } | ||
| 330 | |||
| 331 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | ||
| 332 | |||
| 233 | private: | 333 | private: |
| 234 | using char_type = typename _Context::char_type; | 334 | using char_type = typename _Context::char_type; |
| 235 | 335 | ||
| ... | @@ -270,7 +370,11 @@ private: | ... | @@ -270,7 +370,11 @@ private: |
| 270 | // This function is user facing, so it must wrap the non-standard types of | 370 | // This function is user facing, so it must wrap the non-standard types of |
| 271 | // the "variant" in a handle to stay conforming. See __arg_t for more details. | 371 | // the "variant" in a handle to stay conforming. See __arg_t for more details. |
| 272 | template <class _Visitor, class _Context> | 372 | template <class _Visitor, class _Context> |
| 273 | _LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | 373 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) |
| 374 | _LIBCPP_DEPRECATED_IN_CXX26 | ||
| 375 | # endif | ||
| 376 | _LIBCPP_HIDE_FROM_ABI decltype(auto) | ||
| 377 | visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | ||
| 274 | switch (__arg.__type_) { | 378 | switch (__arg.__type_) { |
| 275 | # ifndef _LIBCPP_HAS_NO_INT128 | 379 | # ifndef _LIBCPP_HAS_NO_INT128 |
| 276 | case __format::__arg_t::__i128: { | 380 | case __format::__arg_t::__i128: { |
| ... | @@ -282,7 +386,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_fo | ... | @@ -282,7 +386,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_fo |
| 282 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; | 386 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; |
| 283 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); | 387 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); |
| 284 | } | 388 | } |
| 285 | # endif | 389 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) |
| 286 | default: | 390 | default: |
| 287 | return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); | 391 | return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); |
| 288 | } | 392 | } |
lib/libcxx/include/__format/format_arg_store.h+1-2| ... | @@ -151,7 +151,7 @@ consteval __arg_t __determine_arg_t() { | ... | @@ -151,7 +151,7 @@ consteval __arg_t __determine_arg_t() { |
| 151 | // The overload for not formattable types allows triggering the static | 151 | // The overload for not formattable types allows triggering the static |
| 152 | // assertion below. | 152 | // assertion below. |
| 153 | template <class _Context, class _Tp> | 153 | template <class _Context, class _Tp> |
| 154 | requires(!__formattable<_Tp, typename _Context::char_type>) | 154 | requires(!__formattable_with<_Tp, _Context>) |
| 155 | consteval __arg_t __determine_arg_t() { | 155 | consteval __arg_t __determine_arg_t() { |
| 156 | return __arg_t::__none; | 156 | return __arg_t::__none; |
| 157 | } | 157 | } |
| ... | @@ -165,7 +165,6 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu | ... | @@ -165,7 +165,6 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu |
| 165 | using _Dp = remove_const_t<_Tp>; | 165 | using _Dp = remove_const_t<_Tp>; |
| 166 | constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>(); | 166 | constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>(); |
| 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); | 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); |
| 168 | |||
| 169 | static_assert(__formattable_with<_Tp, _Context>); | 168 | static_assert(__formattable_with<_Tp, _Context>); |
| 170 | 169 | ||
| 171 | // Not all types can be used to directly initialize the | 170 | // Not all types can be used to directly initialize the |
lib/libcxx/include/__format/format_args.h+1-4| ... | @@ -10,11 +10,10 @@ | ... | @@ -10,11 +10,10 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMAT_ARGS_H | 10 | #ifndef _LIBCPP___FORMAT_FORMAT_ARGS_H |
| 11 | #define _LIBCPP___FORMAT_FORMAT_ARGS_H | 11 | #define _LIBCPP___FORMAT_FORMAT_ARGS_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__format/format_arg.h> | 14 | #include <__format/format_arg.h> |
| 16 | #include <__format/format_arg_store.h> | 15 | #include <__format/format_arg_store.h> |
| 17 | #include <__format/format_fwd.h> | 16 | #include <__fwd/format.h> |
| 18 | #include <cstddef> | 17 | #include <cstddef> |
| 19 | #include <cstdint> | 18 | #include <cstdint> |
| 20 | 19 | ||
| ... | @@ -29,8 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,8 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | template <class _Context> | 28 | template <class _Context> |
| 30 | class _LIBCPP_TEMPLATE_VIS basic_format_args { | 29 | class _LIBCPP_TEMPLATE_VIS basic_format_args { |
| 31 | public: | 30 | public: |
| 32 | basic_format_args() noexcept = default; | ||
| 33 | |||
| 34 | template <class... _Args> | 31 | template <class... _Args> |
| 35 | _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 |
| 36 | : __size_(sizeof...(_Args)) { | 33 | : __size_(sizeof...(_Args)) { |
lib/libcxx/include/__format/format_context.h+24-17| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMAT_CONTEXT_H | 10 | #ifndef _LIBCPP___FORMAT_FORMAT_CONTEXT_H |
| 11 | #define _LIBCPP___FORMAT_FORMAT_CONTEXT_H | 11 | #define _LIBCPP___FORMAT_FORMAT_CONTEXT_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__concepts/same_as.h> | 13 | #include <__concepts/same_as.h> |
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__format/buffer.h> | 15 | #include <__format/buffer.h> |
| ... | @@ -18,7 +17,7 @@ | ... | @@ -18,7 +17,7 @@ |
| 18 | #include <__format/format_arg_store.h> | 17 | #include <__format/format_arg_store.h> |
| 19 | #include <__format/format_args.h> | 18 | #include <__format/format_args.h> |
| 20 | #include <__format/format_error.h> | 19 | #include <__format/format_error.h> |
| 21 | #include <__format/format_fwd.h> | 20 | #include <__fwd/format.h> |
| 22 | #include <__iterator/back_insert_iterator.h> | 21 | #include <__iterator/back_insert_iterator.h> |
| 23 | #include <__iterator/concepts.h> | 22 | #include <__iterator/concepts.h> |
| 24 | #include <__memory/addressof.h> | 23 | #include <__memory/addressof.h> |
| ... | @@ -27,7 +26,7 @@ | ... | @@ -27,7 +26,7 @@ |
| 27 | #include <cstddef> | 26 | #include <cstddef> |
| 28 | 27 | ||
| 29 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | 28 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 30 | # include <locale> | 29 | # include <__locale> |
| 31 | # include <optional> | 30 | # include <optional> |
| 32 | #endif | 31 | #endif |
| 33 | 32 | ||
| ... | @@ -132,6 +131,9 @@ private: | ... | @@ -132,6 +131,9 @@ private: |
| 132 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, basic_format_args<basic_format_context> __args) | 131 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, basic_format_args<basic_format_context> __args) |
| 133 | : __out_it_(std::move(__out_it)), __args_(__args) {} | 132 | : __out_it_(std::move(__out_it)), __args_(__args) {} |
| 134 | # endif | 133 | # endif |
| 134 | |||
| 135 | basic_format_context(const basic_format_context&) = delete; | ||
| 136 | basic_format_context& operator=(const basic_format_context&) = delete; | ||
| 135 | }; | 137 | }; |
| 136 | 138 | ||
| 137 | // A specialization for __retarget_buffer | 139 | // A specialization for __retarget_buffer |
| ... | @@ -166,20 +168,25 @@ public: | ... | @@ -166,20 +168,25 @@ public: |
| 166 | # endif | 168 | # endif |
| 167 | __ctx_(std::addressof(__ctx)), | 169 | __ctx_(std::addressof(__ctx)), |
| 168 | __arg_([](void* __c, size_t __id) { | 170 | __arg_([](void* __c, size_t __id) { |
| 169 | return std::visit_format_arg( | 171 | auto __visitor = [&](auto __arg) -> basic_format_arg<basic_format_context> { |
| 170 | [&](auto __arg) -> basic_format_arg<basic_format_context> { | 172 | if constexpr (same_as<decltype(__arg), monostate>) |
| 171 | if constexpr (same_as<decltype(__arg), monostate>) | 173 | return {}; |
| 172 | return {}; | 174 | else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>) |
| 173 | else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>) | 175 | // At the moment it's not possible for formatting to use a re-targeted handle. |
| 174 | // At the moment it's not possible for formatting to use a re-targeted handle. | 176 | // TODO FMT add this when support is needed. |
| 175 | // TODO FMT add this when support is needed. | 177 | std::__throw_format_error("Re-targeting handle not supported"); |
| 176 | std::__throw_format_error("Re-targeting handle not supported"); | 178 | else |
| 177 | else | 179 | return basic_format_arg<basic_format_context>{ |
| 178 | return basic_format_arg<basic_format_context>{ | 180 | __format::__determine_arg_t<basic_format_context, decltype(__arg)>(), |
| 179 | __format::__determine_arg_t<basic_format_context, decltype(__arg)>(), | 181 | __basic_format_arg_value<basic_format_context>(__arg)}; |
| 180 | __basic_format_arg_value<basic_format_context>(__arg)}; | 182 | }; |
| 181 | }, | 183 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) |
| 182 | static_cast<_Context*>(__c)->arg(__id)); | 184 | return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor)); |
| 185 | # else | ||
| 186 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 187 | return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id)); | ||
| 188 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 189 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | ||
| 183 | }) { | 190 | }) { |
| 184 | } | 191 | } |
| 185 | 192 |
lib/libcxx/include/__format/format_functions.h+17-19| ... | @@ -41,7 +41,7 @@ | ... | @@ -41,7 +41,7 @@ |
| 41 | #include <string_view> | 41 | #include <string_view> |
| 42 | 42 | ||
| 43 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | 43 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 44 | # include <locale> | 44 | # include <__locale> |
| 45 | #endif | 45 | #endif |
| 46 | 46 | ||
| 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -66,15 +66,14 @@ using wformat_args = basic_format_args<wformat_context>; | ... | @@ -66,15 +66,14 @@ using wformat_args = basic_format_args<wformat_context>; |
| 66 | # endif | 66 | # endif |
| 67 | 67 | ||
| 68 | template <class _Context = format_context, class... _Args> | 68 | template <class _Context = format_context, class... _Args> |
| 69 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&... __args) { | 69 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&... __args) { |
| 70 | return _VSTD::__format_arg_store<_Context, _Args...>(__args...); | 70 | return std::__format_arg_store<_Context, _Args...>(__args...); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 73 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 74 | template <class... _Args> | 74 | template <class... _Args> |
| 75 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> | 75 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&... __args) { |
| 76 | make_wformat_args(_Args&... __args) { | 76 | return std::__format_arg_store<wformat_context, _Args...>(__args...); |
| 77 | return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...); | ||
| 78 | } | 77 | } |
| 79 | # endif | 78 | # endif |
| 80 | 79 | ||
| ... | @@ -452,8 +451,7 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { | ... | @@ -452,8 +451,7 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 452 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup | 451 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 453 | // fires too eagerly, see http://llvm.org/PR61563. | 452 | // fires too eagerly, see http://llvm.org/PR61563. |
| 454 | template <class = void> | 453 | template <class = void> |
| 455 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string | 454 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) { |
| 456 | vformat(string_view __fmt, format_args __args) { | ||
| 457 | string __res; | 455 | string __res; |
| 458 | std::vformat_to(std::back_inserter(__res), __fmt, __args); | 456 | std::vformat_to(std::back_inserter(__res), __fmt, __args); |
| 459 | return __res; | 457 | return __res; |
| ... | @@ -463,7 +461,7 @@ vformat(string_view __fmt, format_args __args) { | ... | @@ -463,7 +461,7 @@ vformat(string_view __fmt, format_args __args) { |
| 463 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup | 461 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 464 | // fires too eagerly, see http://llvm.org/PR61563. | 462 | // fires too eagerly, see http://llvm.org/PR61563. |
| 465 | template <class = void> | 463 | template <class = void> |
| 466 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring | 464 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring |
| 467 | vformat(wstring_view __fmt, wformat_args __args) { | 465 | vformat(wstring_view __fmt, wformat_args __args) { |
| 468 | wstring __res; | 466 | wstring __res; |
| 469 | std::vformat_to(std::back_inserter(__res), __fmt, __args); | 467 | std::vformat_to(std::back_inserter(__res), __fmt, __args); |
| ... | @@ -472,14 +470,14 @@ vformat(wstring_view __fmt, wformat_args __args) { | ... | @@ -472,14 +470,14 @@ vformat(wstring_view __fmt, wformat_args __args) { |
| 472 | # endif | 470 | # endif |
| 473 | 471 | ||
| 474 | template <class... _Args> | 472 | template <class... _Args> |
| 475 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string | 473 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string |
| 476 | format(format_string<_Args...> __fmt, _Args&&... __args) { | 474 | format(format_string<_Args...> __fmt, _Args&&... __args) { |
| 477 | return std::vformat(__fmt.get(), std::make_format_args(__args...)); | 475 | return std::vformat(__fmt.get(), std::make_format_args(__args...)); |
| 478 | } | 476 | } |
| 479 | 477 | ||
| 480 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 478 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 481 | template <class... _Args> | 479 | template <class... _Args> |
| 482 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring | 480 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring |
| 483 | format(wformat_string<_Args...> __fmt, _Args&&... __args) { | 481 | format(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 484 | return std::vformat(__fmt.get(), std::make_wformat_args(__args...)); | 482 | return std::vformat(__fmt.get(), std::make_wformat_args(__args...)); |
| 485 | } | 483 | } |
| ... | @@ -520,14 +518,14 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, | ... | @@ -520,14 +518,14 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, |
| 520 | } | 518 | } |
| 521 | 519 | ||
| 522 | template <class... _Args> | 520 | template <class... _Args> |
| 523 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t | 521 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t |
| 524 | formatted_size(format_string<_Args...> __fmt, _Args&&... __args) { | 522 | formatted_size(format_string<_Args...> __fmt, _Args&&... __args) { |
| 525 | return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_format_args(__args...)}); | 523 | return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_format_args(__args...)}); |
| 526 | } | 524 | } |
| 527 | 525 | ||
| 528 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 526 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 529 | template <class... _Args> | 527 | template <class... _Args> |
| 530 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t | 528 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t |
| 531 | formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) { | 529 | formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 532 | return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_wformat_args(__args...)}); | 530 | return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_wformat_args(__args...)}); |
| 533 | } | 531 | } |
| ... | @@ -585,7 +583,7 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&& | ... | @@ -585,7 +583,7 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&& |
| 585 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup | 583 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 586 | // fires too eagerly, see http://llvm.org/PR61563. | 584 | // fires too eagerly, see http://llvm.org/PR61563. |
| 587 | template <class = void> | 585 | template <class = void> |
| 588 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string | 586 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string |
| 589 | vformat(locale __loc, string_view __fmt, format_args __args) { | 587 | vformat(locale __loc, string_view __fmt, format_args __args) { |
| 590 | string __res; | 588 | string __res; |
| 591 | std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args); | 589 | std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args); |
| ... | @@ -596,7 +594,7 @@ vformat(locale __loc, string_view __fmt, format_args __args) { | ... | @@ -596,7 +594,7 @@ vformat(locale __loc, string_view __fmt, format_args __args) { |
| 596 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup | 594 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 597 | // fires too eagerly, see http://llvm.org/PR61563. | 595 | // fires too eagerly, see http://llvm.org/PR61563. |
| 598 | template <class = void> | 596 | template <class = void> |
| 599 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring | 597 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring |
| 600 | vformat(locale __loc, wstring_view __fmt, wformat_args __args) { | 598 | vformat(locale __loc, wstring_view __fmt, wformat_args __args) { |
| 601 | wstring __res; | 599 | wstring __res; |
| 602 | std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args); | 600 | std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args); |
| ... | @@ -605,14 +603,14 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) { | ... | @@ -605,14 +603,14 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) { |
| 605 | # endif | 603 | # endif |
| 606 | 604 | ||
| 607 | template <class... _Args> | 605 | template <class... _Args> |
| 608 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string | 606 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string |
| 609 | format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { | 607 | format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { |
| 610 | return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...)); | 608 | return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...)); |
| 611 | } | 609 | } |
| 612 | 610 | ||
| 613 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 611 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 614 | template <class... _Args> | 612 | template <class... _Args> |
| 615 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring | 613 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring |
| 616 | format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { | 614 | format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 617 | return std::vformat(std::move(__loc), __fmt.get(), std::make_wformat_args(__args...)); | 615 | return std::vformat(std::move(__loc), __fmt.get(), std::make_wformat_args(__args...)); |
| 618 | } | 616 | } |
| ... | @@ -658,14 +656,14 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_ | ... | @@ -658,14 +656,14 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_ |
| 658 | } | 656 | } |
| 659 | 657 | ||
| 660 | template <class... _Args> | 658 | template <class... _Args> |
| 661 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t | 659 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t |
| 662 | formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { | 660 | formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { |
| 663 | return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_format_args(__args...)}); | 661 | return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_format_args(__args...)}); |
| 664 | } | 662 | } |
| 665 | 663 | ||
| 666 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 664 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 667 | template <class... _Args> | 665 | template <class... _Args> |
| 668 | _LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t | 666 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t |
| 669 | formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { | 667 | formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 670 | return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_wformat_args(__args...)}); | 668 | return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_wformat_args(__args...)}); |
| 671 | } | 669 | } |
lib/libcxx/include/__format/format_fwd.h deleted-39| ... | @@ -1,39 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FORMAT_FORMAT_FWD_H | ||
| 11 | #define _LIBCPP___FORMAT_FORMAT_FWD_H | ||
| 12 | |||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | #if _LIBCPP_STD_VER >= 20 | ||
| 24 | |||
| 25 | template <class _Context> | ||
| 26 | class _LIBCPP_TEMPLATE_VIS basic_format_arg; | ||
| 27 | |||
| 28 | template <class _OutIt, class _CharT> | ||
| 29 | requires output_iterator<_OutIt, const _CharT&> | ||
| 30 | class _LIBCPP_TEMPLATE_VIS basic_format_context; | ||
| 31 | |||
| 32 | template <class _Tp, class _CharT = char> | ||
| 33 | struct _LIBCPP_TEMPLATE_VIS formatter; | ||
| 34 | |||
| 35 | #endif //_LIBCPP_STD_VER >= 20 | ||
| 36 | |||
| 37 | _LIBCPP_END_NAMESPACE_STD | ||
| 38 | |||
| 39 | #endif // _LIBCPP___FORMAT_FORMAT_FWD_H | ||
lib/libcxx/include/__format/formatter.h+1-2| ... | @@ -10,9 +10,8 @@ | ... | @@ -10,9 +10,8 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_H | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_H |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_H | 11 | #define _LIBCPP___FORMAT_FORMATTER_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__format/format_fwd.h> | 14 | #include <__fwd/format.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 |
lib/libcxx/include/__format/formatter_bool.h+1-2| ... | @@ -12,7 +12,6 @@ | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | ||
| 13 | #include <__algorithm/copy.h> | 13 | #include <__algorithm/copy.h> |
| 14 | #include <__assert> | 14 | #include <__assert> |
| 15 | #include <__availability> | ||
| 16 | #include <__config> | 15 | #include <__config> |
| 17 | #include <__format/concepts.h> | 16 | #include <__format/concepts.h> |
| 18 | #include <__format/format_parse_context.h> | 17 | #include <__format/format_parse_context.h> |
| ... | @@ -22,7 +21,7 @@ | ... | @@ -22,7 +21,7 @@ |
| 22 | #include <__utility/unreachable.h> | 21 | #include <__utility/unreachable.h> |
| 23 | 22 | ||
| 24 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | 23 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 25 | # include <locale> | 24 | # include <__locale> |
| 26 | #endif | 25 | #endif |
| 27 | 26 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__format/formatter_char.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_CHAR_H | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_CHAR_H |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_CHAR_H | 11 | #define _LIBCPP___FORMAT_FORMATTER_CHAR_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__concepts/same_as.h> | 13 | #include <__concepts/same_as.h> |
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__format/concepts.h> | 15 | #include <__format/concepts.h> |
lib/libcxx/include/__format/formatter_floating_point.h+2-1| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 17 | #include <__algorithm/rotate.h> | 17 | #include <__algorithm/rotate.h> |
| 18 | #include <__algorithm/transform.h> | 18 | #include <__algorithm/transform.h> |
| 19 | #include <__assert> | ||
| 19 | #include <__charconv/chars_format.h> | 20 | #include <__charconv/chars_format.h> |
| 20 | #include <__charconv/to_chars_floating_point.h> | 21 | #include <__charconv/to_chars_floating_point.h> |
| 21 | #include <__charconv/to_chars_result.h> | 22 | #include <__charconv/to_chars_result.h> |
| ... | @@ -38,7 +39,7 @@ | ... | @@ -38,7 +39,7 @@ |
| 38 | #include <cstddef> | 39 | #include <cstddef> |
| 39 | 40 | ||
| 40 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | 41 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 41 | # include <locale> | 42 | # include <__locale> |
| 42 | #endif | 43 | #endif |
| 43 | 44 | ||
| 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 45 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__format/formatter_integer.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_INTEGER_H | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_INTEGER_H |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_INTEGER_H | 11 | #define _LIBCPP___FORMAT_FORMATTER_INTEGER_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__concepts/arithmetic.h> | 13 | #include <__concepts/arithmetic.h> |
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__format/concepts.h> | 15 | #include <__format/concepts.h> |
lib/libcxx/include/__format/formatter_integral.h+1-1| ... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
| 32 | #include <string_view> | 32 | #include <string_view> |
| 33 | 33 | ||
| 34 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | 34 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 35 | # include <locale> | 35 | # include <__locale> |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__format/formatter_output.h+11-9| ... | @@ -100,8 +100,8 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align | ... | @@ -100,8 +100,8 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align |
| 100 | /// | 100 | /// |
| 101 | /// This uses a "mass output function" of __format::__output_buffer when possible. | 101 | /// This uses a "mass output function" of __format::__output_buffer when possible. |
| 102 | template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT> | 102 | template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT> |
| 103 | _LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it) | 103 | _LIBCPP_HIDE_FROM_ABI auto |
| 104 | -> decltype(__out_it) { | 104 | __copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it) -> decltype(__out_it) { |
| 105 | if constexpr (std::same_as<decltype(__out_it), std::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) { | 105 | if constexpr (std::same_as<decltype(__out_it), std::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) { |
| 106 | __out_it.__get_container()->__copy(__str); | 106 | __out_it.__get_container()->__copy(__str); |
| 107 | return __out_it; | 107 | return __out_it; |
| ... | @@ -116,16 +116,16 @@ _LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterat | ... | @@ -116,16 +116,16 @@ _LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterat |
| 116 | template <contiguous_iterator _Iterator, | 116 | template <contiguous_iterator _Iterator, |
| 117 | __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type, | 117 | __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type, |
| 118 | __fmt_char_type _OutCharT = _CharT> | 118 | __fmt_char_type _OutCharT = _CharT> |
| 119 | _LIBCPP_HIDE_FROM_ABI auto __copy(_Iterator __first, _Iterator __last, output_iterator<const _OutCharT&> auto __out_it) | 119 | _LIBCPP_HIDE_FROM_ABI auto |
| 120 | -> decltype(__out_it) { | 120 | __copy(_Iterator __first, _Iterator __last, output_iterator<const _OutCharT&> auto __out_it) -> decltype(__out_it) { |
| 121 | return __formatter::__copy(basic_string_view{__first, __last}, std::move(__out_it)); | 121 | return __formatter::__copy(basic_string_view{__first, __last}, std::move(__out_it)); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | template <contiguous_iterator _Iterator, | 124 | template <contiguous_iterator _Iterator, |
| 125 | __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type, | 125 | __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type, |
| 126 | __fmt_char_type _OutCharT = _CharT> | 126 | __fmt_char_type _OutCharT = _CharT> |
| 127 | _LIBCPP_HIDE_FROM_ABI auto __copy(_Iterator __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it) | 127 | _LIBCPP_HIDE_FROM_ABI auto |
| 128 | -> decltype(__out_it) { | 128 | __copy(_Iterator __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it) -> decltype(__out_it) { |
| 129 | return __formatter::__copy(basic_string_view{std::to_address(__first), __n}, std::move(__out_it)); | 129 | return __formatter::__copy(basic_string_view{std::to_address(__first), __n}, std::move(__out_it)); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| ... | @@ -136,9 +136,11 @@ template <contiguous_iterator _Iterator, | ... | @@ -136,9 +136,11 @@ template <contiguous_iterator _Iterator, |
| 136 | __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type, | 136 | __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type, |
| 137 | __fmt_char_type _OutCharT = _CharT, | 137 | __fmt_char_type _OutCharT = _CharT, |
| 138 | class _UnaryOperation> | 138 | class _UnaryOperation> |
| 139 | _LIBCPP_HIDE_FROM_ABI auto __transform( | 139 | _LIBCPP_HIDE_FROM_ABI auto |
| 140 | _Iterator __first, _Iterator __last, output_iterator<const _OutCharT&> auto __out_it, _UnaryOperation __operation) | 140 | __transform(_Iterator __first, |
| 141 | -> decltype(__out_it) { | 141 | _Iterator __last, |
| 142 | output_iterator<const _OutCharT&> auto __out_it, | ||
| 143 | _UnaryOperation __operation) -> decltype(__out_it) { | ||
| 142 | if constexpr (std::same_as<decltype(__out_it), std::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) { | 144 | if constexpr (std::same_as<decltype(__out_it), std::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) { |
| 143 | __out_it.__get_container()->__transform(__first, __last, std::move(__operation)); | 145 | __out_it.__get_container()->__transform(__first, __last, std::move(__operation)); |
| 144 | return __out_it; | 146 | return __out_it; |
lib/libcxx/include/__format/formatter_pointer.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_POINTER_H | 11 | #define _LIBCPP___FORMAT_FORMATTER_POINTER_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__format/concepts.h> | 14 | #include <__format/concepts.h> |
| 16 | #include <__format/format_parse_context.h> | 15 | #include <__format/format_parse_context.h> |
lib/libcxx/include/__format/formatter_string.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 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 <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__format/concepts.h> | 14 | #include <__format/concepts.h> |
| 16 | #include <__format/format_parse_context.h> | 15 | #include <__format/format_parse_context.h> |
lib/libcxx/include/__format/indic_conjunct_break_table.h created+350| ... | @@ -0,0 +1,350 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // WARNING, this entire header is generated by | ||
| 11 | // utils/generate_indic_conjunct_break_table.py | ||
| 12 | // DO NOT MODIFY! | ||
| 13 | |||
| 14 | // UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE | ||
| 15 | // | ||
| 16 | // See Terms of Use <https://www.unicode.org/copyright.html> | ||
| 17 | // for definitions of Unicode Inc.'s Data Files and Software. | ||
| 18 | // | ||
| 19 | // NOTICE TO USER: Carefully read the following legal agreement. | ||
| 20 | // BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S | ||
| 21 | // DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), | ||
| 22 | // YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE | ||
| 23 | // TERMS AND CONDITIONS OF THIS AGREEMENT. | ||
| 24 | // IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE | ||
| 25 | // THE DATA FILES OR SOFTWARE. | ||
| 26 | // | ||
| 27 | // COPYRIGHT AND PERMISSION NOTICE | ||
| 28 | // | ||
| 29 | // Copyright (c) 1991-2022 Unicode, Inc. All rights reserved. | ||
| 30 | // Distributed under the Terms of Use in https://www.unicode.org/copyright.html. | ||
| 31 | // | ||
| 32 | // Permission is hereby granted, free of charge, to any person obtaining | ||
| 33 | // a copy of the Unicode data files and any associated documentation | ||
| 34 | // (the "Data Files") or Unicode software and any associated documentation | ||
| 35 | // (the "Software") to deal in the Data Files or Software | ||
| 36 | // without restriction, including without limitation the rights to use, | ||
| 37 | // copy, modify, merge, publish, distribute, and/or sell copies of | ||
| 38 | // the Data Files or Software, and to permit persons to whom the Data Files | ||
| 39 | // or Software are furnished to do so, provided that either | ||
| 40 | // (a) this copyright and permission notice appear with all copies | ||
| 41 | // of the Data Files or Software, or | ||
| 42 | // (b) this copyright and permission notice appear in associated | ||
| 43 | // Documentation. | ||
| 44 | // | ||
| 45 | // THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
| 46 | // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
| 47 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 48 | // NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
| 49 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS | ||
| 50 | // NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL | ||
| 51 | // DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | ||
| 52 | // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
| 53 | // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 54 | // PERFORMANCE OF THE DATA FILES OR SOFTWARE. | ||
| 55 | // | ||
| 56 | // Except as contained in this notice, the name of a copyright holder | ||
| 57 | // shall not be used in advertising or otherwise to promote the sale, | ||
| 58 | // use or other dealings in these Data Files or Software without prior | ||
| 59 | // written authorization of the copyright holder. | ||
| 60 | |||
| 61 | #ifndef _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H | ||
| 62 | #define _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H | ||
| 63 | |||
| 64 | #include <__algorithm/ranges_upper_bound.h> | ||
| 65 | #include <__config> | ||
| 66 | #include <__iterator/access.h> | ||
| 67 | #include <cstddef> | ||
| 68 | #include <cstdint> | ||
| 69 | |||
| 70 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 71 | # pragma GCC system_header | ||
| 72 | #endif | ||
| 73 | |||
| 74 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 75 | |||
| 76 | #if _LIBCPP_STD_VER >= 20 | ||
| 77 | |||
| 78 | namespace __indic_conjunct_break { | ||
| 79 | |||
| 80 | enum class __property : uint8_t { | ||
| 81 | // Values generated from the data files. | ||
| 82 | __Consonant, | ||
| 83 | __Extend, | ||
| 84 | __Linker, | ||
| 85 | |||
| 86 | // The code unit has none of above properties. | ||
| 87 | __none | ||
| 88 | }; | ||
| 89 | |||
| 90 | /// The entries of the indic conjunct break property table. | ||
| 91 | /// | ||
| 92 | /// The data is generated from | ||
| 93 | /// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt | ||
| 94 | /// | ||
| 95 | /// The data has 3 values | ||
| 96 | /// - bits [0, 1] The property. One of the values generated from the datafiles | ||
| 97 | /// of \ref __property | ||
| 98 | /// - bits [2, 10] The size of the range. | ||
| 99 | /// - bits [11, 31] The lower bound code point of the range. The upper bound of | ||
| 100 | /// the range is lower bound + size. | ||
| 101 | /// | ||
| 102 | /// The 9 bits for the size allow a maximum range of 512 elements. Some ranges | ||
| 103 | /// in the Unicode tables are larger. They are stored in multiple consecutive | ||
| 104 | /// ranges in the data table. An alternative would be to store the sizes in a | ||
| 105 | /// separate 16-bit value. The original MSVC STL code had such an approach, but | ||
| 106 | /// this approach uses less space for the data and is about 4% faster in the | ||
| 107 | /// following benchmark. | ||
| 108 | /// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp | ||
| 109 | // clang-format off | ||
| 110 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { | ||
| 111 | 0x00180139, | ||
| 112 | 0x001a807d, | ||
| 113 | 0x00241811, | ||
| 114 | 0x002c88b1, | ||
| 115 | 0x002df801, | ||
| 116 | 0x002e0805, | ||
| 117 | 0x002e2005, | ||
| 118 | 0x002e3801, | ||
| 119 | 0x00308029, | ||
| 120 | 0x00325851, | ||
| 121 | 0x00338001, | ||
| 122 | 0x0036b019, | ||
| 123 | 0x0036f815, | ||
| 124 | 0x00373805, | ||
| 125 | 0x0037500d, | ||
| 126 | 0x00388801, | ||
| 127 | 0x00398069, | ||
| 128 | 0x003f5821, | ||
| 129 | 0x003fe801, | ||
| 130 | 0x0040b00d, | ||
| 131 | 0x0040d821, | ||
| 132 | 0x00412809, | ||
| 133 | 0x00414811, | ||
| 134 | 0x0042c809, | ||
| 135 | 0x0044c01d, | ||
| 136 | 0x0046505d, | ||
| 137 | 0x00471871, | ||
| 138 | 0x0048a890, | ||
| 139 | 0x0049e001, | ||
| 140 | 0x004a6802, | ||
| 141 | 0x004a880d, | ||
| 142 | 0x004ac01c, | ||
| 143 | 0x004bc01c, | ||
| 144 | 0x004ca84c, | ||
| 145 | 0x004d5018, | ||
| 146 | 0x004d9000, | ||
| 147 | 0x004db00c, | ||
| 148 | 0x004de001, | ||
| 149 | 0x004e6802, | ||
| 150 | 0x004ee004, | ||
| 151 | 0x004ef800, | ||
| 152 | 0x004f8004, | ||
| 153 | 0x004ff001, | ||
| 154 | 0x0051e001, | ||
| 155 | 0x0054a84c, | ||
| 156 | 0x00555018, | ||
| 157 | 0x00559004, | ||
| 158 | 0x0055a810, | ||
| 159 | 0x0055e001, | ||
| 160 | 0x00566802, | ||
| 161 | 0x0057c800, | ||
| 162 | 0x0058a84c, | ||
| 163 | 0x00595018, | ||
| 164 | 0x00599004, | ||
| 165 | 0x0059a810, | ||
| 166 | 0x0059e001, | ||
| 167 | 0x005a6802, | ||
| 168 | 0x005ae004, | ||
| 169 | 0x005af800, | ||
| 170 | 0x005b8800, | ||
| 171 | 0x0060a84c, | ||
| 172 | 0x0061503c, | ||
| 173 | 0x0061e001, | ||
| 174 | 0x00626802, | ||
| 175 | 0x0062a805, | ||
| 176 | 0x0062c008, | ||
| 177 | 0x0065e001, | ||
| 178 | 0x0068a894, | ||
| 179 | 0x0069d805, | ||
| 180 | 0x006a6802, | ||
| 181 | 0x0071c009, | ||
| 182 | 0x0072400d, | ||
| 183 | 0x0075c009, | ||
| 184 | 0x0076400d, | ||
| 185 | 0x0078c005, | ||
| 186 | 0x0079a801, | ||
| 187 | 0x0079b801, | ||
| 188 | 0x0079c801, | ||
| 189 | 0x007b8805, | ||
| 190 | 0x007ba001, | ||
| 191 | 0x007bd00d, | ||
| 192 | 0x007c0001, | ||
| 193 | 0x007c1009, | ||
| 194 | 0x007c3005, | ||
| 195 | 0x007e3001, | ||
| 196 | 0x0081b801, | ||
| 197 | 0x0081c805, | ||
| 198 | 0x00846801, | ||
| 199 | 0x009ae809, | ||
| 200 | 0x00b8a001, | ||
| 201 | 0x00be9001, | ||
| 202 | 0x00bee801, | ||
| 203 | 0x00c54801, | ||
| 204 | 0x00c9c809, | ||
| 205 | 0x00d0b805, | ||
| 206 | 0x00d30001, | ||
| 207 | 0x00d3a81d, | ||
| 208 | 0x00d3f801, | ||
| 209 | 0x00d58035, | ||
| 210 | 0x00d5f83d, | ||
| 211 | 0x00d9a001, | ||
| 212 | 0x00db5821, | ||
| 213 | 0x00dd5801, | ||
| 214 | 0x00df3001, | ||
| 215 | 0x00e1b801, | ||
| 216 | 0x00e68009, | ||
| 217 | 0x00e6a031, | ||
| 218 | 0x00e71019, | ||
| 219 | 0x00e76801, | ||
| 220 | 0x00e7a001, | ||
| 221 | 0x00e7c005, | ||
| 222 | 0x00ee00fd, | ||
| 223 | 0x01006801, | ||
| 224 | 0x01068031, | ||
| 225 | 0x01070801, | ||
| 226 | 0x0107282d, | ||
| 227 | 0x01677809, | ||
| 228 | 0x016bf801, | ||
| 229 | 0x016f007d, | ||
| 230 | 0x01815015, | ||
| 231 | 0x0184c805, | ||
| 232 | 0x05337801, | ||
| 233 | 0x0533a025, | ||
| 234 | 0x0534f005, | ||
| 235 | 0x05378005, | ||
| 236 | 0x05416001, | ||
| 237 | 0x05470045, | ||
| 238 | 0x05495809, | ||
| 239 | 0x054d9801, | ||
| 240 | 0x05558001, | ||
| 241 | 0x05559009, | ||
| 242 | 0x0555b805, | ||
| 243 | 0x0555f005, | ||
| 244 | 0x05560801, | ||
| 245 | 0x0557b001, | ||
| 246 | 0x055f6801, | ||
| 247 | 0x07d8f001, | ||
| 248 | 0x07f1003d, | ||
| 249 | 0x080fe801, | ||
| 250 | 0x08170001, | ||
| 251 | 0x081bb011, | ||
| 252 | 0x08506801, | ||
| 253 | 0x08507801, | ||
| 254 | 0x0851c009, | ||
| 255 | 0x0851f801, | ||
| 256 | 0x08572805, | ||
| 257 | 0x0869200d, | ||
| 258 | 0x08755805, | ||
| 259 | 0x0877e809, | ||
| 260 | 0x087a3029, | ||
| 261 | 0x087c100d, | ||
| 262 | 0x08838001, | ||
| 263 | 0x0883f801, | ||
| 264 | 0x0885d001, | ||
| 265 | 0x08880009, | ||
| 266 | 0x08899805, | ||
| 267 | 0x088b9801, | ||
| 268 | 0x088e5001, | ||
| 269 | 0x0891b001, | ||
| 270 | 0x08974805, | ||
| 271 | 0x0899d805, | ||
| 272 | 0x089b3019, | ||
| 273 | 0x089b8011, | ||
| 274 | 0x08a23001, | ||
| 275 | 0x08a2f001, | ||
| 276 | 0x08a61801, | ||
| 277 | 0x08ae0001, | ||
| 278 | 0x08b5b801, | ||
| 279 | 0x08b95801, | ||
| 280 | 0x08c1d001, | ||
| 281 | 0x08c9f001, | ||
| 282 | 0x08ca1801, | ||
| 283 | 0x08d1a001, | ||
| 284 | 0x08d23801, | ||
| 285 | 0x08d4c801, | ||
| 286 | 0x08ea1001, | ||
| 287 | 0x08ea2005, | ||
| 288 | 0x08ecb801, | ||
| 289 | 0x08fa1001, | ||
| 290 | 0x0b578011, | ||
| 291 | 0x0b598019, | ||
| 292 | 0x0de4f001, | ||
| 293 | 0x0e8b2801, | ||
| 294 | 0x0e8b3809, | ||
| 295 | 0x0e8b7011, | ||
| 296 | 0x0e8bd81d, | ||
| 297 | 0x0e8c2819, | ||
| 298 | 0x0e8d500d, | ||
| 299 | 0x0e921009, | ||
| 300 | 0x0f000019, | ||
| 301 | 0x0f004041, | ||
| 302 | 0x0f00d819, | ||
| 303 | 0x0f011805, | ||
| 304 | 0x0f013011, | ||
| 305 | 0x0f047801, | ||
| 306 | 0x0f098019, | ||
| 307 | 0x0f157001, | ||
| 308 | 0x0f17600d, | ||
| 309 | 0x0f27600d, | ||
| 310 | 0x0f468019, | ||
| 311 | 0x0f4a2019}; | ||
| 312 | // clang-format on | ||
| 313 | |||
| 314 | /// Returns the indic conjuct break property of a code point. | ||
| 315 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept { | ||
| 316 | // The algorithm searches for the upper bound of the range and, when found, | ||
| 317 | // steps back one entry. This algorithm is used since the code point can be | ||
| 318 | // anywhere in the range. After a lower bound is found the next step is to | ||
| 319 | // compare whether the code unit is indeed in the range. | ||
| 320 | // | ||
| 321 | // Since the entry contains a code unit, size, and property the code point | ||
| 322 | // being sought needs to be adjusted. Just shifting the code point to the | ||
| 323 | // proper position doesn't work; suppose an entry has property 0, size 1, | ||
| 324 | // and lower bound 3. This results in the entry 0x1810. | ||
| 325 | // When searching for code point 3 it will search for 0x1800, find 0x1810 | ||
| 326 | // and moves to the previous entry. Thus the lower bound value will never | ||
| 327 | // be found. | ||
| 328 | // The simple solution is to set the bits belonging to the property and | ||
| 329 | // size. Then the upper bound for code point 3 will return the entry after | ||
| 330 | // 0x1810. After moving to the previous entry the algorithm arrives at the | ||
| 331 | // correct entry. | ||
| 332 | ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries; | ||
| 333 | if (__i == 0) | ||
| 334 | return __property::__none; | ||
| 335 | |||
| 336 | --__i; | ||
| 337 | uint32_t __upper_bound = (__entries[__i] >> 11) + ((__entries[__i] >> 2) & 0b1'1111'1111); | ||
| 338 | if (__code_point <= __upper_bound) | ||
| 339 | return static_cast<__property>(__entries[__i] & 0b11); | ||
| 340 | |||
| 341 | return __property::__none; | ||
| 342 | } | ||
| 343 | |||
| 344 | } // namespace __indic_conjunct_break | ||
| 345 | |||
| 346 | #endif //_LIBCPP_STD_VER >= 20 | ||
| 347 | |||
| 348 | _LIBCPP_END_NAMESPACE_STD | ||
| 349 | |||
| 350 | #endif // _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H | ||
lib/libcxx/include/__format/parser_std_format_spec.h+13-16| ... | @@ -129,8 +129,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr uint32_t __substitute_arg_id(basic_format_arg<_C | ... | @@ -129,8 +129,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr uint32_t __substitute_arg_id(basic_format_arg<_C |
| 129 | /// | 129 | /// |
| 130 | /// They default to false so when a new field is added it needs to be opted in | 130 | /// They default to false so when a new field is added it needs to be opted in |
| 131 | /// explicitly. | 131 | /// explicitly. |
| 132 | // TODO FMT Use an ABI tag for this struct. | 132 | struct _LIBCPP_HIDE_FROM_ABI __fields { |
| 133 | struct __fields { | ||
| 134 | uint16_t __sign_ : 1 {false}; | 133 | uint16_t __sign_ : 1 {false}; |
| 135 | uint16_t __alternate_form_ : 1 {false}; | 134 | uint16_t __alternate_form_ : 1 {false}; |
| 136 | uint16_t __zero_padding_ : 1 {false}; | 135 | uint16_t __zero_padding_ : 1 {false}; |
| ... | @@ -355,10 +354,10 @@ public: | ... | @@ -355,10 +354,10 @@ public: |
| 355 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator __parse(_ParseContext& __ctx, __fields __fields) { | 354 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator __parse(_ParseContext& __ctx, __fields __fields) { |
| 356 | auto __begin = __ctx.begin(); | 355 | auto __begin = __ctx.begin(); |
| 357 | auto __end = __ctx.end(); | 356 | auto __end = __ctx.end(); |
| 358 | if (__begin == __end) | 357 | if (__begin == __end || *__begin == _CharT('}') || (__fields.__use_range_fill_ && *__begin == _CharT(':'))) |
| 359 | return __begin; | 358 | return __begin; |
| 360 | 359 | ||
| 361 | if (__parse_fill_align(__begin, __end, __fields.__use_range_fill_) && __begin == __end) | 360 | if (__parse_fill_align(__begin, __end) && __begin == __end) |
| 362 | return __begin; | 361 | return __begin; |
| 363 | 362 | ||
| 364 | if (__fields.__sign_) { | 363 | if (__fields.__sign_) { |
| ... | @@ -574,12 +573,10 @@ private: | ... | @@ -574,12 +573,10 @@ private: |
| 574 | return false; | 573 | return false; |
| 575 | } | 574 | } |
| 576 | 575 | ||
| 577 | _LIBCPP_HIDE_FROM_ABI constexpr void __validate_fill_character(_CharT __fill, bool __use_range_fill) { | 576 | _LIBCPP_HIDE_FROM_ABI constexpr void __validate_fill_character(_CharT __fill) { |
| 578 | // The forbidden fill characters all code points formed from a single code unit, thus the | 577 | // The forbidden fill characters all code points formed from a single code unit, thus the |
| 579 | // check can be omitted when more code units are used. | 578 | // check can be omitted when more code units are used. |
| 580 | if (__use_range_fill && (__fill == _CharT('{') || __fill == _CharT('}') || __fill == _CharT(':'))) | 579 | if (__fill == _CharT('{')) |
| 581 | std::__throw_format_error("The fill option contains an invalid value"); | ||
| 582 | else if (__fill == _CharT('{') || __fill == _CharT('}')) | ||
| 583 | std::__throw_format_error("The fill option contains an invalid value"); | 580 | std::__throw_format_error("The fill option contains an invalid value"); |
| 584 | } | 581 | } |
| 585 | 582 | ||
| ... | @@ -590,7 +587,7 @@ private: | ... | @@ -590,7 +587,7 @@ private: |
| 590 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 587 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 591 | || (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) | 588 | || (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) |
| 592 | # endif | 589 | # endif |
| 593 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) { | 590 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) { |
| 594 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 591 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 595 | __begin != __end, | 592 | __begin != __end, |
| 596 | "when called with an empty input the function will cause " | 593 | "when called with an empty input the function will cause " |
| ... | @@ -606,7 +603,7 @@ private: | ... | @@ -606,7 +603,7 @@ private: |
| 606 | // The forbidden fill characters all are code points encoded | 603 | // The forbidden fill characters all are code points encoded |
| 607 | // in one code unit, thus the check can be omitted when more | 604 | // in one code unit, thus the check can be omitted when more |
| 608 | // code units are used. | 605 | // code units are used. |
| 609 | __validate_fill_character(*__begin, __use_range_fill); | 606 | __validate_fill_character(*__begin); |
| 610 | 607 | ||
| 611 | std::copy_n(__begin, __code_units, std::addressof(__fill_.__data[0])); | 608 | std::copy_n(__begin, __code_units, std::addressof(__fill_.__data[0])); |
| 612 | __begin += __code_units + 1; | 609 | __begin += __code_units + 1; |
| ... | @@ -623,7 +620,7 @@ private: | ... | @@ -623,7 +620,7 @@ private: |
| 623 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 620 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 624 | template <contiguous_iterator _Iterator> | 621 | template <contiguous_iterator _Iterator> |
| 625 | requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) | 622 | requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) |
| 626 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) { | 623 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) { |
| 627 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 624 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 628 | __begin != __end, | 625 | __begin != __end, |
| 629 | "when called with an empty input the function will cause " | 626 | "when called with an empty input the function will cause " |
| ... | @@ -632,7 +629,7 @@ private: | ... | @@ -632,7 +629,7 @@ private: |
| 632 | if (!__unicode::__is_scalar_value(*__begin)) | 629 | if (!__unicode::__is_scalar_value(*__begin)) |
| 633 | std::__throw_format_error("The fill option contains an invalid value"); | 630 | std::__throw_format_error("The fill option contains an invalid value"); |
| 634 | 631 | ||
| 635 | __validate_fill_character(*__begin, __use_range_fill); | 632 | __validate_fill_character(*__begin); |
| 636 | 633 | ||
| 637 | __fill_.__data[0] = *__begin; | 634 | __fill_.__data[0] = *__begin; |
| 638 | __begin += 2; | 635 | __begin += 2; |
| ... | @@ -651,14 +648,14 @@ private: | ... | @@ -651,14 +648,14 @@ private: |
| 651 | # else // _LIBCPP_HAS_NO_UNICODE | 648 | # else // _LIBCPP_HAS_NO_UNICODE |
| 652 | // range-fill and tuple-fill are identical | 649 | // range-fill and tuple-fill are identical |
| 653 | template <contiguous_iterator _Iterator> | 650 | template <contiguous_iterator _Iterator> |
| 654 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) { | 651 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) { |
| 655 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 652 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 656 | __begin != __end, | 653 | __begin != __end, |
| 657 | "when called with an empty input the function will cause " | 654 | "when called with an empty input the function will cause " |
| 658 | "undefined behavior by evaluating data not in the input"); | 655 | "undefined behavior by evaluating data not in the input"); |
| 659 | if (__begin + 1 != __end) { | 656 | if (__begin + 1 != __end) { |
| 660 | if (__parse_alignment(*(__begin + 1))) { | 657 | if (__parse_alignment(*(__begin + 1))) { |
| 661 | __validate_fill_character(*__begin, __use_range_fill); | 658 | __validate_fill_character(*__begin); |
| 662 | 659 | ||
| 663 | __fill_.__data[0] = *__begin; | 660 | __fill_.__data[0] = *__begin; |
| 664 | __begin += 2; | 661 | __begin += 2; |
| ... | @@ -1158,8 +1155,8 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col | ... | @@ -1158,8 +1155,8 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col |
| 1158 | // When Unicode isn't supported assume ASCII and every code unit is one code | 1155 | // When Unicode isn't supported assume ASCII and every code unit is one code |
| 1159 | // point. In ASCII the estimated column width is always one. Thus there's no | 1156 | // point. In ASCII the estimated column width is always one. Thus there's no |
| 1160 | // need for rounding. | 1157 | // need for rounding. |
| 1161 | size_t __width_ = std::min(__str.size(), __maximum); | 1158 | size_t __width = std::min(__str.size(), __maximum); |
| 1162 | return {__width_, __str.begin() + __width_}; | 1159 | return {__width, __str.begin() + __width}; |
| 1163 | } | 1160 | } |
| 1164 | 1161 | ||
| 1165 | # endif // !defined(_LIBCPP_HAS_NO_UNICODE) | 1162 | # endif // !defined(_LIBCPP_HAS_NO_UNICODE) |
lib/libcxx/include/__format/unicode.h+218-95| ... | @@ -15,8 +15,10 @@ | ... | @@ -15,8 +15,10 @@ |
| 15 | #include <__concepts/same_as.h> | 15 | #include <__concepts/same_as.h> |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__format/extended_grapheme_cluster_table.h> | 17 | #include <__format/extended_grapheme_cluster_table.h> |
| 18 | #include <__format/indic_conjunct_break_table.h> | ||
| 18 | #include <__iterator/concepts.h> | 19 | #include <__iterator/concepts.h> |
| 19 | #include <__iterator/readable_traits.h> // iter_value_t | 20 | #include <__iterator/readable_traits.h> // iter_value_t |
| 21 | #include <__utility/unreachable.h> | ||
| 20 | #include <string_view> | 22 | #include <string_view> |
| 21 | 23 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -292,84 +294,231 @@ private: | ... | @@ -292,84 +294,231 @@ private: |
| 292 | }; | 294 | }; |
| 293 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 295 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 294 | 296 | ||
| 295 | _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break( | 297 | // State machine to implement the Extended Grapheme Cluster Boundary |
| 296 | bool& __ri_break_allowed, | 298 | // |
| 297 | bool __has_extened_pictographic, | 299 | // The exact rules may change between Unicode versions. |
| 298 | __extended_grapheme_custer_property_boundary::__property __prev, | 300 | // This implements the extended rules see |
| 299 | __extended_grapheme_custer_property_boundary::__property __next) { | 301 | // https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries |
| 300 | using __extended_grapheme_custer_property_boundary::__property; | 302 | class __extended_grapheme_cluster_break { |
| 303 | using __EGC_property = __extended_grapheme_custer_property_boundary::__property; | ||
| 304 | using __inCB_property = __indic_conjunct_break::__property; | ||
| 301 | 305 | ||
| 302 | __has_extened_pictographic |= __prev == __property::__Extended_Pictographic; | 306 | public: |
| 307 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_break(char32_t __first_code_point) | ||
| 308 | : __prev_code_point_(__first_code_point), | ||
| 309 | __prev_property_(__extended_grapheme_custer_property_boundary::__get_property(__first_code_point)) { | ||
| 310 | // Initializes the active rule. | ||
| 311 | if (__prev_property_ == __EGC_property::__Extended_Pictographic) | ||
| 312 | __active_rule_ = __rule::__GB11_emoji; | ||
| 313 | else if (__prev_property_ == __EGC_property::__Regional_Indicator) | ||
| 314 | __active_rule_ = __rule::__GB12_GB13_regional_indicator; | ||
| 315 | else if (__indic_conjunct_break::__get_property(__first_code_point) == __inCB_property::__Consonant) | ||
| 316 | __active_rule_ = __rule::__GB9c_indic_conjunct_break; | ||
| 317 | } | ||
| 303 | 318 | ||
| 304 | // https://www.unicode.org/reports/tr29/tr29-39.html#Grapheme_Cluster_Boundary_Rules | 319 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(char32_t __next_code_point) { |
| 320 | __EGC_property __next_property = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point); | ||
| 321 | bool __result = __evaluate(__next_code_point, __next_property); | ||
| 322 | __prev_code_point_ = __next_code_point; | ||
| 323 | __prev_property_ = __next_property; | ||
| 324 | return __result; | ||
| 325 | } | ||
| 305 | 326 | ||
| 306 | // *** Break at the start and end of text, unless the text is empty. *** | 327 | // The code point whose break propery are considered during the next |
| 328 | // evaluation cyle. | ||
| 329 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr char32_t __current_code_point() const { return __prev_code_point_; } | ||
| 307 | 330 | ||
| 308 | _LIBCPP_ASSERT_INTERNAL(__prev != __property::__sot, "should be handled in the constructor"); // GB1 | 331 | private: |
| 309 | _LIBCPP_ASSERT_INTERNAL(__prev != __property::__eot, "should be handled by our caller"); // GB2 | 332 | // The naming of the identifiers matches the Unicode standard. |
| 333 | // NOLINTBEGIN(readability-identifier-naming) | ||
| 334 | |||
| 335 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool | ||
| 336 | __evaluate(char32_t __next_code_point, __EGC_property __next_property) { | ||
| 337 | switch (__active_rule_) { | ||
| 338 | case __rule::__none: | ||
| 339 | return __evaluate_none(__next_code_point, __next_property); | ||
| 340 | case __rule::__GB9c_indic_conjunct_break: | ||
| 341 | return __evaluate_GB9c_indic_conjunct_break(__next_code_point, __next_property); | ||
| 342 | case __rule::__GB11_emoji: | ||
| 343 | return __evaluate_GB11_emoji(__next_code_point, __next_property); | ||
| 344 | case __rule::__GB12_GB13_regional_indicator: | ||
| 345 | return __evaluate_GB12_GB13_regional_indicator(__next_code_point, __next_property); | ||
| 346 | } | ||
| 347 | __libcpp_unreachable(); | ||
| 348 | } | ||
| 310 | 349 | ||
| 311 | // *** Do not break between a CR and LF. Otherwise, break before and after controls. *** | 350 | _LIBCPP_HIDE_FROM_ABI constexpr bool __evaluate_none(char32_t __next_code_point, __EGC_property __next_property) { |
| 312 | if (__prev == __property::__CR && __next == __property::__LF) // GB3 | 351 | // *** Break at the start and end of text, unless the text is empty. *** |
| 313 | return false; | ||
| 314 | 352 | ||
| 315 | if (__prev == __property::__Control || __prev == __property::__CR || __prev == __property::__LF) // GB4 | 353 | _LIBCPP_ASSERT_INTERNAL(__prev_property_ != __EGC_property::__sot, "should be handled in the constructor"); // GB1 |
| 316 | return true; | 354 | _LIBCPP_ASSERT_INTERNAL(__prev_property_ != __EGC_property::__eot, "should be handled by our caller"); // GB2 |
| 317 | 355 | ||
| 318 | if (__next == __property::__Control || __next == __property::__CR || __next == __property::__LF) // GB5 | 356 | // *** Do not break between a CR and LF. Otherwise, break before and after controls. *** |
| 319 | return true; | 357 | if (__prev_property_ == __EGC_property::__CR && __next_property == __EGC_property::__LF) // GB3 |
| 358 | return false; | ||
| 320 | 359 | ||
| 321 | // *** Do not break Hangul syllable sequences. *** | 360 | if (__prev_property_ == __EGC_property::__Control || __prev_property_ == __EGC_property::__CR || |
| 322 | if (__prev == __property::__L && (__next == __property::__L || __next == __property::__V || | 361 | __prev_property_ == __EGC_property::__LF) // GB4 |
| 323 | __next == __property::__LV || __next == __property::__LVT)) // GB6 | 362 | return true; |
| 324 | return false; | ||
| 325 | 363 | ||
| 326 | if ((__prev == __property::__LV || __prev == __property::__V) && | 364 | if (__next_property == __EGC_property::__Control || __next_property == __EGC_property::__CR || |
| 327 | (__next == __property::__V || __next == __property::__T)) // GB7 | 365 | __next_property == __EGC_property::__LF) // GB5 |
| 328 | return false; | 366 | return true; |
| 329 | 367 | ||
| 330 | if ((__prev == __property::__LVT || __prev == __property::__T) && __next == __property::__T) // GB8 | 368 | // *** Do not break Hangul syllable sequences. *** |
| 331 | return false; | 369 | if (__prev_property_ == __EGC_property::__L && |
| 370 | (__next_property == __EGC_property::__L || __next_property == __EGC_property::__V || | ||
| 371 | __next_property == __EGC_property::__LV || __next_property == __EGC_property::__LVT)) // GB6 | ||
| 372 | return false; | ||
| 332 | 373 | ||
| 333 | // *** Do not break before extending characters or ZWJ. *** | 374 | if ((__prev_property_ == __EGC_property::__LV || __prev_property_ == __EGC_property::__V) && |
| 334 | if (__next == __property::__Extend || __next == __property::__ZWJ) | 375 | (__next_property == __EGC_property::__V || __next_property == __EGC_property::__T)) // GB7 |
| 335 | return false; // GB9 | 376 | return false; |
| 336 | 377 | ||
| 337 | // *** Do not break before SpacingMarks, or after Prepend characters. *** | 378 | if ((__prev_property_ == __EGC_property::__LVT || __prev_property_ == __EGC_property::__T) && |
| 338 | if (__next == __property::__SpacingMark) // GB9a | 379 | __next_property == __EGC_property::__T) // GB8 |
| 339 | return false; | 380 | return false; |
| 340 | 381 | ||
| 341 | if (__prev == __property::__Prepend) // GB9b | 382 | // *** Do not break before extending characters or ZWJ. *** |
| 342 | return false; | 383 | if (__next_property == __EGC_property::__Extend || __next_property == __EGC_property::__ZWJ) |
| 384 | return false; // GB9 | ||
| 343 | 385 | ||
| 344 | // *** Do not break within emoji modifier sequences or emoji zwj sequences. *** | 386 | // *** Do not break before SpacingMarks, or after Prepend characters. *** |
| 387 | if (__next_property == __EGC_property::__SpacingMark) // GB9a | ||
| 388 | return false; | ||
| 345 | 389 | ||
| 346 | // GB11 \p{Extended_Pictographic} Extend* ZWJ x \p{Extended_Pictographic} | 390 | if (__prev_property_ == __EGC_property::__Prepend) // GB9b |
| 347 | // | 391 | return false; |
| 348 | // Note that several parts of this rule are matched by GB9: Any x (Extend | ZWJ) | ||
| 349 | // - \p{Extended_Pictographic} x Extend | ||
| 350 | // - Extend x Extend | ||
| 351 | // - \p{Extended_Pictographic} x ZWJ | ||
| 352 | // - Extend x ZWJ | ||
| 353 | // | ||
| 354 | // So the only case left to test is | ||
| 355 | // - \p{Extended_Pictographic}' x ZWJ x \p{Extended_Pictographic} | ||
| 356 | // where \p{Extended_Pictographic}' is stored in __has_extened_pictographic | ||
| 357 | if (__has_extened_pictographic && __prev == __property::__ZWJ && __next == __property::__Extended_Pictographic) | ||
| 358 | return false; | ||
| 359 | 392 | ||
| 360 | // *** Do not break within emoji flag sequences *** | 393 | // *** Do not break within certain combinations with Indic_Conjunct_Break (InCB)=Linker. *** |
| 394 | if (__indic_conjunct_break::__get_property(__next_code_point) == __inCB_property::__Consonant) { | ||
| 395 | __active_rule_ = __rule::__GB9c_indic_conjunct_break; | ||
| 396 | __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant; | ||
| 397 | return true; | ||
| 398 | } | ||
| 399 | |||
| 400 | // *** Do not break within emoji modifier sequences or emoji zwj sequences. *** | ||
| 401 | if (__next_property == __EGC_property::__Extended_Pictographic) { | ||
| 402 | __active_rule_ = __rule::__GB11_emoji; | ||
| 403 | __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic; | ||
| 404 | return true; | ||
| 405 | } | ||
| 406 | |||
| 407 | // *** Do not break within emoji flag sequences *** | ||
| 361 | 408 | ||
| 362 | // That is, do not break between regional indicator (RI) symbols if there | 409 | // That is, do not break between regional indicator (RI) symbols if there |
| 363 | // is an odd number of RI characters before the break point. | 410 | // is an odd number of RI characters before the break point. |
| 411 | if (__next_property == __EGC_property::__Regional_Indicator) { // GB12 + GB13 | ||
| 412 | __active_rule_ = __rule::__GB12_GB13_regional_indicator; | ||
| 413 | return true; | ||
| 414 | } | ||
| 364 | 415 | ||
| 365 | if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13 | 416 | // *** Otherwise, break everywhere. *** |
| 366 | __ri_break_allowed = !__ri_break_allowed; | 417 | return true; // GB999 |
| 367 | return __ri_break_allowed; | ||
| 368 | } | 418 | } |
| 369 | 419 | ||
| 370 | // *** Otherwise, break everywhere. *** | 420 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 371 | return true; // GB999 | 421 | __evaluate_GB9c_indic_conjunct_break(char32_t __next_code_point, __EGC_property __next_property) { |
| 372 | } | 422 | __inCB_property __break = __indic_conjunct_break::__get_property(__next_code_point); |
| 423 | if (__break == __inCB_property::__none) { | ||
| 424 | __active_rule_ = __rule::__none; | ||
| 425 | return __evaluate_none(__next_code_point, __next_property); | ||
| 426 | } | ||
| 427 | |||
| 428 | switch (__GB9c_indic_conjunct_break_state_) { | ||
| 429 | case __GB9c_indic_conjunct_break_state::__Consonant: | ||
| 430 | if (__break == __inCB_property::__Extend) { | ||
| 431 | return false; | ||
| 432 | } | ||
| 433 | if (__break == __inCB_property::__Linker) { | ||
| 434 | __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Linker; | ||
| 435 | return false; | ||
| 436 | } | ||
| 437 | __active_rule_ = __rule::__none; | ||
| 438 | return __evaluate_none(__next_code_point, __next_property); | ||
| 439 | |||
| 440 | case __GB9c_indic_conjunct_break_state::__Linker: | ||
| 441 | if (__break == __inCB_property::__Extend) { | ||
| 442 | return false; | ||
| 443 | } | ||
| 444 | if (__break == __inCB_property::__Linker) { | ||
| 445 | return false; | ||
| 446 | } | ||
| 447 | if (__break == __inCB_property::__Consonant) { | ||
| 448 | __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant; | ||
| 449 | return false; | ||
| 450 | } | ||
| 451 | __active_rule_ = __rule::__none; | ||
| 452 | return __evaluate_none(__next_code_point, __next_property); | ||
| 453 | } | ||
| 454 | __libcpp_unreachable(); | ||
| 455 | } | ||
| 456 | |||
| 457 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool | ||
| 458 | __evaluate_GB11_emoji(char32_t __next_code_point, __EGC_property __next_property) { | ||
| 459 | switch (__GB11_emoji_state_) { | ||
| 460 | case __GB11_emoji_state::__Extended_Pictographic: | ||
| 461 | if (__next_property == __EGC_property::__Extend) { | ||
| 462 | __GB11_emoji_state_ = __GB11_emoji_state::__Extend; | ||
| 463 | return false; | ||
| 464 | } | ||
| 465 | [[fallthrough]]; | ||
| 466 | case __GB11_emoji_state::__Extend: | ||
| 467 | if (__next_property == __EGC_property::__ZWJ) { | ||
| 468 | __GB11_emoji_state_ = __GB11_emoji_state::__ZWJ; | ||
| 469 | return false; | ||
| 470 | } | ||
| 471 | if (__next_property == __EGC_property::__Extend) | ||
| 472 | return false; | ||
| 473 | __active_rule_ = __rule::__none; | ||
| 474 | return __evaluate_none(__next_code_point, __next_property); | ||
| 475 | |||
| 476 | case __GB11_emoji_state::__ZWJ: | ||
| 477 | if (__next_property == __EGC_property::__Extended_Pictographic) { | ||
| 478 | __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic; | ||
| 479 | return false; | ||
| 480 | } | ||
| 481 | __active_rule_ = __rule::__none; | ||
| 482 | return __evaluate_none(__next_code_point, __next_property); | ||
| 483 | } | ||
| 484 | __libcpp_unreachable(); | ||
| 485 | } | ||
| 486 | |||
| 487 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool | ||
| 488 | __evaluate_GB12_GB13_regional_indicator(char32_t __next_code_point, __EGC_property __next_property) { | ||
| 489 | __active_rule_ = __rule::__none; | ||
| 490 | if (__next_property == __EGC_property::__Regional_Indicator) | ||
| 491 | return false; | ||
| 492 | return __evaluate_none(__next_code_point, __next_property); | ||
| 493 | } | ||
| 494 | |||
| 495 | char32_t __prev_code_point_; | ||
| 496 | __EGC_property __prev_property_; | ||
| 497 | |||
| 498 | enum class __rule { | ||
| 499 | __none, | ||
| 500 | __GB9c_indic_conjunct_break, | ||
| 501 | __GB11_emoji, | ||
| 502 | __GB12_GB13_regional_indicator, | ||
| 503 | }; | ||
| 504 | __rule __active_rule_ = __rule::__none; | ||
| 505 | |||
| 506 | enum class __GB11_emoji_state { | ||
| 507 | __Extended_Pictographic, | ||
| 508 | __Extend, | ||
| 509 | __ZWJ, | ||
| 510 | }; | ||
| 511 | __GB11_emoji_state __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic; | ||
| 512 | |||
| 513 | enum class __GB9c_indic_conjunct_break_state { | ||
| 514 | __Consonant, | ||
| 515 | __Linker, | ||
| 516 | }; | ||
| 517 | |||
| 518 | __GB9c_indic_conjunct_break_state __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant; | ||
| 519 | |||
| 520 | // NOLINTEND(readability-identifier-naming) | ||
| 521 | }; | ||
| 373 | 522 | ||
| 374 | /// Helper class to extract an extended grapheme cluster from a Unicode character range. | 523 | /// Helper class to extract an extended grapheme cluster from a Unicode character range. |
| 375 | /// | 524 | /// |
| ... | @@ -382,9 +531,7 @@ class __extended_grapheme_cluster_view { | ... | @@ -382,9 +531,7 @@ class __extended_grapheme_cluster_view { |
| 382 | 531 | ||
| 383 | public: | 532 | public: |
| 384 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last) | 533 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last) |
| 385 | : __code_point_view_(__first, __last), | 534 | : __code_point_view_(__first, __last), __at_break_(__code_point_view_.__consume().__code_point) {} |
| 386 | __next_code_point_(__code_point_view_.__consume().__code_point), | ||
| 387 | __next_prop_(__extended_grapheme_custer_property_boundary::__get_property(__next_code_point_)) {} | ||
| 388 | 535 | ||
| 389 | struct __cluster { | 536 | struct __cluster { |
| 390 | /// The first code point of the extended grapheme cluster. | 537 | /// The first code point of the extended grapheme cluster. |
| ... | @@ -400,44 +547,20 @@ public: | ... | @@ -400,44 +547,20 @@ public: |
| 400 | _Iterator __last_; | 547 | _Iterator __last_; |
| 401 | }; | 548 | }; |
| 402 | 549 | ||
| 403 | _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() { | 550 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() { |
| 404 | _LIBCPP_ASSERT_INTERNAL(__next_prop_ != __extended_grapheme_custer_property_boundary::__property::__eot, | 551 | char32_t __code_point = __at_break_.__current_code_point(); |
| 405 | "can't move beyond the end of input"); | 552 | _Iterator __position = __code_point_view_.__position(); |
| 406 | 553 | while (!__code_point_view_.__at_end()) { | |
| 407 | char32_t __code_point = __next_code_point_; | 554 | if (__at_break_(__code_point_view_.__consume().__code_point)) |
| 408 | if (!__code_point_view_.__at_end()) | 555 | break; |
| 409 | return {__code_point, __get_break()}; | 556 | __position = __code_point_view_.__position(); |
| 410 | 557 | } | |
| 411 | __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot; | 558 | return {__code_point, __position}; |
| 412 | return {__code_point, __code_point_view_.__position()}; | ||
| 413 | } | 559 | } |
| 414 | 560 | ||
| 415 | private: | 561 | private: |
| 416 | __code_point_view<_CharT> __code_point_view_; | 562 | __code_point_view<_CharT> __code_point_view_; |
| 417 | 563 | __extended_grapheme_cluster_break __at_break_; | |
| 418 | char32_t __next_code_point_; | ||
| 419 | __extended_grapheme_custer_property_boundary::__property __next_prop_; | ||
| 420 | |||
| 421 | _LIBCPP_HIDE_FROM_ABI constexpr _Iterator __get_break() { | ||
| 422 | bool __ri_break_allowed = true; | ||
| 423 | bool __has_extened_pictographic = false; | ||
| 424 | while (true) { | ||
| 425 | _Iterator __result = __code_point_view_.__position(); | ||
| 426 | __extended_grapheme_custer_property_boundary::__property __prev = __next_prop_; | ||
| 427 | if (__code_point_view_.__at_end()) { | ||
| 428 | __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot; | ||
| 429 | return __result; | ||
| 430 | } | ||
| 431 | __next_code_point_ = __code_point_view_.__consume().__code_point; | ||
| 432 | __next_prop_ = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point_); | ||
| 433 | |||
| 434 | __has_extened_pictographic |= | ||
| 435 | __prev == __extended_grapheme_custer_property_boundary::__property::__Extended_Pictographic; | ||
| 436 | |||
| 437 | if (__at_extended_grapheme_cluster_break(__ri_break_allowed, __has_extened_pictographic, __prev, __next_prop_)) | ||
| 438 | return __result; | ||
| 439 | } | ||
| 440 | } | ||
| 441 | }; | 564 | }; |
| 442 | 565 | ||
| 443 | template <contiguous_iterator _Iterator> | 566 | template <contiguous_iterator _Iterator> |
lib/libcxx/include/__format/width_estimation_table.h+4-5| ... | @@ -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 | inline constexpr uint32_t __entries[108] = { | 122 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { |
| 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] */, // |
| ... | @@ -158,14 +158,13 @@ inline constexpr uint32_t __entries[108] = { | ... | @@ -158,14 +158,13 @@ inline constexpr uint32_t __entries[108] = { |
| 158 | 0x0ba00019 /* 00002e80 - 00002e99 [ 26] */, // | 158 | 0x0ba00019 /* 00002e80 - 00002e99 [ 26] */, // |
| 159 | 0x0ba6c058 /* 00002e9b - 00002ef3 [ 89] */, // | 159 | 0x0ba6c058 /* 00002e9b - 00002ef3 [ 89] */, // |
| 160 | 0x0bc000d5 /* 00002f00 - 00002fd5 [ 214] */, // | 160 | 0x0bc000d5 /* 00002f00 - 00002fd5 [ 214] */, // |
| 161 | 0x0bfc000b /* 00002ff0 - 00002ffb [ 12] */, // | 161 | 0x0bfc004e /* 00002ff0 - 0000303e [ 79] */, // |
| 162 | 0x0c00003e /* 00003000 - 0000303e [ 63] */, // | ||
| 163 | 0x0c104055 /* 00003041 - 00003096 [ 86] */, // | 162 | 0x0c104055 /* 00003041 - 00003096 [ 86] */, // |
| 164 | 0x0c264066 /* 00003099 - 000030ff [ 103] */, // | 163 | 0x0c264066 /* 00003099 - 000030ff [ 103] */, // |
| 165 | 0x0c41402a /* 00003105 - 0000312f [ 43] */, // | 164 | 0x0c41402a /* 00003105 - 0000312f [ 43] */, // |
| 166 | 0x0c4c405d /* 00003131 - 0000318e [ 94] */, // | 165 | 0x0c4c405d /* 00003131 - 0000318e [ 94] */, // |
| 167 | 0x0c640053 /* 00003190 - 000031e3 [ 84] */, // | 166 | 0x0c640053 /* 00003190 - 000031e3 [ 84] */, // |
| 168 | 0x0c7c002e /* 000031f0 - 0000321e [ 47] */, // | 167 | 0x0c7bc02f /* 000031ef - 0000321e [ 48] */, // |
| 169 | 0x0c880027 /* 00003220 - 00003247 [ 40] */, // | 168 | 0x0c880027 /* 00003220 - 00003247 [ 40] */, // |
| 170 | 0x0c943fff /* 00003250 - 0000724f [16384] */, // | 169 | 0x0c943fff /* 00003250 - 0000724f [16384] */, // |
| 171 | 0x1c94323c /* 00007250 - 0000a48c [12861] */, // | 170 | 0x1c94323c /* 00007250 - 0000a48c [12861] */, // |
| ... | @@ -238,7 +237,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd; | ... | @@ -238,7 +237,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd; |
| 238 | 237 | ||
| 239 | /// Returns the estimated width of a Unicode code point. | 238 | /// Returns the estimated width of a Unicode code point. |
| 240 | /// | 239 | /// |
| 241 | /// \pre The code point is a valid Unicode code point. | 240 | /// \\pre The code point is a valid Unicode code point. |
| 242 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int __estimated_width(const char32_t __code_point) noexcept { | 241 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int __estimated_width(const char32_t __code_point) noexcept { |
| 243 | // Since __table_upper_bound contains the unshifted range do the | 242 | // Since __table_upper_bound contains the unshifted range do the |
| 244 | // comparison without shifting. | 243 | // comparison without shifting. |
lib/libcxx/include/__format/write_escaped.h+22-6| ... | @@ -101,15 +101,27 @@ _LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_Cha | ... | @@ -101,15 +101,27 @@ _LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_Cha |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | template <class _CharT> | 103 | template <class _CharT> |
| 104 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value) { | 104 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool |
| 105 | __is_escaped_sequence_written(basic_string<_CharT>& __str, bool __last_escaped, char32_t __value) { | ||
| 105 | # ifdef _LIBCPP_HAS_NO_UNICODE | 106 | # ifdef _LIBCPP_HAS_NO_UNICODE |
| 106 | // For ASCII assume everything above 127 is printable. | 107 | // For ASCII assume everything above 127 is printable. |
| 107 | if (__value > 127) | 108 | if (__value > 127) |
| 108 | return false; | 109 | return false; |
| 109 | # endif | 110 | # endif |
| 110 | 111 | ||
| 112 | // [format.string.escaped]/2.2.1.2.1 | ||
| 113 | // CE is UTF-8, UTF-16, or UTF-32 and C corresponds to a Unicode scalar | ||
| 114 | // value whose Unicode property General_Category has a value in the groups | ||
| 115 | // Separator (Z) or Other (C), as described by UAX #44 of the Unicode Standard, | ||
| 111 | if (!__escaped_output_table::__needs_escape(__value)) | 116 | if (!__escaped_output_table::__needs_escape(__value)) |
| 112 | return false; | 117 | // [format.string.escaped]/2.2.1.2.2 |
| 118 | // CE is UTF-8, UTF-16, or UTF-32 and C corresponds to a Unicode scalar | ||
| 119 | // value with the Unicode property Grapheme_Extend=Yes as described by UAX | ||
| 120 | // #44 of the Unicode Standard and C is not immediately preceded in S by a | ||
| 121 | // character P appended to E without translation to an escape sequence, | ||
| 122 | if (!__last_escaped || __extended_grapheme_custer_property_boundary::__get_property(__value) != | ||
| 123 | __extended_grapheme_custer_property_boundary::__property::__Extend) | ||
| 124 | return false; | ||
| 113 | 125 | ||
| 114 | __formatter::__write_well_formed_escaped_code_unit(__str, __value); | 126 | __formatter::__write_well_formed_escaped_code_unit(__str, __value); |
| 115 | return true; | 127 | return true; |
| ... | @@ -124,8 +136,8 @@ enum class __escape_quotation_mark { __apostrophe, __double_quote }; | ... | @@ -124,8 +136,8 @@ enum class __escape_quotation_mark { __apostrophe, __double_quote }; |
| 124 | 136 | ||
| 125 | // [format.string.escaped]/2 | 137 | // [format.string.escaped]/2 |
| 126 | template <class _CharT> | 138 | template <class _CharT> |
| 127 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool | 139 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written( |
| 128 | __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __escape_quotation_mark __mark) { | 140 | basic_string<_CharT>& __str, char32_t __value, bool __last_escaped, __escape_quotation_mark __mark) { |
| 129 | // 2.2.1.1 - Mapped character in [tab:format.escape.sequences] | 141 | // 2.2.1.1 - Mapped character in [tab:format.escape.sequences] |
| 130 | switch (__value) { | 142 | switch (__value) { |
| 131 | case _CharT('\t'): | 143 | case _CharT('\t'): |
| ... | @@ -167,7 +179,7 @@ __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __e | ... | @@ -167,7 +179,7 @@ __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __e |
| 167 | // TODO FMT determine what to do with shift sequences. | 179 | // TODO FMT determine what to do with shift sequences. |
| 168 | 180 | ||
| 169 | // 2.2.1.2.1 and 2.2.1.2.2 - Escape | 181 | // 2.2.1.2.1 and 2.2.1.2.2 - Escape |
| 170 | return __formatter::__is_escaped_sequence_written(__str, __formatter::__to_char32(__value)); | 182 | return __formatter::__is_escaped_sequence_written(__str, __last_escaped, __formatter::__to_char32(__value)); |
| 171 | } | 183 | } |
| 172 | 184 | ||
| 173 | template <class _CharT> | 185 | template <class _CharT> |
| ... | @@ -175,11 +187,15 @@ _LIBCPP_HIDE_FROM_ABI void | ... | @@ -175,11 +187,15 @@ _LIBCPP_HIDE_FROM_ABI void |
| 175 | __escape(basic_string<_CharT>& __str, basic_string_view<_CharT> __values, __escape_quotation_mark __mark) { | 187 | __escape(basic_string<_CharT>& __str, basic_string_view<_CharT> __values, __escape_quotation_mark __mark) { |
| 176 | __unicode::__code_point_view<_CharT> __view{__values.begin(), __values.end()}; | 188 | __unicode::__code_point_view<_CharT> __view{__values.begin(), __values.end()}; |
| 177 | 189 | ||
| 190 | // When the first code unit has the property Grapheme_Extend=Yes it needs to | ||
| 191 | // be escaped. This happens when the previous code unit was also escaped. | ||
| 192 | bool __escape = true; | ||
| 178 | while (!__view.__at_end()) { | 193 | while (!__view.__at_end()) { |
| 179 | auto __first = __view.__position(); | 194 | auto __first = __view.__position(); |
| 180 | typename __unicode::__consume_result __result = __view.__consume(); | 195 | typename __unicode::__consume_result __result = __view.__consume(); |
| 181 | if (__result.__status == __unicode::__consume_result::__ok) { | 196 | if (__result.__status == __unicode::__consume_result::__ok) { |
| 182 | if (!__formatter::__is_escaped_sequence_written(__str, __result.__code_point, __mark)) | 197 | __escape = __formatter::__is_escaped_sequence_written(__str, __result.__code_point, __escape, __mark); |
| 198 | if (!__escape) | ||
| 183 | // 2.2.1.3 - Add the character | 199 | // 2.2.1.3 - Add the character |
| 184 | ranges::copy(__first, __view.__position(), std::back_insert_iterator(__str)); | 200 | ranges::copy(__first, __view.__position(), std::back_insert_iterator(__str)); |
| 185 | } else { | 201 | } else { |
lib/libcxx/include/__functional/bind.h+7-6| ... | @@ -13,6 +13,7 @@ | ... | @@ -13,6 +13,7 @@ |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__functional/invoke.h> | 14 | #include <__functional/invoke.h> |
| 15 | #include <__functional/weak_result_type.h> | 15 | #include <__functional/weak_result_type.h> |
| 16 | #include <__fwd/functional.h> | ||
| 16 | #include <__type_traits/decay.h> | 17 | #include <__type_traits/decay.h> |
| 17 | #include <__type_traits/is_reference_wrapper.h> | 18 | #include <__type_traits/is_reference_wrapper.h> |
| 18 | #include <__type_traits/is_void.h> | 19 | #include <__type_traits/is_void.h> |
| ... | @@ -94,7 +95,7 @@ __mu(_Ti& __ti, tuple<_Uj...>& __uj) { | ... | @@ -94,7 +95,7 @@ __mu(_Ti& __ti, tuple<_Uj...>& __uj) { |
| 94 | return std::__mu_expand(__ti, __uj, __indices()); | 95 | return std::__mu_expand(__ti, __uj, __indices()); |
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | template <bool IsPh, class _Ti, class _Uj> | 98 | template <bool _IsPh, class _Ti, class _Uj> |
| 98 | struct __mu_return2 {}; | 99 | struct __mu_return2 {}; |
| 99 | 100 | ||
| 100 | template <class _Ti, class _Uj> | 101 | template <class _Ti, class _Uj> |
| ... | @@ -104,8 +105,8 @@ struct __mu_return2<true, _Ti, _Uj> { | ... | @@ -104,8 +105,8 @@ struct __mu_return2<true, _Ti, _Uj> { |
| 104 | 105 | ||
| 105 | template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0> | 106 | template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0> |
| 106 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 107 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 107 | typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type | 108 | typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type |
| 108 | __mu(_Ti&, _Uj& __uj) { | 109 | __mu(_Ti&, _Uj& __uj) { |
| 109 | const size_t __indx = is_placeholder<_Ti>::value - 1; | 110 | const size_t __indx = is_placeholder<_Ti>::value - 1; |
| 110 | return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj)); | 111 | return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj)); |
| 111 | } | 112 | } |
| ... | @@ -119,7 +120,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ti& __mu(_Ti& __ti, | ... | @@ -119,7 +120,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ti& __mu(_Ti& __ti, |
| 119 | return __ti; | 120 | return __ti; |
| 120 | } | 121 | } |
| 121 | 122 | ||
| 122 | template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, class _TupleUj> | 123 | template <class _Ti, bool _IsReferenceWrapper, bool _IsBindEx, bool _IsPh, class _TupleUj> |
| 123 | struct __mu_return_impl; | 124 | struct __mu_return_impl; |
| 124 | 125 | ||
| 125 | template <bool _Invokable, class _Ti, class... _Uj> | 126 | template <bool _Invokable, class _Ti, class... _Uj> |
| ... | @@ -224,8 +225,8 @@ public: | ... | @@ -224,8 +225,8 @@ public: |
| 224 | 225 | ||
| 225 | template <class... _Args> | 226 | template <class... _Args> |
| 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 227 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 227 | typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type | 228 | typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type |
| 228 | operator()(_Args&&... __args) const { | 229 | operator()(_Args&&... __args) const { |
| 229 | return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); | 230 | return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); |
| 230 | } | 231 | } |
| 231 | }; | 232 | }; |
lib/libcxx/include/__functional/bind_back.h+15-1| ... | @@ -52,7 +52,7 @@ struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs> | ... | @@ -52,7 +52,7 @@ struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs> |
| 52 | 52 | ||
| 53 | template <class _Fn, class... _Args> | 53 | template <class _Fn, class... _Args> |
| 54 | requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> && | 54 | requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> && |
| 55 | (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...) | 55 | (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...) |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) noexcept( | 56 | _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) noexcept( |
| 57 | noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>( | 57 | noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>( |
| 58 | std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...)))) | 58 | std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...)))) |
| ... | @@ -62,6 +62,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) n | ... | @@ -62,6 +62,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) n |
| 62 | std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...)); | 62 | std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...)); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | # if _LIBCPP_STD_VER >= 23 | ||
| 66 | template <class _Fn, class... _Args> | ||
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr auto bind_back(_Fn&& __f, _Args&&... __args) { | ||
| 68 | static_assert(is_constructible_v<decay_t<_Fn>, _Fn>, "bind_back requires decay_t<F> to be constructible from F"); | ||
| 69 | static_assert(is_move_constructible_v<decay_t<_Fn>>, "bind_back requires decay_t<F> to be move constructible"); | ||
| 70 | static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...), | ||
| 71 | "bind_back requires all decay_t<Args> to be constructible from respective Args"); | ||
| 72 | static_assert((is_move_constructible_v<decay_t<_Args>> && ...), | ||
| 73 | "bind_back requires all decay_t<Args> to be move constructible"); | ||
| 74 | return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>( | ||
| 75 | std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...)); | ||
| 76 | } | ||
| 77 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 78 | |||
| 65 | #endif // _LIBCPP_STD_VER >= 20 | 79 | #endif // _LIBCPP_STD_VER >= 20 |
| 66 | 80 | ||
| 67 | _LIBCPP_END_NAMESPACE_STD | 81 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__functional/bind_front.h+2-4| ... | @@ -17,7 +17,6 @@ | ... | @@ -17,7 +17,6 @@ |
| 17 | #include <__type_traits/decay.h> | 17 | #include <__type_traits/decay.h> |
| 18 | #include <__type_traits/enable_if.h> | 18 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/is_constructible.h> | 19 | #include <__type_traits/is_constructible.h> |
| 20 | #include <__type_traits/is_move_constructible.h> | ||
| 21 | #include <__utility/forward.h> | 20 | #include <__utility/forward.h> |
| 22 | 21 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -30,9 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -30,9 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 29 | ||
| 31 | struct __bind_front_op { | 30 | struct __bind_front_op { |
| 32 | template <class... _Args> | 31 | template <class... _Args> |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const | 32 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const noexcept( |
| 34 | noexcept(noexcept(std::invoke(std::forward<_Args>(__args)...))) | 33 | noexcept(std::invoke(std::forward<_Args>(__args)...))) -> decltype(std::invoke(std::forward<_Args>(__args)...)) { |
| 35 | -> decltype(std::invoke(std::forward<_Args>(__args)...)) { | ||
| 36 | return std::invoke(std::forward<_Args>(__args)...); | 34 | return std::invoke(std::forward<_Args>(__args)...); |
| 37 | } | 35 | } |
| 38 | }; | 36 | }; |
lib/libcxx/include/__functional/function.h+23-15| ... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
| 28 | #include <__type_traits/decay.h> | 28 | #include <__type_traits/decay.h> |
| 29 | #include <__type_traits/is_core_convertible.h> | 29 | #include <__type_traits/is_core_convertible.h> |
| 30 | #include <__type_traits/is_scalar.h> | 30 | #include <__type_traits/is_scalar.h> |
| 31 | #include <__type_traits/is_trivially_copy_constructible.h> | 31 | #include <__type_traits/is_trivially_constructible.h> |
| 32 | #include <__type_traits/is_trivially_destructible.h> | 32 | #include <__type_traits/is_trivially_destructible.h> |
| 33 | #include <__type_traits/is_void.h> | 33 | #include <__type_traits/is_void.h> |
| 34 | #include <__type_traits/strip_signature.h> | 34 | #include <__type_traits/strip_signature.h> |
| ... | @@ -55,7 +55,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -55,7 +55,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 55 | // bad_function_call | 55 | // bad_function_call |
| 56 | 56 | ||
| 57 | _LIBCPP_DIAGNOSTIC_PUSH | 57 | _LIBCPP_DIAGNOSTIC_PUSH |
| 58 | # if !_LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION | ||
| 58 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables") | 59 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables") |
| 60 | # endif | ||
| 59 | class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception { | 61 | class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception { |
| 60 | public: | 62 | public: |
| 61 | _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default; | 63 | _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default; |
| ... | @@ -64,7 +66,7 @@ public: | ... | @@ -64,7 +66,7 @@ public: |
| 64 | // Note that when a key function is not used, every translation unit that uses | 66 | // Note that when a key function is not used, every translation unit that uses |
| 65 | // bad_function_call will end up containing a weak definition of the vtable and | 67 | // bad_function_call will end up containing a weak definition of the vtable and |
| 66 | // typeinfo. | 68 | // typeinfo. |
| 67 | # ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | 69 | # if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION |
| 68 | ~bad_function_call() _NOEXCEPT override; | 70 | ~bad_function_call() _NOEXCEPT override; |
| 69 | # else | 71 | # else |
| 70 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {} | 72 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {} |
| ... | @@ -230,10 +232,10 @@ class _LIBCPP_TEMPLATE_VIS __base; | ... | @@ -230,10 +232,10 @@ class _LIBCPP_TEMPLATE_VIS __base; |
| 230 | 232 | ||
| 231 | template <class _Rp, class... _ArgTypes> | 233 | template <class _Rp, class... _ArgTypes> |
| 232 | class __base<_Rp(_ArgTypes...)> { | 234 | class __base<_Rp(_ArgTypes...)> { |
| 233 | __base(const __base&); | ||
| 234 | __base& operator=(const __base&); | ||
| 235 | |||
| 236 | public: | 235 | public: |
| 236 | __base(const __base&) = delete; | ||
| 237 | __base& operator=(const __base&) = delete; | ||
| 238 | |||
| 237 | _LIBCPP_HIDE_FROM_ABI __base() {} | 239 | _LIBCPP_HIDE_FROM_ABI __base() {} |
| 238 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {} | 240 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {} |
| 239 | virtual __base* __clone() const = 0; | 241 | virtual __base* __clone() const = 0; |
| ... | @@ -514,7 +516,7 @@ struct __policy { | ... | @@ -514,7 +516,7 @@ struct __policy { |
| 514 | } | 516 | } |
| 515 | 517 | ||
| 516 | _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() { | 518 | _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() { |
| 517 | static const _LIBCPP_CONSTEXPR __policy __policy = { | 519 | static constexpr __policy __policy = { |
| 518 | nullptr, | 520 | nullptr, |
| 519 | nullptr, | 521 | nullptr, |
| 520 | true, | 522 | true, |
| ... | @@ -541,7 +543,7 @@ private: | ... | @@ -541,7 +543,7 @@ private: |
| 541 | 543 | ||
| 542 | template <typename _Fun> | 544 | template <typename _Fun> |
| 543 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) { | 545 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) { |
| 544 | static const _LIBCPP_CONSTEXPR __policy __policy = { | 546 | static constexpr __policy __policy = { |
| 545 | &__large_clone<_Fun>, | 547 | &__large_clone<_Fun>, |
| 546 | &__large_destroy<_Fun>, | 548 | &__large_destroy<_Fun>, |
| 547 | false, | 549 | false, |
| ... | @@ -556,7 +558,7 @@ private: | ... | @@ -556,7 +558,7 @@ private: |
| 556 | 558 | ||
| 557 | template <typename _Fun> | 559 | template <typename _Fun> |
| 558 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ true_type) { | 560 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ true_type) { |
| 559 | static const _LIBCPP_CONSTEXPR __policy __policy = { | 561 | static constexpr __policy __policy = { |
| 560 | nullptr, | 562 | nullptr, |
| 561 | nullptr, | 563 | nullptr, |
| 562 | false, | 564 | false, |
| ... | @@ -768,7 +770,7 @@ public: | ... | @@ -768,7 +770,7 @@ public: |
| 768 | { | 770 | { |
| 769 | } | 771 | } |
| 770 | 772 | ||
| 771 | virtual __base<_Rp(_ArgTypes...)>* __clone() const { | 773 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const { |
| 772 | _LIBCPP_ASSERT_INTERNAL( | 774 | _LIBCPP_ASSERT_INTERNAL( |
| 773 | false, | 775 | false, |
| 774 | "Block pointers are just pointers, so they should always fit into " | 776 | "Block pointers are just pointers, so they should always fit into " |
| ... | @@ -777,9 +779,11 @@ public: | ... | @@ -777,9 +779,11 @@ public: |
| 777 | return nullptr; | 779 | return nullptr; |
| 778 | } | 780 | } |
| 779 | 781 | ||
| 780 | virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { ::new ((void*)__p) __func(__f_); } | 782 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { |
| 783 | ::new ((void*)__p) __func(__f_); | ||
| 784 | } | ||
| 781 | 785 | ||
| 782 | virtual void destroy() _NOEXCEPT { | 786 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT { |
| 783 | # ifndef _LIBCPP_HAS_OBJC_ARC | 787 | # ifndef _LIBCPP_HAS_OBJC_ARC |
| 784 | if (__f_) | 788 | if (__f_) |
| 785 | _Block_release(__f_); | 789 | _Block_release(__f_); |
| ... | @@ -787,7 +791,7 @@ public: | ... | @@ -787,7 +791,7 @@ public: |
| 787 | __f_ = 0; | 791 | __f_ = 0; |
| 788 | } | 792 | } |
| 789 | 793 | ||
| 790 | virtual void destroy_deallocate() _NOEXCEPT { | 794 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT { |
| 791 | _LIBCPP_ASSERT_INTERNAL( | 795 | _LIBCPP_ASSERT_INTERNAL( |
| 792 | false, | 796 | false, |
| 793 | "Block pointers are just pointers, so they should always fit into " | 797 | "Block pointers are just pointers, so they should always fit into " |
| ... | @@ -795,16 +799,20 @@ public: | ... | @@ -795,16 +799,20 @@ public: |
| 795 | "never be invoked."); | 799 | "never be invoked."); |
| 796 | } | 800 | } |
| 797 | 801 | ||
| 798 | virtual _Rp operator()(_ArgTypes&&... __arg) { return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...); } | 802 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg) { |
| 803 | return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...); | ||
| 804 | } | ||
| 799 | 805 | ||
| 800 | # ifndef _LIBCPP_HAS_NO_RTTI | 806 | # ifndef _LIBCPP_HAS_NO_RTTI |
| 801 | virtual const void* target(type_info const& __ti) const _NOEXCEPT { | 807 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT { |
| 802 | if (__ti == typeid(__func::__block_type)) | 808 | if (__ti == typeid(__func::__block_type)) |
| 803 | return &__f_; | 809 | return &__f_; |
| 804 | return (const void*)nullptr; | 810 | return (const void*)nullptr; |
| 805 | } | 811 | } |
| 806 | 812 | ||
| 807 | virtual const std::type_info& target_type() const _NOEXCEPT { return typeid(__func::__block_type); } | 813 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT { |
| 814 | return typeid(__func::__block_type); | ||
| 815 | } | ||
| 808 | # endif // _LIBCPP_HAS_NO_RTTI | 816 | # endif // _LIBCPP_HAS_NO_RTTI |
| 809 | }; | 817 | }; |
| 810 | 818 |
lib/libcxx/include/__functional/hash.h+4-9| ... | @@ -10,23 +10,18 @@ | ... | @@ -10,23 +10,18 @@ |
| 10 | #define _LIBCPP___FUNCTIONAL_HASH_H | 10 | #define _LIBCPP___FUNCTIONAL_HASH_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__functional/invoke.h> | ||
| 14 | #include <__functional/unary_function.h> | 13 | #include <__functional/unary_function.h> |
| 15 | #include <__fwd/hash.h> | 14 | #include <__fwd/functional.h> |
| 16 | #include <__tuple/sfinae_helpers.h> | 15 | #include <__type_traits/conjunction.h> |
| 17 | #include <__type_traits/is_copy_constructible.h> | 16 | #include <__type_traits/invoke.h> |
| 18 | #include <__type_traits/is_default_constructible.h> | 17 | #include <__type_traits/is_constructible.h> |
| 19 | #include <__type_traits/is_enum.h> | 18 | #include <__type_traits/is_enum.h> |
| 20 | #include <__type_traits/is_move_constructible.h> | ||
| 21 | #include <__type_traits/underlying_type.h> | 19 | #include <__type_traits/underlying_type.h> |
| 22 | #include <__utility/forward.h> | ||
| 23 | #include <__utility/move.h> | ||
| 24 | #include <__utility/pair.h> | 20 | #include <__utility/pair.h> |
| 25 | #include <__utility/swap.h> | 21 | #include <__utility/swap.h> |
| 26 | #include <cstddef> | 22 | #include <cstddef> |
| 27 | #include <cstdint> | 23 | #include <cstdint> |
| 28 | #include <cstring> | 24 | #include <cstring> |
| 29 | #include <limits> | ||
| 30 | 25 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 32 | # pragma GCC system_header | 27 | # pragma GCC system_header |
lib/libcxx/include/__functional/identity.h+2-2| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | #define _LIBCPP___FUNCTIONAL_IDENTITY_H | 11 | #define _LIBCPP___FUNCTIONAL_IDENTITY_H |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__functional/reference_wrapper.h> | 14 | #include <__fwd/functional.h> |
| 15 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 16 | #include <__utility/forward.h> | 16 | #include <__utility/forward.h> |
| 17 | 17 | ||
| ... | @@ -44,7 +44,7 @@ struct __is_identity<reference_wrapper<const __identity> > : true_type {}; | ... | @@ -44,7 +44,7 @@ struct __is_identity<reference_wrapper<const __identity> > : true_type {}; |
| 44 | 44 | ||
| 45 | struct identity { | 45 | struct identity { |
| 46 | template <class _Tp> | 46 | template <class _Tp> |
| 47 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept { | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept { |
| 48 | return std::forward<_Tp>(__t); | 48 | return std::forward<_Tp>(__t); |
| 49 | } | 49 | } |
| 50 | 50 |
lib/libcxx/include/__functional/is_transparent.h+2-3| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | #define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT | 11 | #define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | #include <__type_traits/void_t.h> | 14 | #include <__type_traits/void_t.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -23,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER >= 14 | 22 | #if _LIBCPP_STD_VER >= 14 |
| 24 | 23 | ||
| 25 | template <class _Tp, class, class = void> | 24 | template <class _Tp, class, class = void> |
| 26 | struct __is_transparent : false_type {}; | 25 | inline const bool __is_transparent_v = false; |
| 27 | 26 | ||
| 28 | template <class _Tp, class _Up> | 27 | template <class _Tp, class _Up> |
| 29 | struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> > : true_type {}; | 28 | inline const bool __is_transparent_v<_Tp, _Up, __void_t<typename _Tp::is_transparent> > = true; |
| 30 | 29 | ||
| 31 | #endif | 30 | #endif |
| 32 | 31 |
lib/libcxx/include/__functional/mem_fn.h+2-2| ... | @@ -38,8 +38,8 @@ public: | ... | @@ -38,8 +38,8 @@ public: |
| 38 | template <class... _ArgTypes> | 38 | template <class... _ArgTypes> |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 40 | 40 | ||
| 41 | typename __invoke_return<type, _ArgTypes...>::type | 41 | typename __invoke_return<type, _ArgTypes...>::type |
| 42 | operator()(_ArgTypes&&... __args) const { | 42 | operator()(_ArgTypes&&... __args) const { |
| 43 | return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...); | 43 | return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...); |
| 44 | } | 44 | } |
| 45 | }; | 45 | }; |
lib/libcxx/include/__functional/mem_fun_ref.h+2-2| ... | @@ -89,8 +89,8 @@ public: | ... | @@ -89,8 +89,8 @@ 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 _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t | 92 | class _LIBCPP_TEMPLATE_VIS |
| 93 | : 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; | 94 | _Sp (_Tp::*__p_)(_Ap) const; |
| 95 | 95 | ||
| 96 | public: | 96 | public: |
lib/libcxx/include/__functional/not_fn.h-1| ... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
| 16 | #include <__type_traits/decay.h> | 16 | #include <__type_traits/decay.h> |
| 17 | #include <__type_traits/enable_if.h> | 17 | #include <__type_traits/enable_if.h> |
| 18 | #include <__type_traits/is_constructible.h> | 18 | #include <__type_traits/is_constructible.h> |
| 19 | #include <__type_traits/is_move_constructible.h> | ||
| 20 | #include <__utility/forward.h> | 19 | #include <__utility/forward.h> |
| 21 | 20 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__functional/operations.h+49-41| ... | @@ -13,8 +13,7 @@ | ... | @@ -13,8 +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 <__type_traits/integral_constant.h> | 16 | #include <__type_traits/desugars_to.h> |
| 17 | #include <__type_traits/operation_traits.h> | ||
| 18 | #include <__utility/forward.h> | 17 | #include <__utility/forward.h> |
| 19 | 18 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -41,18 +40,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus); | ... | @@ -41,18 +40,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus); |
| 41 | // The non-transparent std::plus specialization is only equivalent to a raw plus | 40 | // The non-transparent std::plus specialization is only equivalent to a raw plus |
| 42 | // operator when we don't perform an implicit conversion when calling it. | 41 | // operator when we don't perform an implicit conversion when calling it. |
| 43 | template <class _Tp> | 42 | template <class _Tp> |
| 44 | struct __desugars_to<__plus_tag, plus<_Tp>, _Tp, _Tp> : true_type {}; | 43 | inline const bool __desugars_to_v<__plus_tag, plus<_Tp>, _Tp, _Tp> = true; |
| 45 | 44 | ||
| 46 | template <class _Tp, class _Up> | 45 | template <class _Tp, class _Up> |
| 47 | struct __desugars_to<__plus_tag, plus<void>, _Tp, _Up> : true_type {}; | 46 | inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true; |
| 48 | 47 | ||
| 49 | #if _LIBCPP_STD_VER >= 14 | 48 | #if _LIBCPP_STD_VER >= 14 |
| 50 | template <> | 49 | template <> |
| 51 | struct _LIBCPP_TEMPLATE_VIS plus<void> { | 50 | struct _LIBCPP_TEMPLATE_VIS plus<void> { |
| 52 | template <class _T1, class _T2> | 51 | template <class _T1, class _T2> |
| 53 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 52 | _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))) | 53 | noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) // |
| 55 | -> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) { | 54 | -> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) { |
| 56 | return std::forward<_T1>(__t) + std::forward<_T2>(__u); | 55 | return std::forward<_T1>(__t) + std::forward<_T2>(__u); |
| 57 | } | 56 | } |
| 58 | typedef void is_transparent; | 57 | typedef void is_transparent; |
| ... | @@ -77,8 +76,8 @@ template <> | ... | @@ -77,8 +76,8 @@ template <> |
| 77 | struct _LIBCPP_TEMPLATE_VIS minus<void> { | 76 | struct _LIBCPP_TEMPLATE_VIS minus<void> { |
| 78 | template <class _T1, class _T2> | 77 | template <class _T1, class _T2> |
| 79 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 78 | _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))) | 79 | noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) // |
| 81 | -> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) { | 80 | -> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) { |
| 82 | return std::forward<_T1>(__t) - std::forward<_T2>(__u); | 81 | return std::forward<_T1>(__t) - std::forward<_T2>(__u); |
| 83 | } | 82 | } |
| 84 | typedef void is_transparent; | 83 | typedef void is_transparent; |
| ... | @@ -103,8 +102,8 @@ template <> | ... | @@ -103,8 +102,8 @@ template <> |
| 103 | struct _LIBCPP_TEMPLATE_VIS multiplies<void> { | 102 | struct _LIBCPP_TEMPLATE_VIS multiplies<void> { |
| 104 | template <class _T1, class _T2> | 103 | template <class _T1, class _T2> |
| 105 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 104 | _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))) | 105 | noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) // |
| 107 | -> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) { | 106 | -> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) { |
| 108 | return std::forward<_T1>(__t) * std::forward<_T2>(__u); | 107 | return std::forward<_T1>(__t) * std::forward<_T2>(__u); |
| 109 | } | 108 | } |
| 110 | typedef void is_transparent; | 109 | typedef void is_transparent; |
| ... | @@ -129,8 +128,8 @@ template <> | ... | @@ -129,8 +128,8 @@ template <> |
| 129 | struct _LIBCPP_TEMPLATE_VIS divides<void> { | 128 | struct _LIBCPP_TEMPLATE_VIS divides<void> { |
| 130 | template <class _T1, class _T2> | 129 | template <class _T1, class _T2> |
| 131 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 130 | _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))) | 131 | noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) // |
| 133 | -> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) { | 132 | -> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) { |
| 134 | return std::forward<_T1>(__t) / std::forward<_T2>(__u); | 133 | return std::forward<_T1>(__t) / std::forward<_T2>(__u); |
| 135 | } | 134 | } |
| 136 | typedef void is_transparent; | 135 | typedef void is_transparent; |
| ... | @@ -155,8 +154,8 @@ template <> | ... | @@ -155,8 +154,8 @@ template <> |
| 155 | struct _LIBCPP_TEMPLATE_VIS modulus<void> { | 154 | struct _LIBCPP_TEMPLATE_VIS modulus<void> { |
| 156 | template <class _T1, class _T2> | 155 | template <class _T1, class _T2> |
| 157 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 156 | _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))) | 157 | noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) // |
| 159 | -> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) { | 158 | -> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) { |
| 160 | return std::forward<_T1>(__t) % std::forward<_T2>(__u); | 159 | return std::forward<_T1>(__t) % std::forward<_T2>(__u); |
| 161 | } | 160 | } |
| 162 | typedef void is_transparent; | 161 | typedef void is_transparent; |
| ... | @@ -179,7 +178,8 @@ template <> | ... | @@ -179,7 +178,8 @@ template <> |
| 179 | struct _LIBCPP_TEMPLATE_VIS negate<void> { | 178 | struct _LIBCPP_TEMPLATE_VIS negate<void> { |
| 180 | template <class _Tp> | 179 | template <class _Tp> |
| 181 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const | 180 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const |
| 182 | noexcept(noexcept(-std::forward<_Tp>(__x))) -> decltype(-std::forward<_Tp>(__x)) { | 181 | noexcept(noexcept(-std::forward<_Tp>(__x))) // |
| 182 | -> decltype(-std::forward<_Tp>(__x)) { | ||
| 183 | return -std::forward<_Tp>(__x); | 183 | return -std::forward<_Tp>(__x); |
| 184 | } | 184 | } |
| 185 | typedef void is_transparent; | 185 | typedef void is_transparent; |
| ... | @@ -206,8 +206,8 @@ template <> | ... | @@ -206,8 +206,8 @@ template <> |
| 206 | struct _LIBCPP_TEMPLATE_VIS bit_and<void> { | 206 | struct _LIBCPP_TEMPLATE_VIS bit_and<void> { |
| 207 | template <class _T1, class _T2> | 207 | template <class _T1, class _T2> |
| 208 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 208 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 209 | noexcept(noexcept(std::forward<_T1>(__t) & std::forward<_T2>(__u))) | 209 | noexcept(noexcept(std::forward<_T1>(__t) & |
| 210 | -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) { | 210 | std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) { |
| 211 | return std::forward<_T1>(__t) & std::forward<_T2>(__u); | 211 | return std::forward<_T1>(__t) & std::forward<_T2>(__u); |
| 212 | } | 212 | } |
| 213 | typedef void is_transparent; | 213 | typedef void is_transparent; |
| ... | @@ -225,7 +225,8 @@ template <> | ... | @@ -225,7 +225,8 @@ template <> |
| 225 | struct _LIBCPP_TEMPLATE_VIS bit_not<void> { | 225 | struct _LIBCPP_TEMPLATE_VIS bit_not<void> { |
| 226 | template <class _Tp> | 226 | template <class _Tp> |
| 227 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const | 227 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const |
| 228 | noexcept(noexcept(~std::forward<_Tp>(__x))) -> decltype(~std::forward<_Tp>(__x)) { | 228 | noexcept(noexcept(~std::forward<_Tp>(__x))) // |
| 229 | -> decltype(~std::forward<_Tp>(__x)) { | ||
| 229 | return ~std::forward<_Tp>(__x); | 230 | return ~std::forward<_Tp>(__x); |
| 230 | } | 231 | } |
| 231 | typedef void is_transparent; | 232 | typedef void is_transparent; |
| ... | @@ -250,8 +251,8 @@ template <> | ... | @@ -250,8 +251,8 @@ template <> |
| 250 | struct _LIBCPP_TEMPLATE_VIS bit_or<void> { | 251 | struct _LIBCPP_TEMPLATE_VIS bit_or<void> { |
| 251 | template <class _T1, class _T2> | 252 | template <class _T1, class _T2> |
| 252 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 253 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 253 | noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) | 254 | noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) // |
| 254 | -> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) { | 255 | -> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) { |
| 255 | return std::forward<_T1>(__t) | std::forward<_T2>(__u); | 256 | return std::forward<_T1>(__t) | std::forward<_T2>(__u); |
| 256 | } | 257 | } |
| 257 | typedef void is_transparent; | 258 | typedef void is_transparent; |
| ... | @@ -276,8 +277,8 @@ template <> | ... | @@ -276,8 +277,8 @@ template <> |
| 276 | struct _LIBCPP_TEMPLATE_VIS bit_xor<void> { | 277 | struct _LIBCPP_TEMPLATE_VIS bit_xor<void> { |
| 277 | template <class _T1, class _T2> | 278 | template <class _T1, class _T2> |
| 278 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 279 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 279 | noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) | 280 | noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) // |
| 280 | -> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) { | 281 | -> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) { |
| 281 | return std::forward<_T1>(__t) ^ std::forward<_T2>(__u); | 282 | return std::forward<_T1>(__t) ^ std::forward<_T2>(__u); |
| 282 | } | 283 | } |
| 283 | typedef void is_transparent; | 284 | typedef void is_transparent; |
| ... | @@ -304,8 +305,8 @@ template <> | ... | @@ -304,8 +305,8 @@ template <> |
| 304 | struct _LIBCPP_TEMPLATE_VIS equal_to<void> { | 305 | struct _LIBCPP_TEMPLATE_VIS equal_to<void> { |
| 305 | template <class _T1, class _T2> | 306 | template <class _T1, class _T2> |
| 306 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 307 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 307 | noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) | 308 | noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) // |
| 308 | -> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) { | 309 | -> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) { |
| 309 | return std::forward<_T1>(__t) == std::forward<_T2>(__u); | 310 | return std::forward<_T1>(__t) == std::forward<_T2>(__u); |
| 310 | } | 311 | } |
| 311 | typedef void is_transparent; | 312 | typedef void is_transparent; |
| ... | @@ -315,11 +316,11 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void> { | ... | @@ -315,11 +316,11 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void> { |
| 315 | // The non-transparent std::equal_to specialization is only equivalent to a raw equality | 316 | // The non-transparent std::equal_to specialization is only equivalent to a raw equality |
| 316 | // comparison when we don't perform an implicit conversion when calling it. | 317 | // comparison when we don't perform an implicit conversion when calling it. |
| 317 | template <class _Tp> | 318 | template <class _Tp> |
| 318 | struct __desugars_to<__equal_tag, equal_to<_Tp>, _Tp, _Tp> : true_type {}; | 319 | inline const bool __desugars_to_v<__equal_tag, equal_to<_Tp>, _Tp, _Tp> = true; |
| 319 | 320 | ||
| 320 | // In the transparent case, we do not enforce that | 321 | // In the transparent case, we do not enforce that |
| 321 | template <class _Tp, class _Up> | 322 | template <class _Tp, class _Up> |
| 322 | struct __desugars_to<__equal_tag, equal_to<void>, _Tp, _Up> : true_type {}; | 323 | inline const bool __desugars_to_v<__equal_tag, equal_to<void>, _Tp, _Up> = true; |
| 323 | 324 | ||
| 324 | #if _LIBCPP_STD_VER >= 14 | 325 | #if _LIBCPP_STD_VER >= 14 |
| 325 | template <class _Tp = void> | 326 | template <class _Tp = void> |
| ... | @@ -339,8 +340,8 @@ template <> | ... | @@ -339,8 +340,8 @@ template <> |
| 339 | struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> { | 340 | struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> { |
| 340 | template <class _T1, class _T2> | 341 | template <class _T1, class _T2> |
| 341 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 342 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 342 | noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) | 343 | noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) // |
| 343 | -> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) { | 344 | -> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) { |
| 344 | return std::forward<_T1>(__t) != std::forward<_T2>(__u); | 345 | return std::forward<_T1>(__t) != std::forward<_T2>(__u); |
| 345 | } | 346 | } |
| 346 | typedef void is_transparent; | 347 | typedef void is_transparent; |
| ... | @@ -360,17 +361,23 @@ struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> { | ... | @@ -360,17 +361,23 @@ struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> { |
| 360 | }; | 361 | }; |
| 361 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less); | 362 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less); |
| 362 | 363 | ||
| 364 | template <class _Tp> | ||
| 365 | inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true; | ||
| 366 | |||
| 363 | #if _LIBCPP_STD_VER >= 14 | 367 | #if _LIBCPP_STD_VER >= 14 |
| 364 | template <> | 368 | template <> |
| 365 | struct _LIBCPP_TEMPLATE_VIS less<void> { | 369 | struct _LIBCPP_TEMPLATE_VIS less<void> { |
| 366 | template <class _T1, class _T2> | 370 | template <class _T1, class _T2> |
| 367 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 371 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 368 | noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) | 372 | noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) // |
| 369 | -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) { | 373 | -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) { |
| 370 | return std::forward<_T1>(__t) < std::forward<_T2>(__u); | 374 | return std::forward<_T1>(__t) < std::forward<_T2>(__u); |
| 371 | } | 375 | } |
| 372 | typedef void is_transparent; | 376 | typedef void is_transparent; |
| 373 | }; | 377 | }; |
| 378 | |||
| 379 | template <class _Tp> | ||
| 380 | inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Tp> = true; | ||
| 374 | #endif | 381 | #endif |
| 375 | 382 | ||
| 376 | #if _LIBCPP_STD_VER >= 14 | 383 | #if _LIBCPP_STD_VER >= 14 |
| ... | @@ -391,8 +398,8 @@ template <> | ... | @@ -391,8 +398,8 @@ template <> |
| 391 | struct _LIBCPP_TEMPLATE_VIS less_equal<void> { | 398 | struct _LIBCPP_TEMPLATE_VIS less_equal<void> { |
| 392 | template <class _T1, class _T2> | 399 | template <class _T1, class _T2> |
| 393 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 400 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 394 | noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) | 401 | noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) // |
| 395 | -> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) { | 402 | -> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) { |
| 396 | return std::forward<_T1>(__t) <= std::forward<_T2>(__u); | 403 | return std::forward<_T1>(__t) <= std::forward<_T2>(__u); |
| 397 | } | 404 | } |
| 398 | typedef void is_transparent; | 405 | typedef void is_transparent; |
| ... | @@ -417,8 +424,8 @@ template <> | ... | @@ -417,8 +424,8 @@ template <> |
| 417 | struct _LIBCPP_TEMPLATE_VIS greater_equal<void> { | 424 | struct _LIBCPP_TEMPLATE_VIS greater_equal<void> { |
| 418 | template <class _T1, class _T2> | 425 | template <class _T1, class _T2> |
| 419 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 426 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 420 | noexcept(noexcept(std::forward<_T1>(__t) >= std::forward<_T2>(__u))) | 427 | noexcept(noexcept(std::forward<_T1>(__t) >= |
| 421 | -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) { | 428 | std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) { |
| 422 | return std::forward<_T1>(__t) >= std::forward<_T2>(__u); | 429 | return std::forward<_T1>(__t) >= std::forward<_T2>(__u); |
| 423 | } | 430 | } |
| 424 | typedef void is_transparent; | 431 | typedef void is_transparent; |
| ... | @@ -443,8 +450,8 @@ template <> | ... | @@ -443,8 +450,8 @@ template <> |
| 443 | struct _LIBCPP_TEMPLATE_VIS greater<void> { | 450 | struct _LIBCPP_TEMPLATE_VIS greater<void> { |
| 444 | template <class _T1, class _T2> | 451 | template <class _T1, class _T2> |
| 445 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 452 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 446 | noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) | 453 | noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) // |
| 447 | -> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) { | 454 | -> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) { |
| 448 | return std::forward<_T1>(__t) > std::forward<_T2>(__u); | 455 | return std::forward<_T1>(__t) > std::forward<_T2>(__u); |
| 449 | } | 456 | } |
| 450 | typedef void is_transparent; | 457 | typedef void is_transparent; |
| ... | @@ -471,8 +478,8 @@ template <> | ... | @@ -471,8 +478,8 @@ template <> |
| 471 | struct _LIBCPP_TEMPLATE_VIS logical_and<void> { | 478 | struct _LIBCPP_TEMPLATE_VIS logical_and<void> { |
| 472 | template <class _T1, class _T2> | 479 | template <class _T1, class _T2> |
| 473 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 480 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 474 | noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) | 481 | noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) // |
| 475 | -> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) { | 482 | -> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) { |
| 476 | return std::forward<_T1>(__t) && std::forward<_T2>(__u); | 483 | return std::forward<_T1>(__t) && std::forward<_T2>(__u); |
| 477 | } | 484 | } |
| 478 | typedef void is_transparent; | 485 | typedef void is_transparent; |
| ... | @@ -495,7 +502,8 @@ template <> | ... | @@ -495,7 +502,8 @@ template <> |
| 495 | struct _LIBCPP_TEMPLATE_VIS logical_not<void> { | 502 | struct _LIBCPP_TEMPLATE_VIS logical_not<void> { |
| 496 | template <class _Tp> | 503 | template <class _Tp> |
| 497 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const | 504 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const |
| 498 | noexcept(noexcept(!std::forward<_Tp>(__x))) -> decltype(!std::forward<_Tp>(__x)) { | 505 | noexcept(noexcept(!std::forward<_Tp>(__x))) // |
| 506 | -> decltype(!std::forward<_Tp>(__x)) { | ||
| 499 | return !std::forward<_Tp>(__x); | 507 | return !std::forward<_Tp>(__x); |
| 500 | } | 508 | } |
| 501 | typedef void is_transparent; | 509 | typedef void is_transparent; |
| ... | @@ -520,8 +528,8 @@ template <> | ... | @@ -520,8 +528,8 @@ template <> |
| 520 | struct _LIBCPP_TEMPLATE_VIS logical_or<void> { | 528 | struct _LIBCPP_TEMPLATE_VIS logical_or<void> { |
| 521 | template <class _T1, class _T2> | 529 | template <class _T1, class _T2> |
| 522 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 530 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 523 | noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) | 531 | noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) // |
| 524 | -> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) { | 532 | -> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) { |
| 525 | return std::forward<_T1>(__t) || std::forward<_T2>(__u); | 533 | return std::forward<_T1>(__t) || std::forward<_T2>(__u); |
| 526 | } | 534 | } |
| 527 | typedef void is_transparent; | 535 | typedef void is_transparent; |
lib/libcxx/include/__functional/pointer_to_binary_function.h+2-2| ... | @@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,8 @@ _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 _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function | 25 | class _LIBCPP_TEMPLATE_VIS |
| 26 | : 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); | 27 | _Result (*__f_)(_Arg1, _Arg2); |
| 28 | 28 | ||
| 29 | public: | 29 | public: |
lib/libcxx/include/__functional/pointer_to_unary_function.h+2-2| ... | @@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,8 @@ _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 _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function | 25 | class _LIBCPP_TEMPLATE_VIS |
| 26 | : public __unary_function<_Arg, _Result> { | 26 | _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> { |
| 27 | _Result (*__f_)(_Arg); | 27 | _Result (*__f_)(_Arg); |
| 28 | 28 | ||
| 29 | public: | 29 | public: |
lib/libcxx/include/__functional/ranges_operations.h+5-3| ... | @@ -13,8 +13,7 @@ | ... | @@ -13,8 +13,7 @@ |
| 13 | #include <__concepts/equality_comparable.h> | 13 | #include <__concepts/equality_comparable.h> |
| 14 | #include <__concepts/totally_ordered.h> | 14 | #include <__concepts/totally_ordered.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__type_traits/integral_constant.h> | 16 | #include <__type_traits/desugars_to.h> |
| 17 | #include <__type_traits/operation_traits.h> | ||
| 18 | #include <__utility/forward.h> | 17 | #include <__utility/forward.h> |
| 19 | 18 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -98,7 +97,10 @@ struct greater_equal { | ... | @@ -98,7 +97,10 @@ struct greater_equal { |
| 98 | // For ranges we do not require that the types on each side of the equality | 97 | // For ranges we do not require that the types on each side of the equality |
| 99 | // operator are of the same type | 98 | // operator are of the same type |
| 100 | template <class _Tp, class _Up> | 99 | template <class _Tp, class _Up> |
| 101 | struct __desugars_to<__equal_tag, ranges::equal_to, _Tp, _Up> : true_type {}; | 100 | inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true; |
| 101 | |||
| 102 | template <class _Tp, class _Up> | ||
| 103 | inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true; | ||
| 102 | 104 | ||
| 103 | #endif // _LIBCPP_STD_VER >= 20 | 105 | #endif // _LIBCPP_STD_VER >= 20 |
| 104 | 106 |
lib/libcxx/include/__functional/reference_wrapper.h+56-4| ... | @@ -10,12 +10,16 @@ | ... | @@ -10,12 +10,16 @@ |
| 10 | #ifndef _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H | 10 | #ifndef _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H |
| 11 | #define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H | 11 | #define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H |
| 12 | 12 | ||
| 13 | #include <__compare/synth_three_way.h> | ||
| 14 | #include <__concepts/boolean_testable.h> | ||
| 13 | #include <__config> | 15 | #include <__config> |
| 14 | #include <__functional/invoke.h> | 16 | #include <__functional/invoke.h> |
| 15 | #include <__functional/weak_result_type.h> | 17 | #include <__functional/weak_result_type.h> |
| 16 | #include <__memory/addressof.h> | 18 | #include <__memory/addressof.h> |
| 17 | #include <__type_traits/enable_if.h> | 19 | #include <__type_traits/enable_if.h> |
| 20 | #include <__type_traits/is_const.h> | ||
| 18 | #include <__type_traits/remove_cvref.h> | 21 | #include <__type_traits/remove_cvref.h> |
| 22 | #include <__type_traits/void_t.h> | ||
| 19 | #include <__utility/declval.h> | 23 | #include <__utility/declval.h> |
| 20 | #include <__utility/forward.h> | 24 | #include <__utility/forward.h> |
| 21 | 25 | ||
| ... | @@ -35,12 +39,12 @@ private: | ... | @@ -35,12 +39,12 @@ private: |
| 35 | type* __f_; | 39 | type* __f_; |
| 36 | 40 | ||
| 37 | static void __fun(_Tp&) _NOEXCEPT; | 41 | static void __fun(_Tp&) _NOEXCEPT; |
| 38 | static void __fun(_Tp&&) = delete; | 42 | static void __fun(_Tp&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276 |
| 39 | 43 | ||
| 40 | public: | 44 | public: |
| 41 | template < | 45 | template <class _Up, |
| 42 | class _Up, | 46 | class = __void_t<decltype(__fun(std::declval<_Up>()))>, |
| 43 | class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > > | 47 | __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, int> = 0> |
| 44 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u) | 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u) |
| 45 | _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) { | 49 | _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) { |
| 46 | type& __f = static_cast<_Up&&>(__u); | 50 | type& __f = static_cast<_Up&&>(__u); |
| ... | @@ -63,6 +67,54 @@ public: | ... | @@ -63,6 +67,54 @@ public: |
| 63 | { | 67 | { |
| 64 | return std::__invoke(get(), std::forward<_ArgTypes>(__args)...); | 68 | return std::__invoke(get(), std::forward<_ArgTypes>(__args)...); |
| 65 | } | 69 | } |
| 70 | |||
| 71 | #if _LIBCPP_STD_VER >= 26 | ||
| 72 | |||
| 73 | // [refwrap.comparisons], comparisons | ||
| 74 | |||
| 75 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y) | ||
| 76 | requires requires { | ||
| 77 | { __x.get() == __y.get() } -> __boolean_testable; | ||
| 78 | } | ||
| 79 | { | ||
| 80 | return __x.get() == __y.get(); | ||
| 81 | } | ||
| 82 | |||
| 83 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y) | ||
| 84 | requires requires { | ||
| 85 | { __x.get() == __y } -> __boolean_testable; | ||
| 86 | } | ||
| 87 | { | ||
| 88 | return __x.get() == __y; | ||
| 89 | } | ||
| 90 | |||
| 91 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y) | ||
| 92 | requires(!is_const_v<_Tp>) && requires { | ||
| 93 | { __x.get() == __y.get() } -> __boolean_testable; | ||
| 94 | } | ||
| 95 | { | ||
| 96 | return __x.get() == __y.get(); | ||
| 97 | } | ||
| 98 | |||
| 99 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y) | ||
| 100 | requires requires { std::__synth_three_way(__x.get(), __y.get()); } | ||
| 101 | { | ||
| 102 | return std::__synth_three_way(__x.get(), __y.get()); | ||
| 103 | } | ||
| 104 | |||
| 105 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, const _Tp& __y) | ||
| 106 | requires requires { std::__synth_three_way(__x.get(), __y); } | ||
| 107 | { | ||
| 108 | return std::__synth_three_way(__x.get(), __y); | ||
| 109 | } | ||
| 110 | |||
| 111 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y) | ||
| 112 | requires(!is_const_v<_Tp>) && requires { std::__synth_three_way(__x.get(), __y.get()); } | ||
| 113 | { | ||
| 114 | return std::__synth_three_way(__x.get(), __y.get()); | ||
| 115 | } | ||
| 116 | |||
| 117 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 66 | }; | 118 | }; |
| 67 | 119 | ||
| 68 | #if _LIBCPP_STD_VER >= 17 | 120 | #if _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/__functional/unary_negate.h+2-2| ... | @@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,8 @@ _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 unary_negate | 25 | class _LIBCPP_TEMPLATE_VIS |
| 26 | : 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_; | 27 | _Predicate __pred_; |
| 28 | 28 | ||
| 29 | public: | 29 | public: |
lib/libcxx/include/__fwd/array.h+20| ... | @@ -21,6 +21,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,6 +21,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | template <class _Tp, size_t _Size> | 21 | template <class _Tp, size_t _Size> |
| 22 | struct _LIBCPP_TEMPLATE_VIS array; | 22 | struct _LIBCPP_TEMPLATE_VIS array; |
| 23 | 23 | ||
| 24 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 25 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT; | ||
| 26 | |||
| 27 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT; | ||
| 29 | |||
| 30 | #ifndef _LIBCPP_CXX03_LANG | ||
| 31 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT; | ||
| 33 | |||
| 34 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 35 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT; | ||
| 36 | #endif | ||
| 37 | |||
| 38 | template <class> | ||
| 39 | struct __is_std_array : false_type {}; | ||
| 40 | |||
| 41 | template <class _Tp, size_t _Size> | ||
| 42 | struct __is_std_array<array<_Tp, _Size> > : true_type {}; | ||
| 43 | |||
| 24 | _LIBCPP_END_NAMESPACE_STD | 44 | _LIBCPP_END_NAMESPACE_STD |
| 25 | 45 | ||
| 26 | #endif // _LIBCPP___FWD_ARRAY_H | 46 | #endif // _LIBCPP___FWD_ARRAY_H |
lib/libcxx/include/__fwd/complex.h created+42| ... | @@ -0,0 +1,42 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_COMPLEX_H | ||
| 10 | #define _LIBCPP___FWD_COMPLEX_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <cstddef> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp> | ||
| 22 | class _LIBCPP_TEMPLATE_VIS complex; | ||
| 23 | |||
| 24 | #if _LIBCPP_STD_VER >= 26 | ||
| 25 | |||
| 26 | template <size_t _Ip, class _Tp> | ||
| 27 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(complex<_Tp>&) noexcept; | ||
| 28 | |||
| 29 | template <size_t _Ip, class _Tp> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(complex<_Tp>&&) noexcept; | ||
| 31 | |||
| 32 | template <size_t _Ip, class _Tp> | ||
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const complex<_Tp>&) noexcept; | ||
| 34 | |||
| 35 | template <size_t _Ip, class _Tp> | ||
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const complex<_Tp>&&) noexcept; | ||
| 37 | |||
| 38 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 39 | |||
| 40 | _LIBCPP_END_NAMESPACE_STD | ||
| 41 | |||
| 42 | #endif // _LIBCPP___FWD_COMPLEX_H | ||
lib/libcxx/include/__fwd/deque.h created+26| ... | @@ -0,0 +1,26 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_DEQUE_H | ||
| 10 | #define _LIBCPP___FWD_DEQUE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/memory.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp, class _Allocator = allocator<_Tp> > | ||
| 22 | class _LIBCPP_TEMPLATE_VIS deque; | ||
| 23 | |||
| 24 | _LIBCPP_END_NAMESPACE_STD | ||
| 25 | |||
| 26 | #endif // _LIBCPP___FWD_DEQUE_H | ||
lib/libcxx/include/__fwd/format.h created+38| ... | @@ -0,0 +1,38 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FWD_FORMAT_H | ||
| 11 | #define _LIBCPP___FWD_FORMAT_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__iterator/concepts.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | #if _LIBCPP_STD_VER >= 20 | ||
| 23 | |||
| 24 | template <class _Context> | ||
| 25 | class _LIBCPP_TEMPLATE_VIS basic_format_arg; | ||
| 26 | |||
| 27 | template <class _OutIt, class _CharT> | ||
| 28 | requires output_iterator<_OutIt, const _CharT&> | ||
| 29 | class _LIBCPP_TEMPLATE_VIS basic_format_context; | ||
| 30 | |||
| 31 | template <class _Tp, class _CharT = char> | ||
| 32 | struct _LIBCPP_TEMPLATE_VIS formatter; | ||
| 33 | |||
| 34 | #endif //_LIBCPP_STD_VER >= 20 | ||
| 35 | |||
| 36 | _LIBCPP_END_NAMESPACE_STD | ||
| 37 | |||
| 38 | #endif // _LIBCPP___FWD_FORMAT_H | ||
lib/libcxx/include/__fwd/functional.h created+28| ... | @@ -0,0 +1,28 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_FUNCTIONAL_H | ||
| 10 | #define _LIBCPP___FWD_FUNCTIONAL_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | template <class> | ||
| 21 | struct _LIBCPP_TEMPLATE_VIS hash; | ||
| 22 | |||
| 23 | template <class> | ||
| 24 | class _LIBCPP_TEMPLATE_VIS reference_wrapper; | ||
| 25 | |||
| 26 | _LIBCPP_END_NAMESPACE_STD | ||
| 27 | |||
| 28 | #endif // _LIBCPP___FWD_FUNCTIONAL_H | ||
lib/libcxx/include/__fwd/get.h deleted-99| ... | @@ -1,99 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_GET_H | ||
| 10 | #define _LIBCPP___FWD_GET_H | ||
| 11 | |||
| 12 | #include <__concepts/copyable.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__fwd/array.h> | ||
| 15 | #include <__fwd/pair.h> | ||
| 16 | #include <__fwd/subrange.h> | ||
| 17 | #include <__fwd/tuple.h> | ||
| 18 | #include <__tuple/tuple_element.h> | ||
| 19 | #include <cstddef> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | #ifndef _LIBCPP_CXX03_LANG | ||
| 28 | |||
| 29 | template <size_t _Ip, class... _Tp> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type& | ||
| 31 | get(tuple<_Tp...>&) _NOEXCEPT; | ||
| 32 | |||
| 33 | template <size_t _Ip, class... _Tp> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type& | ||
| 35 | get(const tuple<_Tp...>&) _NOEXCEPT; | ||
| 36 | |||
| 37 | template <size_t _Ip, class... _Tp> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&& | ||
| 39 | get(tuple<_Tp...>&&) _NOEXCEPT; | ||
| 40 | |||
| 41 | template <size_t _Ip, class... _Tp> | ||
| 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&& | ||
| 43 | get(const tuple<_Tp...>&&) _NOEXCEPT; | ||
| 44 | |||
| 45 | #endif //_LIBCPP_CXX03_LANG | ||
| 46 | |||
| 47 | template <size_t _Ip, class _T1, class _T2> | ||
| 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type& | ||
| 49 | get(pair<_T1, _T2>&) _NOEXCEPT; | ||
| 50 | |||
| 51 | template <size_t _Ip, class _T1, class _T2> | ||
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& | ||
| 53 | get(const pair<_T1, _T2>&) _NOEXCEPT; | ||
| 54 | |||
| 55 | #ifndef _LIBCPP_CXX03_LANG | ||
| 56 | template <size_t _Ip, class _T1, class _T2> | ||
| 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | ||
| 58 | get(pair<_T1, _T2>&&) _NOEXCEPT; | ||
| 59 | |||
| 60 | template <size_t _Ip, class _T1, class _T2> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | ||
| 62 | get(const pair<_T1, _T2>&&) _NOEXCEPT; | ||
| 63 | #endif | ||
| 64 | |||
| 65 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 66 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT; | ||
| 67 | |||
| 68 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 69 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT; | ||
| 70 | |||
| 71 | #ifndef _LIBCPP_CXX03_LANG | ||
| 72 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT; | ||
| 74 | |||
| 75 | template <size_t _Ip, class _Tp, size_t _Size> | ||
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT; | ||
| 77 | #endif | ||
| 78 | |||
| 79 | #if _LIBCPP_STD_VER >= 20 | ||
| 80 | |||
| 81 | namespace ranges { | ||
| 82 | |||
| 83 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> | ||
| 84 | requires((_Index == 0 && copyable<_Iter>) || _Index == 1) | ||
| 85 | _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange); | ||
| 86 | |||
| 87 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> | ||
| 88 | requires(_Index < 2) | ||
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange); | ||
| 90 | |||
| 91 | } // namespace ranges | ||
| 92 | |||
| 93 | using ranges::get; | ||
| 94 | |||
| 95 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 96 | |||
| 97 | _LIBCPP_END_NAMESPACE_STD | ||
| 98 | |||
| 99 | #endif // _LIBCPP___FWD_GET_H | ||
lib/libcxx/include/__fwd/hash.h deleted-25| ... | @@ -1,25 +0,0 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_HASH_H | ||
| 10 | #define _LIBCPP___FWD_HASH_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | template <class> | ||
| 21 | struct _LIBCPP_TEMPLATE_VIS hash; | ||
| 22 | |||
| 23 | _LIBCPP_END_NAMESPACE_STD | ||
| 24 | |||
| 25 | #endif // _LIBCPP___FWD_HASH_H | ||
lib/libcxx/include/__fwd/ios.h+2| ... | @@ -18,6 +18,8 @@ | ... | @@ -18,6 +18,8 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | class _LIBCPP_EXPORTED_FROM_ABI ios_base; | ||
| 22 | |||
| 21 | template <class _CharT, class _Traits = char_traits<_CharT> > | 23 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 22 | class _LIBCPP_TEMPLATE_VIS basic_ios; | 24 | class _LIBCPP_TEMPLATE_VIS basic_ios; |
| 23 | 25 |
lib/libcxx/include/__fwd/memory.h created+25| ... | @@ -0,0 +1,25 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_MEMORY_H | ||
| 10 | #define _LIBCPP___FWD_MEMORY_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | template <class _Tp> | ||
| 21 | class _LIBCPP_TEMPLATE_VIS allocator; | ||
| 22 | |||
| 23 | _LIBCPP_END_NAMESPACE_STD | ||
| 24 | |||
| 25 | #endif // _LIBCPP___FWD_MEMORY_H | ||
lib/libcxx/include/__fwd/memory_resource.h-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H | 9 | #ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H |
| 10 | #define _LIBCPP___FWD_MEMORY_RESOURCE_H | 10 | #define _LIBCPP___FWD_MEMORY_RESOURCE_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | 13 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__fwd/pair.h+20| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 10 | #define _LIBCPP___FWD_PAIR_H | 10 | #define _LIBCPP___FWD_PAIR_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__fwd/tuple.h> | ||
| 14 | #include <cstddef> | ||
| 13 | 15 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| ... | @@ -20,6 +22,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,6 +22,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | template <class, class> | 22 | template <class, class> |
| 21 | struct _LIBCPP_TEMPLATE_VIS pair; | 23 | struct _LIBCPP_TEMPLATE_VIS pair; |
| 22 | 24 | ||
| 25 | 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& | ||
| 27 | get(pair<_T1, _T2>&) _NOEXCEPT; | ||
| 28 | |||
| 29 | template <size_t _Ip, class _T1, class _T2> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& | ||
| 31 | get(const pair<_T1, _T2>&) _NOEXCEPT; | ||
| 32 | |||
| 33 | #ifndef _LIBCPP_CXX03_LANG | ||
| 34 | template <size_t _Ip, class _T1, class _T2> | ||
| 35 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | ||
| 36 | get(pair<_T1, _T2>&&) _NOEXCEPT; | ||
| 37 | |||
| 38 | template <size_t _Ip, class _T1, class _T2> | ||
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | ||
| 40 | get(const pair<_T1, _T2>&&) _NOEXCEPT; | ||
| 41 | #endif | ||
| 42 | |||
| 23 | _LIBCPP_END_NAMESPACE_STD | 43 | _LIBCPP_END_NAMESPACE_STD |
| 24 | 44 | ||
| 25 | #endif // _LIBCPP___FWD_PAIR_H | 45 | #endif // _LIBCPP___FWD_PAIR_H |
lib/libcxx/include/__fwd/queue.h created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_QUEUE_H | ||
| 10 | #define _LIBCPP___FWD_QUEUE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__functional/operations.h> | ||
| 14 | #include <__fwd/deque.h> | ||
| 15 | #include <__fwd/vector.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp, class _Container = deque<_Tp> > | ||
| 24 | class _LIBCPP_TEMPLATE_VIS queue; | ||
| 25 | |||
| 26 | template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > | ||
| 27 | class _LIBCPP_TEMPLATE_VIS priority_queue; | ||
| 28 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | ||
| 30 | |||
| 31 | #endif // _LIBCPP___FWD_QUEUE_H | ||
lib/libcxx/include/__fwd/sstream.h+1| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___FWD_SSTREAM_H | 10 | #define _LIBCPP___FWD_SSTREAM_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__fwd/memory.h> | ||
| 13 | #include <__fwd/string.h> | 14 | #include <__fwd/string.h> |
| 14 | 15 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__fwd/stack.h created+26| ... | @@ -0,0 +1,26 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_STACK_H | ||
| 10 | #define _LIBCPP___FWD_STACK_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/deque.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp, class _Container = deque<_Tp> > | ||
| 22 | class _LIBCPP_TEMPLATE_VIS stack; | ||
| 23 | |||
| 24 | _LIBCPP_END_NAMESPACE_STD | ||
| 25 | |||
| 26 | #endif // _LIBCPP___FWD_STACK_H | ||
lib/libcxx/include/__fwd/string.h+1-4| ... | @@ -9,8 +9,8 @@ | ... | @@ -9,8 +9,8 @@ |
| 9 | #ifndef _LIBCPP___FWD_STRING_H | 9 | #ifndef _LIBCPP___FWD_STRING_H |
| 10 | #define _LIBCPP___FWD_STRING_H | 10 | #define _LIBCPP___FWD_STRING_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__fwd/memory.h> | ||
| 14 | #include <__fwd/memory_resource.h> | 14 | #include <__fwd/memory_resource.h> |
| 15 | 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -39,9 +39,6 @@ template <> | ... | @@ -39,9 +39,6 @@ template <> |
| 39 | struct char_traits<wchar_t>; | 39 | struct char_traits<wchar_t>; |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | template <class _Tp> | ||
| 43 | class _LIBCPP_TEMPLATE_VIS allocator; | ||
| 44 | |||
| 45 | 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> > |
| 46 | class _LIBCPP_TEMPLATE_VIS basic_string; | 43 | class _LIBCPP_TEMPLATE_VIS basic_string; |
| 47 | 44 |
lib/libcxx/include/__fwd/subrange.h+13-2| ... | @@ -9,7 +9,10 @@ | ... | @@ -9,7 +9,10 @@ |
| 9 | #ifndef _LIBCPP___FWD_SUBRANGE_H | 9 | #ifndef _LIBCPP___FWD_SUBRANGE_H |
| 10 | #define _LIBCPP___FWD_SUBRANGE_H | 10 | #define _LIBCPP___FWD_SUBRANGE_H |
| 11 | 11 | ||
| 12 | #include <__concepts/copyable.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__iterator/concepts.h> | ||
| 15 | #include <cstddef> | ||
| 13 | 16 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # pragma GCC system_header | 18 | # pragma GCC system_header |
| ... | @@ -17,8 +20,6 @@ | ... | @@ -17,8 +20,6 @@ |
| 17 | 20 | ||
| 18 | #if _LIBCPP_STD_VER >= 20 | 21 | #if _LIBCPP_STD_VER >= 20 |
| 19 | 22 | ||
| 20 | # include <__iterator/concepts.h> | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | ||
| 24 | namespace ranges { | 25 | namespace ranges { |
| ... | @@ -29,8 +30,18 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_ki | ... | @@ -29,8 +30,18 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_ki |
| 29 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) | 30 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) |
| 30 | class _LIBCPP_TEMPLATE_VIS subrange; | 31 | class _LIBCPP_TEMPLATE_VIS subrange; |
| 31 | 32 | ||
| 33 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> | ||
| 34 | requires((_Index == 0 && copyable<_Iter>) || _Index == 1) | ||
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>&); | ||
| 36 | |||
| 37 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> | ||
| 38 | requires(_Index < 2) | ||
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&&); | ||
| 40 | |||
| 32 | } // namespace ranges | 41 | } // namespace ranges |
| 33 | 42 | ||
| 43 | using ranges::get; | ||
| 44 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | 45 | _LIBCPP_END_NAMESPACE_STD |
| 35 | 46 | ||
| 36 | #endif // _LIBCPP_STD_VER >= 20 | 47 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__fwd/tuple.h+23| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___FWD_TUPLE_H | 10 | #define _LIBCPP___FWD_TUPLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <cstddef> | ||
| 13 | 14 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -17,11 +18,33 @@ | ... | @@ -17,11 +18,33 @@ |
| 17 | 18 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 20 | ||
| 21 | template <size_t, class> | ||
| 22 | struct _LIBCPP_TEMPLATE_VIS tuple_element; | ||
| 23 | |||
| 20 | #ifndef _LIBCPP_CXX03_LANG | 24 | #ifndef _LIBCPP_CXX03_LANG |
| 21 | 25 | ||
| 22 | template <class...> | 26 | template <class...> |
| 23 | class _LIBCPP_TEMPLATE_VIS tuple; | 27 | class _LIBCPP_TEMPLATE_VIS tuple; |
| 24 | 28 | ||
| 29 | template <class> | ||
| 30 | struct _LIBCPP_TEMPLATE_VIS tuple_size; | ||
| 31 | |||
| 32 | template <size_t _Ip, class... _Tp> | ||
| 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type& | ||
| 34 | get(tuple<_Tp...>&) _NOEXCEPT; | ||
| 35 | |||
| 36 | template <size_t _Ip, class... _Tp> | ||
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type& | ||
| 38 | get(const tuple<_Tp...>&) _NOEXCEPT; | ||
| 39 | |||
| 40 | template <size_t _Ip, class... _Tp> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&& | ||
| 42 | get(tuple<_Tp...>&&) _NOEXCEPT; | ||
| 43 | |||
| 44 | template <size_t _Ip, class... _Tp> | ||
| 45 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&& | ||
| 46 | get(const tuple<_Tp...>&&) _NOEXCEPT; | ||
| 47 | |||
| 25 | #endif // _LIBCPP_CXX03_LANG | 48 | #endif // _LIBCPP_CXX03_LANG |
| 26 | 49 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__fwd/vector.h created+26| ... | @@ -0,0 +1,26 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_VECTOR_H | ||
| 10 | #define _LIBCPP___FWD_VECTOR_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/memory.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp, class _Alloc = allocator<_Tp> > | ||
| 22 | class _LIBCPP_TEMPLATE_VIS vector; | ||
| 23 | |||
| 24 | _LIBCPP_END_NAMESPACE_STD | ||
| 25 | |||
| 26 | #endif // _LIBCPP___FWD_VECTOR_H | ||
lib/libcxx/include/__hash_table+54-26| ... | @@ -28,12 +28,9 @@ | ... | @@ -28,12 +28,9 @@ |
| 28 | #include <__type_traits/can_extract_key.h> | 28 | #include <__type_traits/can_extract_key.h> |
| 29 | #include <__type_traits/conditional.h> | 29 | #include <__type_traits/conditional.h> |
| 30 | #include <__type_traits/is_const.h> | 30 | #include <__type_traits/is_const.h> |
| 31 | #include <__type_traits/is_copy_constructible.h> | 31 | #include <__type_traits/is_constructible.h> |
| 32 | #include <__type_traits/is_nothrow_assignable.h> | ||
| 32 | #include <__type_traits/is_nothrow_constructible.h> | 33 | #include <__type_traits/is_nothrow_constructible.h> |
| 33 | #include <__type_traits/is_nothrow_copy_constructible.h> | ||
| 34 | #include <__type_traits/is_nothrow_default_constructible.h> | ||
| 35 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 36 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 37 | #include <__type_traits/is_pointer.h> | 34 | #include <__type_traits/is_pointer.h> |
| 38 | #include <__type_traits/is_reference.h> | 35 | #include <__type_traits/is_reference.h> |
| 39 | #include <__type_traits/is_swappable.h> | 36 | #include <__type_traits/is_swappable.h> |
| ... | @@ -243,9 +240,9 @@ public: | ... | @@ -243,9 +240,9 @@ public: |
| 243 | 240 | ||
| 244 | private: | 241 | private: |
| 245 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); | 242 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); |
| 246 | static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value), | 243 | static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value, |
| 247 | "_VoidPtr does not point to unqualified void type"); | 244 | "_VoidPtr does not point to unqualified void type"); |
| 248 | static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value), | 245 | static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value, |
| 249 | "_VoidPtr does not rebind to _NodePtr."); | 246 | "_VoidPtr does not rebind to _NodePtr."); |
| 250 | }; | 247 | }; |
| 251 | 248 | ||
| ... | @@ -284,13 +281,21 @@ public: | ... | @@ -284,13 +281,21 @@ public: |
| 284 | 281 | ||
| 285 | _LIBCPP_HIDE_FROM_ABI __hash_iterator() _NOEXCEPT : __node_(nullptr) {} | 282 | _LIBCPP_HIDE_FROM_ABI __hash_iterator() _NOEXCEPT : __node_(nullptr) {} |
| 286 | 283 | ||
| 287 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); } | 284 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 285 | _LIBCPP_ASSERT_NON_NULL( | ||
| 286 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container iterator"); | ||
| 287 | return __node_->__upcast()->__get_value(); | ||
| 288 | } | ||
| 288 | 289 | ||
| 289 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 290 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { |
| 291 | _LIBCPP_ASSERT_NON_NULL( | ||
| 292 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container iterator"); | ||
| 290 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); | 293 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); |
| 291 | } | 294 | } |
| 292 | 295 | ||
| 293 | _LIBCPP_HIDE_FROM_ABI __hash_iterator& operator++() { | 296 | _LIBCPP_HIDE_FROM_ABI __hash_iterator& operator++() { |
| 297 | _LIBCPP_ASSERT_NON_NULL( | ||
| 298 | __node_ != nullptr, "Attempted to increment a non-incrementable unordered container iterator"); | ||
| 294 | __node_ = __node_->__next_; | 299 | __node_ = __node_->__next_; |
| 295 | return *this; | 300 | return *this; |
| 296 | } | 301 | } |
| ... | @@ -345,12 +350,20 @@ public: | ... | @@ -345,12 +350,20 @@ public: |
| 345 | 350 | ||
| 346 | _LIBCPP_HIDE_FROM_ABI __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) {} | 351 | _LIBCPP_HIDE_FROM_ABI __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) {} |
| 347 | 352 | ||
| 348 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); } | 353 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 354 | _LIBCPP_ASSERT_NON_NULL( | ||
| 355 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); | ||
| 356 | return __node_->__upcast()->__get_value(); | ||
| 357 | } | ||
| 349 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 358 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { |
| 359 | _LIBCPP_ASSERT_NON_NULL( | ||
| 360 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); | ||
| 350 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); | 361 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); |
| 351 | } | 362 | } |
| 352 | 363 | ||
| 353 | _LIBCPP_HIDE_FROM_ABI __hash_const_iterator& operator++() { | 364 | _LIBCPP_HIDE_FROM_ABI __hash_const_iterator& operator++() { |
| 365 | _LIBCPP_ASSERT_NON_NULL( | ||
| 366 | __node_ != nullptr, "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| 354 | __node_ = __node_->__next_; | 367 | __node_ = __node_->__next_; |
| 355 | return *this; | 368 | return *this; |
| 356 | } | 369 | } |
| ... | @@ -400,13 +413,21 @@ public: | ... | @@ -400,13 +413,21 @@ public: |
| 400 | 413 | ||
| 401 | _LIBCPP_HIDE_FROM_ABI __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {} | 414 | _LIBCPP_HIDE_FROM_ABI __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {} |
| 402 | 415 | ||
| 403 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); } | 416 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 417 | _LIBCPP_ASSERT_NON_NULL( | ||
| 418 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container local_iterator"); | ||
| 419 | return __node_->__upcast()->__get_value(); | ||
| 420 | } | ||
| 404 | 421 | ||
| 405 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 422 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { |
| 423 | _LIBCPP_ASSERT_NON_NULL( | ||
| 424 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container local_iterator"); | ||
| 406 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); | 425 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); |
| 407 | } | 426 | } |
| 408 | 427 | ||
| 409 | _LIBCPP_HIDE_FROM_ABI __hash_local_iterator& operator++() { | 428 | _LIBCPP_HIDE_FROM_ABI __hash_local_iterator& operator++() { |
| 429 | _LIBCPP_ASSERT_NON_NULL( | ||
| 430 | __node_ != nullptr, "Attempted to increment a non-incrementable unordered container local_iterator"); | ||
| 410 | __node_ = __node_->__next_; | 431 | __node_ = __node_->__next_; |
| 411 | if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) | 432 | if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) |
| 412 | __node_ = nullptr; | 433 | __node_ = nullptr; |
| ... | @@ -475,13 +496,21 @@ public: | ... | @@ -475,13 +496,21 @@ public: |
| 475 | __bucket_(__x.__bucket_), | 496 | __bucket_(__x.__bucket_), |
| 476 | __bucket_count_(__x.__bucket_count_) {} | 497 | __bucket_count_(__x.__bucket_count_) {} |
| 477 | 498 | ||
| 478 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); } | 499 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 500 | _LIBCPP_ASSERT_NON_NULL( | ||
| 501 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); | ||
| 502 | return __node_->__upcast()->__get_value(); | ||
| 503 | } | ||
| 479 | 504 | ||
| 480 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 505 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { |
| 506 | _LIBCPP_ASSERT_NON_NULL( | ||
| 507 | __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); | ||
| 481 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); | 508 | return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); |
| 482 | } | 509 | } |
| 483 | 510 | ||
| 484 | _LIBCPP_HIDE_FROM_ABI __hash_const_local_iterator& operator++() { | 511 | _LIBCPP_HIDE_FROM_ABI __hash_const_local_iterator& operator++() { |
| 512 | _LIBCPP_ASSERT_NON_NULL( | ||
| 513 | __node_ != nullptr, "Attempted to increment a non-incrementable unordered container const_local_iterator"); | ||
| 485 | __node_ = __node_->__next_; | 514 | __node_ = __node_->__next_; |
| 486 | if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) | 515 | if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) |
| 487 | __node_ = nullptr; | 516 | __node_ = nullptr; |
| ... | @@ -671,11 +700,11 @@ private: | ... | @@ -671,11 +700,11 @@ private: |
| 671 | // check for sane allocator pointer rebinding semantics. Rebinding the | 700 | // check for sane allocator pointer rebinding semantics. Rebinding the |
| 672 | // allocator for a new pointer type should be exactly the same as rebinding | 701 | // allocator for a new pointer type should be exactly the same as rebinding |
| 673 | // the pointer using 'pointer_traits'. | 702 | // the pointer using 'pointer_traits'. |
| 674 | static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value), | 703 | static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value, |
| 675 | "Allocator does not rebind pointers in a sane manner."); | 704 | "Allocator does not rebind pointers in a sane manner."); |
| 676 | typedef __rebind_alloc<__node_traits, __first_node> __node_base_allocator; | 705 | typedef __rebind_alloc<__node_traits, __first_node> __node_base_allocator; |
| 677 | typedef allocator_traits<__node_base_allocator> __node_base_traits; | 706 | typedef allocator_traits<__node_base_allocator> __node_base_traits; |
| 678 | static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value), | 707 | static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value, |
| 679 | "Allocator does not rebind pointers in a sane manner."); | 708 | "Allocator does not rebind pointers in a sane manner."); |
| 680 | 709 | ||
| 681 | private: | 710 | private: |
| ... | @@ -802,7 +831,7 @@ public: | ... | @@ -802,7 +831,7 @@ public: |
| 802 | return __emplace_unique_key_args(_NodeTypes::__get_key(__x), std::move(__x)); | 831 | return __emplace_unique_key_args(_NodeTypes::__get_key(__x), std::move(__x)); |
| 803 | } | 832 | } |
| 804 | 833 | ||
| 805 | template <class _Pp, class = __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value> > | 834 | template <class _Pp, __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value, int> = 0> |
| 806 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Pp&& __x) { | 835 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Pp&& __x) { |
| 807 | return __emplace_unique(std::forward<_Pp>(__x)); | 836 | return __emplace_unique(std::forward<_Pp>(__x)); |
| 808 | } | 837 | } |
| ... | @@ -899,13 +928,12 @@ public: | ... | @@ -899,13 +928,12 @@ public: |
| 899 | 928 | ||
| 900 | _LIBCPP_HIDE_FROM_ABI void swap(__hash_table& __u) | 929 | _LIBCPP_HIDE_FROM_ABI void swap(__hash_table& __u) |
| 901 | #if _LIBCPP_STD_VER <= 11 | 930 | #if _LIBCPP_STD_VER <= 11 |
| 902 | _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value && | 931 | _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> && |
| 903 | (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || | 932 | (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || |
| 904 | __is_nothrow_swappable<__pointer_allocator>::value) && | 933 | __is_nothrow_swappable_v<__pointer_allocator>) && |
| 905 | (!__node_traits::propagate_on_container_swap::value || | 934 | (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)); |
| 906 | __is_nothrow_swappable<__node_allocator>::value)); | ||
| 907 | #else | 935 | #else |
| 908 | _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value); | 936 | _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>); |
| 909 | #endif | 937 | #endif |
| 910 | 938 | ||
| 911 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return max_size(); } | 939 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return max_size(); } |
| ... | @@ -1072,8 +1100,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const | ... | @@ -1072,8 +1100,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const |
| 1072 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1100 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1073 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { | 1101 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { |
| 1074 | #if defined(_LIBCPP_CXX03_LANG) | 1102 | #if defined(_LIBCPP_CXX03_LANG) |
| 1075 | static_assert((is_copy_constructible<key_equal>::value), "Predicate must be copy-constructible."); | 1103 | static_assert(is_copy_constructible<key_equal>::value, "Predicate must be copy-constructible."); |
| 1076 | static_assert((is_copy_constructible<hasher>::value), "Hasher must be copy-constructible."); | 1104 | static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible."); |
| 1077 | #endif | 1105 | #endif |
| 1078 | 1106 | ||
| 1079 | __deallocate_node(__p1_.first().__next_); | 1107 | __deallocate_node(__p1_.first().__next_); |
| ... | @@ -1199,7 +1227,7 @@ template <class _InputIterator> | ... | @@ -1199,7 +1227,7 @@ template <class _InputIterator> |
| 1199 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, _InputIterator __last) { | 1227 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, _InputIterator __last) { |
| 1200 | typedef iterator_traits<_InputIterator> _ITraits; | 1228 | typedef iterator_traits<_InputIterator> _ITraits; |
| 1201 | typedef typename _ITraits::value_type _ItValueType; | 1229 | typedef typename _ITraits::value_type _ItValueType; |
| 1202 | static_assert((is_same<_ItValueType, __container_value_type>::value), | 1230 | static_assert(is_same<_ItValueType, __container_value_type>::value, |
| 1203 | "__assign_unique may only be called with the containers value type"); | 1231 | "__assign_unique may only be called with the containers value type"); |
| 1204 | 1232 | ||
| 1205 | if (bucket_count() != 0) { | 1233 | if (bucket_count() != 0) { |
| ... | @@ -1956,12 +1984,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(const _Key& __k) c | ... | @@ -1956,12 +1984,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(const _Key& __k) c |
| 1956 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1984 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1957 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) | 1985 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) |
| 1958 | #if _LIBCPP_STD_VER <= 11 | 1986 | #if _LIBCPP_STD_VER <= 11 |
| 1959 | _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value && | 1987 | _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> && |
| 1960 | (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || | 1988 | (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || |
| 1961 | __is_nothrow_swappable<__pointer_allocator>::value) && | 1989 | __is_nothrow_swappable_v<__pointer_allocator>) && |
| 1962 | (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value)) | 1990 | (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)) |
| 1963 | #else | 1991 | #else |
| 1964 | _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value) | 1992 | _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>) |
| 1965 | #endif | 1993 | #endif |
| 1966 | { | 1994 | { |
| 1967 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( | 1995 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( |
lib/libcxx/include/__iterator/access.h+2-2| ... | @@ -54,8 +54,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) -> | ... | @@ -54,8 +54,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) -> |
| 54 | # if _LIBCPP_STD_VER >= 14 | 54 | # if _LIBCPP_STD_VER >= 14 |
| 55 | 55 | ||
| 56 | template <class _Cp> | 56 | template <class _Cp> |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr auto cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c))) | 57 | _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 58 | -> decltype(std::begin(__c)) { | 58 | cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c))) -> decltype(std::begin(__c)) { |
| 59 | return std::begin(__c); | 59 | return std::begin(__c); |
| 60 | } | 60 | } |
| 61 | 61 |
lib/libcxx/include/__iterator/advance.h+3-3| ... | @@ -61,7 +61,7 @@ __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type _ | ... | @@ -61,7 +61,7 @@ __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type _ |
| 61 | template < class _InputIter, | 61 | template < class _InputIter, |
| 62 | class _Distance, | 62 | class _Distance, |
| 63 | class _IntegralDistance = decltype(std::__convert_to_integral(std::declval<_Distance>())), | 63 | class _IntegralDistance = decltype(std::__convert_to_integral(std::declval<_Distance>())), |
| 64 | class = __enable_if_t<is_integral<_IntegralDistance>::value> > | 64 | __enable_if_t<is_integral<_IntegralDistance>::value, int> = 0> |
| 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)); |
| ... | @@ -170,14 +170,14 @@ public: | ... | @@ -170,14 +170,14 @@ public: |
| 170 | } else { | 170 | } else { |
| 171 | // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at | 171 | // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at |
| 172 | // most `n` times. | 172 | // most `n` times. |
| 173 | while (__i != __bound_sentinel && __n > 0) { | 173 | while (__n > 0 && __i != __bound_sentinel) { |
| 174 | ++__i; | 174 | ++__i; |
| 175 | --__n; | 175 | --__n; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times. | 178 | // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times. |
| 179 | if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { | 179 | if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { |
| 180 | while (__i != __bound_sentinel && __n < 0) { | 180 | while (__n < 0 && __i != __bound_sentinel) { |
| 181 | --__i; | 181 | --__i; |
| 182 | ++__n; | 182 | ++__n; |
| 183 | } | 183 | } |
lib/libcxx/include/__iterator/aliasing_iterator.h created+127| ... | @@ -0,0 +1,127 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ITERATOR_ALIASING_ITERATOR_H | ||
| 10 | #define _LIBCPP___ITERATOR_ALIASING_ITERATOR_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__iterator/iterator_traits.h> | ||
| 14 | #include <__memory/pointer_traits.h> | ||
| 15 | #include <__type_traits/is_trivial.h> | ||
| 16 | #include <cstddef> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | // This iterator wrapper is used to type-pun an iterator to return a different type. This is done without UB by not | ||
| 23 | // actually punning the type, but instead inspecting the object representation of the base type and copying that into | ||
| 24 | // an instance of the alias type. For that reason the alias type has to be trivial. The alias is returned as a prvalue | ||
| 25 | // when derferencing the iterator, since it is temporary storage. This wrapper is used to vectorize some algorithms. | ||
| 26 | |||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 28 | |||
| 29 | template <class _BaseIter, class _Alias> | ||
| 30 | struct __aliasing_iterator_wrapper { | ||
| 31 | class __iterator { | ||
| 32 | _BaseIter __base_ = nullptr; | ||
| 33 | |||
| 34 | using __iter_traits = iterator_traits<_BaseIter>; | ||
| 35 | using __base_value_type = typename __iter_traits::value_type; | ||
| 36 | |||
| 37 | static_assert(__has_random_access_iterator_category<_BaseIter>::value, | ||
| 38 | "The base iterator has to be a random access iterator!"); | ||
| 39 | |||
| 40 | public: | ||
| 41 | using iterator_category = random_access_iterator_tag; | ||
| 42 | using value_type = _Alias; | ||
| 43 | using difference_type = ptrdiff_t; | ||
| 44 | using reference = value_type&; | ||
| 45 | using pointer = value_type*; | ||
| 46 | |||
| 47 | static_assert(is_trivial<value_type>::value); | ||
| 48 | static_assert(sizeof(__base_value_type) == sizeof(value_type)); | ||
| 49 | |||
| 50 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | ||
| 51 | _LIBCPP_HIDE_FROM_ABI __iterator(_BaseIter __base) _NOEXCEPT : __base_(__base) {} | ||
| 52 | |||
| 53 | _LIBCPP_HIDE_FROM_ABI __iterator& operator++() _NOEXCEPT { | ||
| 54 | ++__base_; | ||
| 55 | return *this; | ||
| 56 | } | ||
| 57 | |||
| 58 | _LIBCPP_HIDE_FROM_ABI __iterator operator++(int) _NOEXCEPT { | ||
| 59 | __iterator __tmp(*this); | ||
| 60 | ++__base_; | ||
| 61 | return __tmp; | ||
| 62 | } | ||
| 63 | |||
| 64 | _LIBCPP_HIDE_FROM_ABI __iterator& operator--() _NOEXCEPT { | ||
| 65 | --__base_; | ||
| 66 | return *this; | ||
| 67 | } | ||
| 68 | |||
| 69 | _LIBCPP_HIDE_FROM_ABI __iterator operator--(int) _NOEXCEPT { | ||
| 70 | __iterator __tmp(*this); | ||
| 71 | --__base_; | ||
| 72 | return __tmp; | ||
| 73 | } | ||
| 74 | |||
| 75 | _LIBCPP_HIDE_FROM_ABI friend __iterator operator+(__iterator __iter, difference_type __n) _NOEXCEPT { | ||
| 76 | return __iterator(__iter.__base_ + __n); | ||
| 77 | } | ||
| 78 | |||
| 79 | _LIBCPP_HIDE_FROM_ABI friend __iterator operator+(difference_type __n, __iterator __iter) _NOEXCEPT { | ||
| 80 | return __iterator(__n + __iter.__base_); | ||
| 81 | } | ||
| 82 | |||
| 83 | _LIBCPP_HIDE_FROM_ABI __iterator& operator+=(difference_type __n) _NOEXCEPT { | ||
| 84 | __base_ += __n; | ||
| 85 | return *this; | ||
| 86 | } | ||
| 87 | |||
| 88 | _LIBCPP_HIDE_FROM_ABI friend __iterator operator-(__iterator __iter, difference_type __n) _NOEXCEPT { | ||
| 89 | return __iterator(__iter.__base_ - __n); | ||
| 90 | } | ||
| 91 | |||
| 92 | _LIBCPP_HIDE_FROM_ABI friend difference_type operator-(__iterator __lhs, __iterator __rhs) _NOEXCEPT { | ||
| 93 | return __lhs.__base_ - __rhs.__base_; | ||
| 94 | } | ||
| 95 | |||
| 96 | _LIBCPP_HIDE_FROM_ABI __iterator& operator-=(difference_type __n) _NOEXCEPT { | ||
| 97 | __base_ -= __n; | ||
| 98 | return *this; | ||
| 99 | } | ||
| 100 | |||
| 101 | _LIBCPP_HIDE_FROM_ABI _BaseIter __base() const _NOEXCEPT { return __base_; } | ||
| 102 | |||
| 103 | _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT { | ||
| 104 | _Alias __val; | ||
| 105 | __builtin_memcpy(&__val, std::__to_address(__base_), sizeof(value_type)); | ||
| 106 | return __val; | ||
| 107 | } | ||
| 108 | |||
| 109 | _LIBCPP_HIDE_FROM_ABI value_type operator[](difference_type __n) const _NOEXCEPT { return *(*this + __n); } | ||
| 110 | |||
| 111 | _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __iterator& __lhs, const __iterator& __rhs) _NOEXCEPT { | ||
| 112 | return __lhs.__base_ == __rhs.__base_; | ||
| 113 | } | ||
| 114 | |||
| 115 | _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __iterator& __lhs, const __iterator& __rhs) _NOEXCEPT { | ||
| 116 | return __lhs.__base_ != __rhs.__base_; | ||
| 117 | } | ||
| 118 | }; | ||
| 119 | }; | ||
| 120 | |||
| 121 | // This is required to avoid ADL instantiations on _BaseT | ||
| 122 | template <class _BaseT, class _Alias> | ||
| 123 | using __aliasing_iterator = typename __aliasing_iterator_wrapper<_BaseT, _Alias>::__iterator; | ||
| 124 | |||
| 125 | _LIBCPP_END_NAMESPACE_STD | ||
| 126 | |||
| 127 | #endif // _LIBCPP___ITERATOR_ALIASING_ITERATOR_H | ||
lib/libcxx/include/__iterator/bounded_iter.h+74-27| ... | @@ -11,6 +11,8 @@ | ... | @@ -11,6 +11,8 @@ |
| 11 | #define _LIBCPP___ITERATOR_BOUNDED_ITER_H | 11 | #define _LIBCPP___ITERATOR_BOUNDED_ITER_H |
| 12 | 12 | ||
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__compare/ordering.h> | ||
| 15 | #include <__compare/three_way_comparable.h> | ||
| 14 | #include <__config> | 16 | #include <__config> |
| 15 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__memory/pointer_traits.h> | 18 | #include <__memory/pointer_traits.h> |
| ... | @@ -31,13 +33,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -31,13 +33,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | // Iterator wrapper that carries the valid range it is allowed to access. | 33 | // Iterator wrapper that carries the valid range it is allowed to access. |
| 32 | // | 34 | // |
| 33 | // This is a simple iterator wrapper for contiguous iterators that points | 35 | // This is a simple iterator wrapper for contiguous iterators that points |
| 34 | // within a [begin, end) range and carries these bounds with it. The iterator | 36 | // within a [begin, end] range and carries these bounds with it. The iterator |
| 35 | // ensures that it is pointing within that [begin, end) range when it is | 37 | // ensures that it is pointing within [begin, end) range when it is |
| 36 | // dereferenced. | 38 | // dereferenced. It also ensures that it is never iterated outside of |
| 39 | // [begin, end]. This is important for two reasons: | ||
| 37 | // | 40 | // |
| 38 | // Arithmetic operations are allowed and the bounds of the resulting iterator | 41 | // 1. It allows `operator*` and `operator++` bounds checks to be `iter != end`. |
| 39 | // are not checked. Hence, it is possible to create an iterator pointing outside | 42 | // This is both less for the optimizer to prove, and aligns with how callers |
| 40 | // its range, but it is not possible to dereference it. | 43 | // typically use iterators. |
| 44 | // | ||
| 45 | // 2. Advancing an iterator out of bounds is undefined behavior (see the table | ||
| 46 | // in [input.iterators]). In particular, when the underlying iterator is a | ||
| 47 | // pointer, it is undefined at the language level (see [expr.add]). If | ||
| 48 | // bounded iterators exhibited this undefined behavior, we risk compiler | ||
| 49 | // optimizations deleting non-redundant bounds checks. | ||
| 41 | template <class _Iterator, class = __enable_if_t< __libcpp_is_contiguous_iterator<_Iterator>::value > > | 50 | template <class _Iterator, class = __enable_if_t< __libcpp_is_contiguous_iterator<_Iterator>::value > > |
| 42 | struct __bounded_iter { | 51 | struct __bounded_iter { |
| 43 | using value_type = typename iterator_traits<_Iterator>::value_type; | 52 | using value_type = typename iterator_traits<_Iterator>::value_type; |
| ... | @@ -51,14 +60,14 @@ struct __bounded_iter { | ... | @@ -51,14 +60,14 @@ struct __bounded_iter { |
| 51 | 60 | ||
| 52 | // Create a singular iterator. | 61 | // Create a singular iterator. |
| 53 | // | 62 | // |
| 54 | // Such an iterator does not point to any object and is conceptually out of bounds, so it is | 63 | // Such an iterator points past the end of an empty span, so it is not dereferenceable. |
| 55 | // not dereferenceable. Observing operations like comparison and assignment are valid. | 64 | // Observing operations like comparison and assignment are valid. |
| 56 | _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default; | 65 | _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default; |
| 57 | 66 | ||
| 58 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default; | 67 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default; |
| 59 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default; | 68 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default; |
| 60 | 69 | ||
| 61 | template <class _OtherIterator, class = __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value > > | 70 | template <class _OtherIterator, __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value, int> = 0> |
| 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT | 71 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT |
| 63 | : __current_(__other.__current_), | 72 | : __current_(__other.__current_), |
| 64 | __begin_(__other.__begin_), | 73 | __begin_(__other.__begin_), |
| ... | @@ -70,18 +79,20 @@ struct __bounded_iter { | ... | @@ -70,18 +79,20 @@ struct __bounded_iter { |
| 70 | 79 | ||
| 71 | private: | 80 | private: |
| 72 | // Create an iterator wrapping the given iterator, and whose bounds are described | 81 | // Create an iterator wrapping the given iterator, and whose bounds are described |
| 73 | // by the provided [begin, end) range. | 82 | // by the provided [begin, end] range. |
| 74 | // | 83 | // |
| 75 | // This constructor does not check whether the resulting iterator is within its bounds. | 84 | // The constructor does not check whether the resulting iterator is within its bounds. It is a |
| 76 | // However, it does check that the provided [begin, end) range is a valid range (that | 85 | // responsibility of the container to ensure that the given bounds are valid. |
| 77 | // is, begin <= end). | ||
| 78 | // | 86 | // |
| 79 | // Since it is non-standard for iterators to have this constructor, __bounded_iter must | 87 | // Since it is non-standard for iterators to have this constructor, __bounded_iter must |
| 80 | // be created via `std::__make_bounded_iter`. | 88 | // be created via `std::__make_bounded_iter`. |
| 81 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __bounded_iter( | 89 | _LIBCPP_HIDE_FROM_ABI |
| 82 | _Iterator __current, _Iterator __begin, _Iterator __end) | 90 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __bounded_iter(_Iterator __current, _Iterator __begin, _Iterator __end) |
| 83 | : __current_(__current), __begin_(__begin), __end_(__end) { | 91 | : __current_(__current), __begin_(__begin), __end_(__end) { |
| 84 | _LIBCPP_ASSERT_INTERNAL(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range"); | 92 | _LIBCPP_ASSERT_INTERNAL( |
| 93 | __begin <= __current, "__bounded_iter(current, begin, end): current and begin are inconsistent"); | ||
| 94 | _LIBCPP_ASSERT_INTERNAL( | ||
| 95 | __current <= __end, "__bounded_iter(current, begin, end): current and end are inconsistent"); | ||
| 85 | } | 96 | } |
| 86 | 97 | ||
| 87 | template <class _It> | 98 | template <class _It> |
| ... | @@ -90,30 +101,37 @@ private: | ... | @@ -90,30 +101,37 @@ private: |
| 90 | public: | 101 | public: |
| 91 | // Dereference and indexing operations. | 102 | // Dereference and indexing operations. |
| 92 | // | 103 | // |
| 93 | // These operations check that the iterator is dereferenceable, that is within [begin, end). | 104 | // These operations check that the iterator is dereferenceable. Since the class invariant is |
| 105 | // that the iterator is always within `[begin, end]`, we only need to check it's not pointing to | ||
| 106 | // `end`. This is easier for the optimizer because it aligns with the `iter != container.end()` | ||
| 107 | // checks that typical callers already use (see | ||
| 108 | // https://github.com/llvm/llvm-project/issues/78829). | ||
| 94 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { | 109 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { |
| 95 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 110 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 96 | __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator"); | 111 | __current_ != __end_, "__bounded_iter::operator*: Attempt to dereference an iterator at the end"); |
| 97 | return *__current_; | 112 | return *__current_; |
| 98 | } | 113 | } |
| 99 | 114 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT { | 115 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT { |
| 101 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 116 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 102 | __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator"); | 117 | __current_ != __end_, "__bounded_iter::operator->: Attempt to dereference an iterator at the end"); |
| 103 | return std::__to_address(__current_); | 118 | return std::__to_address(__current_); |
| 104 | } | 119 | } |
| 105 | 120 | ||
| 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT { | 121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT { |
| 107 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 122 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 108 | __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range"); | 123 | __n >= __begin_ - __current_, "__bounded_iter::operator[]: Attempt to index an iterator past the start"); |
| 124 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 125 | __n < __end_ - __current_, "__bounded_iter::operator[]: Attempt to index an iterator at or past the end"); | ||
| 109 | return __current_[__n]; | 126 | return __current_[__n]; |
| 110 | } | 127 | } |
| 111 | 128 | ||
| 112 | // Arithmetic operations. | 129 | // Arithmetic operations. |
| 113 | // | 130 | // |
| 114 | // These operations do not check that the resulting iterator is within the bounds, since that | 131 | // These operations check that the iterator remains within `[begin, end]`. |
| 115 | // would make it impossible to create a past-the-end iterator. | ||
| 116 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator++() _NOEXCEPT { | 132 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator++() _NOEXCEPT { |
| 133 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 134 | __current_ != __end_, "__bounded_iter::operator++: Attempt to advance an iterator past the end"); | ||
| 117 | ++__current_; | 135 | ++__current_; |
| 118 | return *this; | 136 | return *this; |
| 119 | } | 137 | } |
| ... | @@ -124,6 +142,8 @@ public: | ... | @@ -124,6 +142,8 @@ public: |
| 124 | } | 142 | } |
| 125 | 143 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator--() _NOEXCEPT { | 144 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator--() _NOEXCEPT { |
| 145 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 146 | __current_ != __begin_, "__bounded_iter::operator--: Attempt to rewind an iterator past the start"); | ||
| 127 | --__current_; | 147 | --__current_; |
| 128 | return *this; | 148 | return *this; |
| 129 | } | 149 | } |
| ... | @@ -134,6 +154,10 @@ public: | ... | @@ -134,6 +154,10 @@ public: |
| 134 | } | 154 | } |
| 135 | 155 | ||
| 136 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT { | 156 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT { |
| 157 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 158 | __n >= __begin_ - __current_, "__bounded_iter::operator+=: Attempt to rewind an iterator past the start"); | ||
| 159 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 160 | __n <= __end_ - __current_, "__bounded_iter::operator+=: Attempt to advance an iterator past the end"); | ||
| 137 | __current_ += __n; | 161 | __current_ += __n; |
| 138 | return *this; | 162 | return *this; |
| 139 | } | 163 | } |
| ... | @@ -151,6 +175,10 @@ public: | ... | @@ -151,6 +175,10 @@ public: |
| 151 | } | 175 | } |
| 152 | 176 | ||
| 153 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT { | 177 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT { |
| 178 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 179 | __n <= __current_ - __begin_, "__bounded_iter::operator-=: Attempt to rewind an iterator past the start"); | ||
| 180 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 181 | __n >= __current_ - __end_, "__bounded_iter::operator-=: Attempt to advance an iterator past the end"); | ||
| 154 | __current_ -= __n; | 182 | __current_ -= __n; |
| 155 | return *this; | 183 | return *this; |
| 156 | } | 184 | } |
| ... | @@ -175,10 +203,15 @@ public: | ... | @@ -175,10 +203,15 @@ public: |
| 175 | operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | 203 | operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { |
| 176 | return __x.__current_ == __y.__current_; | 204 | return __x.__current_ == __y.__current_; |
| 177 | } | 205 | } |
| 206 | |||
| 207 | #if _LIBCPP_STD_VER <= 17 | ||
| 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | 208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool |
| 179 | operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | 209 | operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { |
| 180 | return __x.__current_ != __y.__current_; | 210 | return __x.__current_ != __y.__current_; |
| 181 | } | 211 | } |
| 212 | #endif | ||
| 213 | |||
| 214 | // TODO(mordante) disable these overloads in the LLVM 20 release. | ||
| 182 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool |
| 183 | operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | 216 | operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { |
| 184 | return __x.__current_ < __y.__current_; | 217 | return __x.__current_ < __y.__current_; |
| ... | @@ -196,16 +229,30 @@ public: | ... | @@ -196,16 +229,30 @@ public: |
| 196 | return __x.__current_ >= __y.__current_; | 229 | return __x.__current_ >= __y.__current_; |
| 197 | } | 230 | } |
| 198 | 231 | ||
| 199 | private: | 232 | #if _LIBCPP_STD_VER >= 20 |
| 200 | // Return whether the given iterator is in the bounds of this __bounded_iter. | 233 | _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering |
| 201 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Iterator const& __iter) const { | 234 | operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept { |
| 202 | return __iter >= __begin_ && __iter < __end_; | 235 | if constexpr (three_way_comparable<_Iterator, strong_ordering>) { |
| 236 | return __x.__current_ <=> __y.__current_; | ||
| 237 | } else { | ||
| 238 | if (__x.__current_ < __y.__current_) | ||
| 239 | return strong_ordering::less; | ||
| 240 | |||
| 241 | if (__x.__current_ == __y.__current_) | ||
| 242 | return strong_ordering::equal; | ||
| 243 | |||
| 244 | return strong_ordering::greater; | ||
| 245 | } | ||
| 203 | } | 246 | } |
| 247 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 204 | 248 | ||
| 249 | private: | ||
| 205 | template <class> | 250 | template <class> |
| 206 | friend struct pointer_traits; | 251 | friend struct pointer_traits; |
| 252 | template <class, class> | ||
| 253 | friend struct __bounded_iter; | ||
| 207 | _Iterator __current_; // current iterator | 254 | _Iterator __current_; // current iterator |
| 208 | _Iterator __begin_, __end_; // valid range represented as [begin, end) | 255 | _Iterator __begin_, __end_; // valid range represented as [begin, end] |
| 209 | }; | 256 | }; |
| 210 | 257 | ||
| 211 | template <class _It> | 258 | template <class _It> |
lib/libcxx/include/__iterator/common_iterator.h+1-1| ... | @@ -124,7 +124,7 @@ public: | ... | @@ -124,7 +124,7 @@ public: |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | template <class _I2 = _Iter> | 126 | template <class _I2 = _Iter> |
| 127 | _LIBCPP_HIDE_FROM_ABI decltype(auto) operator->() const | 127 | _LIBCPP_HIDE_FROM_ABI auto operator->() const |
| 128 | requires indirectly_readable<const _I2> && (requires(const _I2& __i) { | 128 | requires indirectly_readable<const _I2> && (requires(const _I2& __i) { |
| 129 | __i.operator->(); | 129 | __i.operator->(); |
| 130 | } || is_reference_v<iter_reference_t<_I2>> || constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>) | 130 | } || is_reference_v<iter_reference_t<_I2>> || constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>) |
lib/libcxx/include/__iterator/concepts.h+6-9| ... | @@ -177,19 +177,19 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip | ... | @@ -177,19 +177,19 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip |
| 177 | template <class _Fp, class _It> | 177 | template <class _Fp, class _It> |
| 178 | concept indirectly_unary_invocable = | 178 | concept indirectly_unary_invocable = |
| 179 | indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> && | 179 | indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> && |
| 180 | invocable<_Fp&, iter_reference_t<_It>> && invocable<_Fp&, iter_common_reference_t<_It>> && | 180 | invocable<_Fp&, iter_reference_t<_It>> && |
| 181 | common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>; | 181 | common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>; |
| 182 | 182 | ||
| 183 | template <class _Fp, class _It> | 183 | template <class _Fp, class _It> |
| 184 | concept indirectly_regular_unary_invocable = | 184 | concept indirectly_regular_unary_invocable = |
| 185 | indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> && | 185 | indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> && |
| 186 | regular_invocable<_Fp&, iter_reference_t<_It>> && regular_invocable<_Fp&, iter_common_reference_t<_It>> && | 186 | regular_invocable<_Fp&, iter_reference_t<_It>> && |
| 187 | common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>; | 187 | common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>; |
| 188 | 188 | ||
| 189 | template <class _Fp, class _It> | 189 | template <class _Fp, class _It> |
| 190 | concept indirect_unary_predicate = | 190 | concept indirect_unary_predicate = |
| 191 | indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> && | 191 | indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> && |
| 192 | predicate<_Fp&, iter_reference_t<_It>> && predicate<_Fp&, iter_common_reference_t<_It>>; | 192 | predicate<_Fp&, iter_reference_t<_It>>; |
| 193 | 193 | ||
| 194 | template <class _Fp, class _It1, class _It2> | 194 | template <class _Fp, class _It1, class _It2> |
| 195 | concept indirect_binary_predicate = | 195 | concept indirect_binary_predicate = |
| ... | @@ -197,8 +197,7 @@ concept indirect_binary_predicate = | ... | @@ -197,8 +197,7 @@ concept indirect_binary_predicate = |
| 197 | predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && | 197 | predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && |
| 198 | predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && | 198 | predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && |
| 199 | predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && | 199 | predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && |
| 200 | predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && | 200 | predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; |
| 201 | predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; | ||
| 202 | 201 | ||
| 203 | template <class _Fp, class _It1, class _It2 = _It1> | 202 | template <class _Fp, class _It1, class _It2 = _It1> |
| 204 | concept indirect_equivalence_relation = | 203 | concept indirect_equivalence_relation = |
| ... | @@ -206,8 +205,7 @@ concept indirect_equivalence_relation = | ... | @@ -206,8 +205,7 @@ concept indirect_equivalence_relation = |
| 206 | equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && | 205 | equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && |
| 207 | equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && | 206 | equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && |
| 208 | equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && | 207 | equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && |
| 209 | equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && | 208 | equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; |
| 210 | equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; | ||
| 211 | 209 | ||
| 212 | template <class _Fp, class _It1, class _It2 = _It1> | 210 | template <class _Fp, class _It1, class _It2 = _It1> |
| 213 | concept indirect_strict_weak_order = | 211 | concept indirect_strict_weak_order = |
| ... | @@ -215,8 +213,7 @@ concept indirect_strict_weak_order = | ... | @@ -215,8 +213,7 @@ concept indirect_strict_weak_order = |
| 215 | strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && | 213 | strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && |
| 216 | strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && | 214 | strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && |
| 217 | strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && | 215 | strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && |
| 218 | strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && | 216 | strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; |
| 219 | strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; | ||
| 220 | 217 | ||
| 221 | template <class _Fp, class... _Its> | 218 | template <class _Fp, class... _Its> |
| 222 | requires(indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> | 219 | requires(indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> |
lib/libcxx/include/__iterator/counted_iterator.h+1-1| ... | @@ -129,7 +129,7 @@ public: | ... | @@ -129,7 +129,7 @@ public: |
| 129 | return *this; | 129 | return *this; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | _LIBCPP_HIDE_FROM_ABI decltype(auto) operator++(int) { | 132 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) { |
| 133 | _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end."); | 133 | _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end."); |
| 134 | --__count_; | 134 | --__count_; |
| 135 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 135 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
lib/libcxx/include/__iterator/cpp17_iterator_concepts.h+22-22| ... | @@ -14,10 +14,8 @@ | ... | @@ -14,10 +14,8 @@ |
| 14 | #include <__concepts/same_as.h> | 14 | #include <__concepts/same_as.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__type_traits/is_constructible.h> | ||
| 17 | #include <__type_traits/is_convertible.h> | 18 | #include <__type_traits/is_convertible.h> |
| 18 | #include <__type_traits/is_copy_constructible.h> | ||
| 19 | #include <__type_traits/is_default_constructible.h> | ||
| 20 | #include <__type_traits/is_move_constructible.h> | ||
| 21 | #include <__type_traits/is_signed.h> | 19 | #include <__type_traits/is_signed.h> |
| 22 | #include <__type_traits/is_void.h> | 20 | #include <__type_traits/is_void.h> |
| 23 | #include <__utility/as_const.h> | 21 | #include <__utility/as_const.h> |
| ... | @@ -70,7 +68,7 @@ concept __cpp17_default_constructible = is_default_constructible_v<_Tp>; | ... | @@ -70,7 +68,7 @@ concept __cpp17_default_constructible = is_default_constructible_v<_Tp>; |
| 70 | template <class _Iter> | 68 | template <class _Iter> |
| 71 | concept __cpp17_iterator = | 69 | concept __cpp17_iterator = |
| 72 | __cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> && | 70 | __cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> && |
| 73 | (is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>)&&requires(_Iter __iter) { | 71 | (is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>) && requires(_Iter __iter) { |
| 74 | { *__iter }; | 72 | { *__iter }; |
| 75 | { ++__iter } -> same_as<_Iter&>; | 73 | { ++__iter } -> same_as<_Iter&>; |
| 76 | }; | 74 | }; |
| ... | @@ -159,29 +157,31 @@ concept __cpp17_random_access_iterator = | ... | @@ -159,29 +157,31 @@ concept __cpp17_random_access_iterator = |
| 159 | _LIBCPP_END_NAMESPACE_STD | 157 | _LIBCPP_END_NAMESPACE_STD |
| 160 | 158 | ||
| 161 | # ifndef _LIBCPP_DISABLE_ITERATOR_CHECKS | 159 | # ifndef _LIBCPP_DISABLE_ITERATOR_CHECKS |
| 162 | # define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t) static_assert(::std::__cpp17_input_iterator<iter_t>); | 160 | # define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) \ |
| 163 | # define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t) \ | 161 | static_assert(::std::__cpp17_input_iterator<iter_t>, message) |
| 164 | static_assert(::std::__cpp17_output_iterator<iter_t, write_t>); | 162 | # define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) \ |
| 165 | # define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t) static_assert(::std::__cpp17_forward_iterator<iter_t>); | 163 | static_assert(::std::__cpp17_output_iterator<iter_t, write_t>, message) |
| 166 | # define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t) \ | 164 | # define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) \ |
| 167 | static_assert(::std::__cpp17_bidirectional_iterator<iter_t>); | 165 | static_assert(::std::__cpp17_forward_iterator<iter_t>, message) |
| 168 | # define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t) \ | 166 | # define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) \ |
| 169 | static_assert(::std::__cpp17_random_access_iterator<iter_t>); | 167 | static_assert(::std::__cpp17_bidirectional_iterator<iter_t>, message) |
| 168 | # define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) \ | ||
| 169 | static_assert(::std::__cpp17_random_access_iterator<iter_t>, message) | ||
| 170 | # else | 170 | # else |
| 171 | # define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t) | 171 | # define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) static_assert(true) |
| 172 | # define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t) | 172 | # define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) static_assert(true) |
| 173 | # define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t) | 173 | # define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) static_assert(true) |
| 174 | # define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t) | 174 | # define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) static_assert(true) |
| 175 | # define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t) | 175 | # define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) static_assert(true) |
| 176 | # endif | 176 | # endif |
| 177 | 177 | ||
| 178 | #else // _LIBCPP_STD_VER >= 20 | 178 | #else // _LIBCPP_STD_VER >= 20 |
| 179 | 179 | ||
| 180 | # define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t) | 180 | # define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) static_assert(true) |
| 181 | # define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t) | 181 | # define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) static_assert(true) |
| 182 | # define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t) | 182 | # define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) static_assert(true) |
| 183 | # define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t) | 183 | # define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) static_assert(true) |
| 184 | # define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t) | 184 | # define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) static_assert(true) |
| 185 | 185 | ||
| 186 | #endif // _LIBCPP_STD_VER >= 20 | 186 | #endif // _LIBCPP_STD_VER >= 20 |
| 187 | 187 |
lib/libcxx/include/__iterator/data.h+2-2| ... | @@ -23,12 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,12 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER >= 17 | 23 | #if _LIBCPP_STD_VER >= 17 |
| 24 | 24 | ||
| 25 | template <class _Cont> | 25 | template <class _Cont> |
| 26 | constexpr _LIBCPP_HIDE_FROM_ABI auto data(_Cont& __c) _NOEXCEPT_(noexcept(__c.data())) -> decltype(__c.data()) { | 26 | constexpr _LIBCPP_HIDE_FROM_ABI auto data(_Cont& __c) noexcept(noexcept(__c.data())) -> decltype(__c.data()) { |
| 27 | return __c.data(); | 27 | return __c.data(); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | template <class _Cont> | 30 | template <class _Cont> |
| 31 | constexpr _LIBCPP_HIDE_FROM_ABI auto data(const _Cont& __c) _NOEXCEPT_(noexcept(__c.data())) -> decltype(__c.data()) { | 31 | constexpr _LIBCPP_HIDE_FROM_ABI auto data(const _Cont& __c) noexcept(noexcept(__c.data())) -> decltype(__c.data()) { |
| 32 | return __c.data(); | 32 | return __c.data(); |
| 33 | } | 33 | } |
| 34 | 34 |
lib/libcxx/include/__iterator/empty.h+4-4| ... | @@ -23,18 +23,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,18 +23,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER >= 17 | 23 | #if _LIBCPP_STD_VER >= 17 |
| 24 | 24 | ||
| 25 | template <class _Cont> | 25 | template <class _Cont> |
| 26 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI constexpr auto empty(const _Cont& __c) | 26 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 27 | _NOEXCEPT_(noexcept(__c.empty())) -> decltype(__c.empty()) { | 27 | empty(const _Cont& __c) noexcept(noexcept(__c.empty())) -> decltype(__c.empty()) { |
| 28 | return __c.empty(); | 28 | return __c.empty(); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | template <class _Tp, size_t _Sz> | 31 | template <class _Tp, size_t _Sz> |
| 32 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI constexpr bool empty(const _Tp (&)[_Sz]) noexcept { | 32 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty(const _Tp (&)[_Sz]) noexcept { |
| 33 | return false; | 33 | return false; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | template <class _Ep> | 36 | template <class _Ep> |
| 37 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI constexpr bool empty(initializer_list<_Ep> __il) noexcept { | 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty(initializer_list<_Ep> __il) noexcept { |
| 38 | return __il.size() == 0; | 38 | return __il.size() == 0; |
| 39 | } | 39 | } |
| 40 | 40 |
lib/libcxx/include/__iterator/iter_move.h+1-1| ... | @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | namespace ranges { | 35 | namespace ranges { |
| 36 | namespace __iter_move { | 36 | namespace __iter_move { |
| 37 | 37 | ||
| 38 | void iter_move(); | 38 | void iter_move() = delete; |
| 39 | 39 | ||
| 40 | template <class _Tp> | 40 | template <class _Tp> |
| 41 | concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) { | 41 | concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) { |
lib/libcxx/include/__iterator/iter_swap.h+1-1| ... | @@ -42,7 +42,7 @@ void iter_swap(_I1, _I2) = delete; | ... | @@ -42,7 +42,7 @@ void iter_swap(_I1, _I2) = delete; |
| 42 | 42 | ||
| 43 | template <class _T1, class _T2> | 43 | template <class _T1, class _T2> |
| 44 | concept __unqualified_iter_swap = | 44 | concept __unqualified_iter_swap = |
| 45 | (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>)&&requires(_T1&& __x, _T2&& __y) { | 45 | (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) && requires(_T1&& __x, _T2&& __y) { |
| 46 | // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap | 46 | // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap |
| 47 | iter_swap(std::forward<_T1>(__x), std::forward<_T2>(__y)); | 47 | iter_swap(std::forward<_T1>(__x), std::forward<_T2>(__y)); |
| 48 | }; | 48 | }; |
lib/libcxx/include/__iterator/iterator_traits.h+2-3| ... | @@ -21,7 +21,6 @@ | ... | @@ -21,7 +21,6 @@ |
| 21 | #include <__fwd/pair.h> | 21 | #include <__fwd/pair.h> |
| 22 | #include <__iterator/incrementable_traits.h> | 22 | #include <__iterator/incrementable_traits.h> |
| 23 | #include <__iterator/readable_traits.h> | 23 | #include <__iterator/readable_traits.h> |
| 24 | #include <__type_traits/add_const.h> | ||
| 25 | #include <__type_traits/common_reference.h> | 24 | #include <__type_traits/common_reference.h> |
| 26 | #include <__type_traits/conditional.h> | 25 | #include <__type_traits/conditional.h> |
| 27 | #include <__type_traits/disjunction.h> | 26 | #include <__type_traits/disjunction.h> |
| ... | @@ -493,8 +492,8 @@ using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type: | ... | @@ -493,8 +492,8 @@ using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type: |
| 493 | 492 | ||
| 494 | template <class _InputIterator> | 493 | template <class _InputIterator> |
| 495 | using __iter_to_alloc_type = | 494 | using __iter_to_alloc_type = |
| 496 | pair< typename add_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type, | 495 | pair<const typename iterator_traits<_InputIterator>::value_type::first_type, |
| 497 | typename iterator_traits<_InputIterator>::value_type::second_type>; | 496 | typename iterator_traits<_InputIterator>::value_type::second_type>; |
| 498 | 497 | ||
| 499 | template <class _Iter> | 498 | template <class _Iter> |
| 500 | using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category; | 499 | using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category; |
lib/libcxx/include/__iterator/move_iterator.h+14-9| ... | @@ -105,9 +105,8 @@ public: | ... | @@ -105,9 +105,8 @@ public: |
| 105 | typedef iterator_type pointer; | 105 | typedef iterator_type pointer; |
| 106 | 106 | ||
| 107 | typedef typename iterator_traits<iterator_type>::reference __reference; | 107 | typedef typename iterator_traits<iterator_type>::reference __reference; |
| 108 | typedef typename conditional< is_reference<__reference>::value, | 108 | typedef __conditional_t<is_reference<__reference>::value, __libcpp_remove_reference_t<__reference>&&, __reference> |
| 109 | __libcpp_remove_reference_t<__reference>&&, | 109 | reference; |
| 110 | __reference >::type reference; | ||
| 111 | #endif // _LIBCPP_STD_VER >= 20 | 110 | #endif // _LIBCPP_STD_VER >= 20 |
| 112 | 111 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {} | 112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {} |
| ... | @@ -157,14 +156,14 @@ public: | ... | @@ -157,14 +156,14 @@ public: |
| 157 | #else | 156 | #else |
| 158 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator() : __current_() {} | 157 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator() : __current_() {} |
| 159 | 158 | ||
| 160 | template <class _Up, | 159 | template <class _Up, __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value, int> = 0> |
| 161 | class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value > > | ||
| 162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator(const move_iterator<_Up>& __u) | 160 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator(const move_iterator<_Up>& __u) |
| 163 | : __current_(__u.base()) {} | 161 | : __current_(__u.base()) {} |
| 164 | 162 | ||
| 165 | template <class _Up, | 163 | template <class _Up, |
| 166 | class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value && | 164 | __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value && |
| 167 | is_assignable<_Iter&, const _Up&>::value > > | 165 | is_assignable<_Iter&, const _Up&>::value, |
| 166 | int> = 0> | ||
| 168 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator& operator=(const move_iterator<_Up>& __u) { | 167 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator& operator=(const move_iterator<_Up>& __u) { |
| 169 | __current_ = __u.base(); | 168 | __current_ = __u.base(); |
| 170 | return *this; | 169 | return *this; |
| ... | @@ -292,8 +291,8 @@ operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { | ... | @@ -292,8 +291,8 @@ operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { |
| 292 | #if _LIBCPP_STD_VER >= 20 | 291 | #if _LIBCPP_STD_VER >= 20 |
| 293 | template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2> | 292 | template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2> |
| 294 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto | 293 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 295 | operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | 294 | operator<=>(const move_iterator<_Iter1>& __x, |
| 296 | -> compare_three_way_result_t<_Iter1, _Iter2> { | 295 | const move_iterator<_Iter2>& __y) -> compare_three_way_result_t<_Iter1, _Iter2> { |
| 297 | return __x.base() <=> __y.base(); | 296 | return __x.base() <=> __y.base(); |
| 298 | } | 297 | } |
| 299 | #endif // _LIBCPP_STD_VER >= 20 | 298 | #endif // _LIBCPP_STD_VER >= 20 |
| ... | @@ -330,6 +329,12 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato | ... | @@ -330,6 +329,12 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato |
| 330 | } | 329 | } |
| 331 | #endif // _LIBCPP_STD_VER >= 20 | 330 | #endif // _LIBCPP_STD_VER >= 20 |
| 332 | 331 | ||
| 332 | #if _LIBCPP_STD_VER >= 20 | ||
| 333 | template <class _Iter1, class _Iter2> | ||
| 334 | requires(!sized_sentinel_for<_Iter1, _Iter2>) | ||
| 335 | inline constexpr bool disable_sized_sentinel_for<move_iterator<_Iter1>, move_iterator<_Iter2>> = true; | ||
| 336 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 337 | |||
| 333 | template <class _Iter> | 338 | template <class _Iter> |
| 334 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) { | 339 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) { |
| 335 | return move_iterator<_Iter>(std::move(__i)); | 340 | return move_iterator<_Iter>(std::move(__i)); |
lib/libcxx/include/__iterator/ranges_iterator_traits.h+1-3| ... | @@ -13,7 +13,6 @@ | ... | @@ -13,7 +13,6 @@ |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__fwd/pair.h> | 14 | #include <__fwd/pair.h> |
| 15 | #include <__ranges/concepts.h> | 15 | #include <__ranges/concepts.h> |
| 16 | #include <__type_traits/add_const.h> | ||
| 17 | #include <__type_traits/remove_const.h> | 16 | #include <__type_traits/remove_const.h> |
| 18 | 17 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -32,8 +31,7 @@ using __range_mapped_type = typename ranges::range_value_t<_Range>::second_type; | ... | @@ -32,8 +31,7 @@ using __range_mapped_type = typename ranges::range_value_t<_Range>::second_type; |
| 32 | 31 | ||
| 33 | template <ranges::input_range _Range> | 32 | template <ranges::input_range _Range> |
| 34 | using __range_to_alloc_type = | 33 | using __range_to_alloc_type = |
| 35 | pair<add_const_t<typename ranges::range_value_t<_Range>::first_type>, | 34 | pair<const typename ranges::range_value_t<_Range>::first_type, typename ranges::range_value_t<_Range>::second_type>; |
| 36 | typename ranges::range_value_t<_Range>::second_type>; | ||
| 37 | 35 | ||
| 38 | #endif | 36 | #endif |
| 39 | 37 |
lib/libcxx/include/__iterator/reverse_iterator.h+26-197| ... | @@ -34,7 +34,7 @@ | ... | @@ -34,7 +34,7 @@ |
| 34 | #include <__type_traits/enable_if.h> | 34 | #include <__type_traits/enable_if.h> |
| 35 | #include <__type_traits/is_assignable.h> | 35 | #include <__type_traits/is_assignable.h> |
| 36 | #include <__type_traits/is_convertible.h> | 36 | #include <__type_traits/is_convertible.h> |
| 37 | #include <__type_traits/is_nothrow_copy_constructible.h> | 37 | #include <__type_traits/is_nothrow_constructible.h> |
| 38 | #include <__type_traits/is_pointer.h> | 38 | #include <__type_traits/is_pointer.h> |
| 39 | #include <__type_traits/is_same.h> | 39 | #include <__type_traits/is_same.h> |
| 40 | #include <__utility/declval.h> | 40 | #include <__utility/declval.h> |
| ... | @@ -96,14 +96,14 @@ public: | ... | @@ -96,14 +96,14 @@ public: |
| 96 | 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {} | 97 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {} |
| 98 | 98 | ||
| 99 | template <class _Up, | 99 | template <class _Up, __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value, int> = 0> |
| 100 | class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value > > | ||
| 101 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator(const reverse_iterator<_Up>& __u) | 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator(const reverse_iterator<_Up>& __u) |
| 102 | : __t_(__u.base()), current(__u.base()) {} | 101 | : __t_(__u.base()), current(__u.base()) {} |
| 103 | 102 | ||
| 104 | template <class _Up, | 103 | template <class _Up, |
| 105 | class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value && | 104 | __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value && |
| 106 | is_assignable<_Iter&, _Up const&>::value > > | 105 | is_assignable<_Iter&, _Up const&>::value, |
| 106 | int> = 0> | ||
| 107 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { | 107 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { |
| 108 | __t_ = current = __u.base(); | 108 | __t_ = current = __u.base(); |
| 109 | return *this; | 109 | return *this; |
| ... | @@ -113,14 +113,14 @@ public: | ... | @@ -113,14 +113,14 @@ public: |
| 113 | 113 | ||
| 114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : current(__x) {} | 114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : current(__x) {} |
| 115 | 115 | ||
| 116 | template <class _Up, | 116 | template <class _Up, __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value, int> = 0> |
| 117 | class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value > > | ||
| 118 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator(const reverse_iterator<_Up>& __u) | 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator(const reverse_iterator<_Up>& __u) |
| 119 | : current(__u.base()) {} | 118 | : current(__u.base()) {} |
| 120 | 119 | ||
| 121 | template <class _Up, | 120 | template <class _Up, |
| 122 | class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value && | 121 | __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value && |
| 123 | is_assignable<_Iter&, _Up const&>::value > > | 122 | is_assignable<_Iter&, _Up const&>::value, |
| 123 | int> = 0> | ||
| 124 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { | 124 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { |
| 125 | current = __u.base(); | 125 | current = __u.base(); |
| 126 | return *this; | 126 | return *this; |
| ... | @@ -184,7 +184,7 @@ public: | ... | @@ -184,7 +184,7 @@ public: |
| 184 | 184 | ||
| 185 | #if _LIBCPP_STD_VER >= 20 | 185 | #if _LIBCPP_STD_VER >= 20 |
| 186 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i) noexcept( | 186 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i) noexcept( |
| 187 | is_nothrow_copy_constructible_v<_Iter>&& noexcept(ranges::iter_move(--std::declval<_Iter&>()))) { | 187 | is_nothrow_copy_constructible_v<_Iter> && noexcept(ranges::iter_move(--std::declval<_Iter&>()))) { |
| 188 | auto __tmp = __i.base(); | 188 | auto __tmp = __i.base(); |
| 189 | return ranges::iter_move(--__tmp); | 189 | return ranges::iter_move(--__tmp); |
| 190 | } | 190 | } |
| ... | @@ -192,9 +192,8 @@ public: | ... | @@ -192,9 +192,8 @@ public: |
| 192 | template <indirectly_swappable<_Iter> _Iter2> | 192 | template <indirectly_swappable<_Iter> _Iter2> |
| 193 | _LIBCPP_HIDE_FROM_ABI friend constexpr void | 193 | _LIBCPP_HIDE_FROM_ABI friend constexpr void |
| 194 | iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y) noexcept( | 194 | iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y) noexcept( |
| 195 | is_nothrow_copy_constructible_v<_Iter> && | 195 | is_nothrow_copy_constructible_v<_Iter> && is_nothrow_copy_constructible_v<_Iter2> && |
| 196 | is_nothrow_copy_constructible_v<_Iter2>&& noexcept( | 196 | noexcept(ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) { |
| 197 | ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) { | ||
| 198 | auto __xtmp = __x.base(); | 197 | auto __xtmp = __x.base(); |
| 199 | auto __ytmp = __y.base(); | 198 | auto __ytmp = __y.base(); |
| 200 | ranges::iter_swap(--__xtmp, --__ytmp); | 199 | ranges::iter_swap(--__xtmp, --__ytmp); |
| ... | @@ -285,8 +284,8 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& | ... | @@ -285,8 +284,8 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& |
| 285 | #ifndef _LIBCPP_CXX03_LANG | 284 | #ifndef _LIBCPP_CXX03_LANG |
| 286 | template <class _Iter1, class _Iter2> | 285 | template <class _Iter1, class _Iter2> |
| 287 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto | 286 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto |
| 288 | operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) | 287 | operator-(const reverse_iterator<_Iter1>& __x, |
| 289 | -> decltype(__y.base() - __x.base()) { | 288 | const reverse_iterator<_Iter2>& __y) -> decltype(__y.base() - __x.base()) { |
| 290 | return __y.base() - __x.base(); | 289 | return __y.base() - __x.base(); |
| 291 | } | 290 | } |
| 292 | #else | 291 | #else |
| ... | @@ -316,172 +315,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Ite | ... | @@ -316,172 +315,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Ite |
| 316 | } | 315 | } |
| 317 | #endif | 316 | #endif |
| 318 | 317 | ||
| 319 | #if _LIBCPP_STD_VER <= 17 | ||
| 320 | template <class _Iter> | ||
| 321 | using __unconstrained_reverse_iterator = reverse_iterator<_Iter>; | ||
| 322 | #else | ||
| 323 | |||
| 324 | // __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working | ||
| 325 | // around a language issue in C++20. | ||
| 326 | // In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will | ||
| 327 | // result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not | ||
| 328 | // an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a | ||
| 329 | // C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with | ||
| 330 | // tweaks to make it support hostile iterators. | ||
| 331 | // | ||
| 332 | // A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match | ||
| 333 | // and the other requires an implicit conversion, for example: | ||
| 334 | // friend bool operator==(const BaseIter&, const DerivedIter&); | ||
| 335 | // | ||
| 336 | // C++20 rules for rewriting equality operators create another overload of this function with parameters reversed: | ||
| 337 | // friend bool operator==(const DerivedIter&, const BaseIter&); | ||
| 338 | // | ||
| 339 | // This creates an ambiguity in overload resolution. | ||
| 340 | // | ||
| 341 | // Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function | ||
| 342 | // body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however, | ||
| 343 | // it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its | ||
| 344 | // base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload | ||
| 345 | // resolution. This class simply removes the problematic constraints from comparison functions. | ||
| 346 | template <class _Iter> | ||
| 347 | class __unconstrained_reverse_iterator { | ||
| 348 | _Iter __iter_; | ||
| 349 | |||
| 350 | public: | ||
| 351 | static_assert(__has_bidirectional_iterator_category<_Iter>::value || bidirectional_iterator<_Iter>); | ||
| 352 | |||
| 353 | using iterator_type = _Iter; | ||
| 354 | using iterator_category = | ||
| 355 | _If<__has_random_access_iterator_category<_Iter>::value, | ||
| 356 | random_access_iterator_tag, | ||
| 357 | __iterator_category_type<_Iter>>; | ||
| 358 | using pointer = __iterator_pointer_type<_Iter>; | ||
| 359 | using value_type = iter_value_t<_Iter>; | ||
| 360 | using difference_type = iter_difference_t<_Iter>; | ||
| 361 | using reference = iter_reference_t<_Iter>; | ||
| 362 | |||
| 363 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator() = default; | ||
| 364 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator&) = default; | ||
| 365 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __unconstrained_reverse_iterator(_Iter __iter) : __iter_(__iter) {} | ||
| 366 | |||
| 367 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() const { return __iter_; } | ||
| 368 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const { | ||
| 369 | auto __tmp = __iter_; | ||
| 370 | return *--__tmp; | ||
| 371 | } | ||
| 372 | |||
| 373 | _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const { | ||
| 374 | if constexpr (is_pointer_v<_Iter>) { | ||
| 375 | return std::prev(__iter_); | ||
| 376 | } else { | ||
| 377 | return std::prev(__iter_).operator->(); | ||
| 378 | } | ||
| 379 | } | ||
| 380 | |||
| 381 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> | ||
| 382 | iter_move(const __unconstrained_reverse_iterator& __i) noexcept( | ||
| 383 | is_nothrow_copy_constructible_v<_Iter>&& noexcept(ranges::iter_move(--std::declval<_Iter&>()))) { | ||
| 384 | auto __tmp = __i.base(); | ||
| 385 | return ranges::iter_move(--__tmp); | ||
| 386 | } | ||
| 387 | |||
| 388 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() { | ||
| 389 | --__iter_; | ||
| 390 | return *this; | ||
| 391 | } | ||
| 392 | |||
| 393 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator++(int) { | ||
| 394 | auto __tmp = *this; | ||
| 395 | --__iter_; | ||
| 396 | return __tmp; | ||
| 397 | } | ||
| 398 | |||
| 399 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator--() { | ||
| 400 | ++__iter_; | ||
| 401 | return *this; | ||
| 402 | } | ||
| 403 | |||
| 404 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator--(int) { | ||
| 405 | auto __tmp = *this; | ||
| 406 | ++__iter_; | ||
| 407 | return __tmp; | ||
| 408 | } | ||
| 409 | |||
| 410 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator+=(difference_type __n) { | ||
| 411 | __iter_ -= __n; | ||
| 412 | return *this; | ||
| 413 | } | ||
| 414 | |||
| 415 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator-=(difference_type __n) { | ||
| 416 | __iter_ += __n; | ||
| 417 | return *this; | ||
| 418 | } | ||
| 419 | |||
| 420 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator+(difference_type __n) const { | ||
| 421 | return __unconstrained_reverse_iterator(__iter_ - __n); | ||
| 422 | } | ||
| 423 | |||
| 424 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator-(difference_type __n) const { | ||
| 425 | return __unconstrained_reverse_iterator(__iter_ + __n); | ||
| 426 | } | ||
| 427 | |||
| 428 | _LIBCPP_HIDE_FROM_ABI constexpr difference_type operator-(const __unconstrained_reverse_iterator& __other) const { | ||
| 429 | return __other.__iter_ - __iter_; | ||
| 430 | } | ||
| 431 | |||
| 432 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const { return *(*this + __n); } | ||
| 433 | |||
| 434 | // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the | ||
| 435 | // rationale. | ||
| 436 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 437 | operator==(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | ||
| 438 | return __lhs.base() == __rhs.base(); | ||
| 439 | } | ||
| 440 | |||
| 441 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 442 | operator!=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | ||
| 443 | return __lhs.base() != __rhs.base(); | ||
| 444 | } | ||
| 445 | |||
| 446 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 447 | operator<(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | ||
| 448 | return __lhs.base() > __rhs.base(); | ||
| 449 | } | ||
| 450 | |||
| 451 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 452 | operator>(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | ||
| 453 | return __lhs.base() < __rhs.base(); | ||
| 454 | } | ||
| 455 | |||
| 456 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 457 | operator<=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | ||
| 458 | return __lhs.base() >= __rhs.base(); | ||
| 459 | } | ||
| 460 | |||
| 461 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 462 | operator>=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | ||
| 463 | return __lhs.base() <= __rhs.base(); | ||
| 464 | } | ||
| 465 | }; | ||
| 466 | |||
| 467 | #endif // _LIBCPP_STD_VER <= 17 | ||
| 468 | |||
| 469 | template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter> | ||
| 470 | struct __unwrap_reverse_iter_impl { | ||
| 471 | using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>())); | ||
| 472 | using _ReverseWrapper = _RevIter1<_RevIter2<_Iter> >; | ||
| 473 | |||
| 474 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper | ||
| 475 | __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) { | ||
| 476 | return _ReverseWrapper( | ||
| 477 | _RevIter2<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter))); | ||
| 478 | } | ||
| 479 | |||
| 480 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT { | ||
| 481 | return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base()); | ||
| 482 | } | ||
| 483 | }; | ||
| 484 | |||
| 485 | #if _LIBCPP_STD_VER >= 20 | 318 | #if _LIBCPP_STD_VER >= 20 |
| 486 | template <ranges::bidirectional_range _Range> | 319 | template <ranges::bidirectional_range _Range> |
| 487 | _LIBCPP_HIDE_FROM_ABI constexpr ranges::subrange<reverse_iterator<ranges::iterator_t<_Range>>, | 320 | _LIBCPP_HIDE_FROM_ABI constexpr ranges::subrange<reverse_iterator<ranges::iterator_t<_Range>>, |
| ... | @@ -493,24 +326,20 @@ __reverse_range(_Range&& __range) { | ... | @@ -493,24 +326,20 @@ __reverse_range(_Range&& __range) { |
| 493 | #endif | 326 | #endif |
| 494 | 327 | ||
| 495 | template <class _Iter, bool __b> | 328 | template <class _Iter, bool __b> |
| 496 | struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> | 329 | struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> { |
| 497 | : __unwrap_reverse_iter_impl<reverse_iterator, reverse_iterator, _Iter> {}; | 330 | using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>())); |
| 498 | 331 | using _ReverseWrapper = reverse_iterator<reverse_iterator<_Iter> >; | |
| 499 | #if _LIBCPP_STD_VER >= 20 | ||
| 500 | |||
| 501 | template <class _Iter, bool __b> | ||
| 502 | struct __unwrap_iter_impl<reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b> | ||
| 503 | : __unwrap_reverse_iter_impl<reverse_iterator, __unconstrained_reverse_iterator, _Iter> {}; | ||
| 504 | |||
| 505 | template <class _Iter, bool __b> | ||
| 506 | struct __unwrap_iter_impl<__unconstrained_reverse_iterator<reverse_iterator<_Iter>>, __b> | ||
| 507 | : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, reverse_iterator, _Iter> {}; | ||
| 508 | 332 | ||
| 509 | template <class _Iter, bool __b> | 333 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper |
| 510 | struct __unwrap_iter_impl<__unconstrained_reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b> | 334 | __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) { |
| 511 | : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, __unconstrained_reverse_iterator, _Iter> {}; | 335 | return _ReverseWrapper( |
| 336 | reverse_iterator<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter))); | ||
| 337 | } | ||
| 512 | 338 | ||
| 513 | #endif // _LIBCPP_STD_VER >= 20 | 339 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT { |
| 340 | return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base()); | ||
| 341 | } | ||
| 342 | }; | ||
| 514 | 343 | ||
| 515 | _LIBCPP_END_NAMESPACE_STD | 344 | _LIBCPP_END_NAMESPACE_STD |
| 516 | 345 |
lib/libcxx/include/__iterator/size.h+4-4| ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | ||
| 26 | template <class _Cont> | 26 | template <class _Cont> |
| 27 | _LIBCPP_HIDE_FROM_ABI constexpr auto size(const _Cont& __c) _NOEXCEPT_(noexcept(__c.size())) -> decltype(__c.size()) { | 27 | _LIBCPP_HIDE_FROM_ABI constexpr auto size(const _Cont& __c) noexcept(noexcept(__c.size())) -> decltype(__c.size()) { |
| 28 | return __c.size(); | 28 | return __c.size(); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| ... | @@ -35,9 +35,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t size(const _Tp (&)[_Sz]) noexcept { | ... | @@ -35,9 +35,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t size(const _Tp (&)[_Sz]) noexcept { |
| 35 | 35 | ||
| 36 | # if _LIBCPP_STD_VER >= 20 | 36 | # if _LIBCPP_STD_VER >= 20 |
| 37 | template <class _Cont> | 37 | template <class _Cont> |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr auto ssize(const _Cont& __c) | 38 | _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 39 | _NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()))) | 39 | ssize(const _Cont& __c) noexcept(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>( |
| 40 | -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> { | 40 | __c.size()))) -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> { |
| 41 | return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); | 41 | return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); |
| 42 | } | 42 | } |
| 43 | 43 |
lib/libcxx/include/__iterator/wrap_iter.h+29-2| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 10 | #ifndef _LIBCPP___ITERATOR_WRAP_ITER_H | 10 | #ifndef _LIBCPP___ITERATOR_WRAP_ITER_H |
| 11 | #define _LIBCPP___ITERATOR_WRAP_ITER_H | 11 | #define _LIBCPP___ITERATOR_WRAP_ITER_H |
| 12 | 12 | ||
| 13 | #include <__compare/ordering.h> | ||
| 14 | #include <__compare/three_way_comparable.h> | ||
| 13 | #include <__config> | 15 | #include <__config> |
| 14 | #include <__iterator/iterator_traits.h> | 16 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__memory/addressof.h> | 17 | #include <__memory/addressof.h> |
| ... | @@ -97,10 +99,14 @@ private: | ... | @@ -97,10 +99,14 @@ private: |
| 97 | friend class __wrap_iter; | 99 | friend class __wrap_iter; |
| 98 | template <class _CharT, class _Traits, class _Alloc> | 100 | template <class _CharT, class _Traits, class _Alloc> |
| 99 | friend class basic_string; | 101 | friend class basic_string; |
| 102 | template <class _CharT, class _Traits> | ||
| 103 | friend class basic_string_view; | ||
| 100 | template <class _Tp, class _Alloc> | 104 | template <class _Tp, class _Alloc> |
| 101 | friend class _LIBCPP_TEMPLATE_VIS vector; | 105 | friend class _LIBCPP_TEMPLATE_VIS vector; |
| 102 | template <class _Tp, size_t> | 106 | template <class _Tp, size_t> |
| 103 | friend class _LIBCPP_TEMPLATE_VIS span; | 107 | friend class _LIBCPP_TEMPLATE_VIS span; |
| 108 | template <class _Tp, size_t _Size> | ||
| 109 | friend struct array; | ||
| 104 | }; | 110 | }; |
| 105 | 111 | ||
| 106 | template <class _Iter1> | 112 | template <class _Iter1> |
| ... | @@ -127,6 +133,7 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC | ... | @@ -127,6 +133,7 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC |
| 127 | return __x.base() < __y.base(); | 133 | return __x.base() < __y.base(); |
| 128 | } | 134 | } |
| 129 | 135 | ||
| 136 | #if _LIBCPP_STD_VER <= 17 | ||
| 130 | template <class _Iter1> | 137 | template <class _Iter1> |
| 131 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 138 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 132 | operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { | 139 | operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { |
| ... | @@ -138,7 +145,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | ... | @@ -138,7 +145,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 138 | operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { | 145 | operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { |
| 139 | return !(__x == __y); | 146 | return !(__x == __y); |
| 140 | } | 147 | } |
| 148 | #endif | ||
| 141 | 149 | ||
| 150 | // TODO(mordante) disable these overloads in the LLVM 20 release. | ||
| 142 | template <class _Iter1> | 151 | template <class _Iter1> |
| 143 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 144 | operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { | 153 | operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { |
| ... | @@ -175,6 +184,24 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX | ... | @@ -175,6 +184,24 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX |
| 175 | return !(__y < __x); | 184 | return !(__y < __x); |
| 176 | } | 185 | } |
| 177 | 186 | ||
| 187 | #if _LIBCPP_STD_VER >= 20 | ||
| 188 | template <class _Iter1, class _Iter2> | ||
| 189 | _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering | ||
| 190 | operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept { | ||
| 191 | if constexpr (three_way_comparable_with<_Iter1, _Iter2, strong_ordering>) { | ||
| 192 | return __x.base() <=> __y.base(); | ||
| 193 | } else { | ||
| 194 | if (__x.base() < __y.base()) | ||
| 195 | return strong_ordering::less; | ||
| 196 | |||
| 197 | if (__x.base() == __y.base()) | ||
| 198 | return strong_ordering::equal; | ||
| 199 | |||
| 200 | return strong_ordering::greater; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 204 | |||
| 178 | template <class _Iter1, class _Iter2> | 205 | template <class _Iter1, class _Iter2> |
| 179 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 206 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 180 | #ifndef _LIBCPP_CXX03_LANG | 207 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -182,8 +209,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | ... | @@ -182,8 +209,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 182 | operator-(const __wrap_iter<_Iter1>& __x, | 209 | operator-(const __wrap_iter<_Iter1>& __x, |
| 183 | const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.base() - __y.base()) | 210 | const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.base() - __y.base()) |
| 184 | #else | 211 | #else |
| 185 | typename __wrap_iter<_Iter1>::difference_type | 212 | typename __wrap_iter<_Iter1>::difference_type |
| 186 | operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT | 213 | operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 187 | #endif // C++03 | 214 | #endif // C++03 |
| 188 | { | 215 | { |
| 189 | return __x.base() - __y.base(); | 216 | return __x.base() - __y.base(); |
lib/libcxx/include/__locale+12-30| ... | @@ -10,12 +10,13 @@ | ... | @@ -10,12 +10,13 @@ |
| 10 | #ifndef _LIBCPP___LOCALE | 10 | #ifndef _LIBCPP___LOCALE |
| 11 | #define _LIBCPP___LOCALE | 11 | #define _LIBCPP___LOCALE |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__locale_dir/locale_base_api.h> | ||
| 15 | #include <__memory/shared_ptr.h> // __shared_count | 15 | #include <__memory/shared_ptr.h> // __shared_count |
| 16 | #include <__mutex/once_flag.h> | 16 | #include <__mutex/once_flag.h> |
| 17 | #include <__type_traits/make_unsigned.h> | 17 | #include <__type_traits/make_unsigned.h> |
| 18 | #include <__utility/no_destroy.h> | 18 | #include <__utility/no_destroy.h> |
| 19 | #include <__utility/private_constructor_tag.h> | ||
| 19 | #include <cctype> | 20 | #include <cctype> |
| 20 | #include <clocale> | 21 | #include <clocale> |
| 21 | #include <cstdint> | 22 | #include <cstdint> |
| ... | @@ -32,27 +33,6 @@ | ... | @@ -32,27 +33,6 @@ |
| 32 | # include <__std_mbstate_t.h> | 33 | # include <__std_mbstate_t.h> |
| 33 | #endif | 34 | #endif |
| 34 | 35 | ||
| 35 | #if defined(_LIBCPP_MSVCRT_LIKE) | ||
| 36 | # include <__support/win32/locale_win32.h> | ||
| 37 | #elif defined(_AIX) || defined(__MVS__) | ||
| 38 | # include <__support/ibm/xlocale.h> | ||
| 39 | #elif defined(__ANDROID__) | ||
| 40 | # include <__support/android/locale_bionic.h> | ||
| 41 | #elif defined(_NEWLIB_VERSION) | ||
| 42 | # include <__support/newlib/xlocale.h> | ||
| 43 | #elif defined(__OpenBSD__) | ||
| 44 | # include <__support/openbsd/xlocale.h> | ||
| 45 | #elif (defined(__APPLE__) || defined(__FreeBSD__)) | ||
| 46 | # include <xlocale.h> | ||
| 47 | #elif defined(__Fuchsia__) | ||
| 48 | # include <__support/fuchsia/xlocale.h> | ||
| 49 | #elif defined(__wasi__) | ||
| 50 | // WASI libc uses musl's locales support. | ||
| 51 | # include <__support/musl/xlocale.h> | ||
| 52 | #elif defined(_LIBCPP_HAS_MUSL_LIBC) | ||
| 53 | # include <__support/musl/xlocale.h> | ||
| 54 | #endif | ||
| 55 | |||
| 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 36 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 57 | # pragma GCC system_header | 37 | # pragma GCC system_header |
| 58 | #endif | 38 | #endif |
| ... | @@ -69,6 +49,9 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); | ... | @@ -69,6 +49,9 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); |
| 69 | 49 | ||
| 70 | class _LIBCPP_EXPORTED_FROM_ABI locale { | 50 | class _LIBCPP_EXPORTED_FROM_ABI locale { |
| 71 | public: | 51 | public: |
| 52 | // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor. | ||
| 53 | using __trivially_relocatable = locale; | ||
| 54 | |||
| 72 | // types: | 55 | // types: |
| 73 | class _LIBCPP_EXPORTED_FROM_ABI facet; | 56 | class _LIBCPP_EXPORTED_FROM_ABI facet; |
| 74 | class _LIBCPP_EXPORTED_FROM_ABI id; | 57 | class _LIBCPP_EXPORTED_FROM_ABI id; |
| ... | @@ -118,8 +101,7 @@ private: | ... | @@ -118,8 +101,7 @@ private: |
| 118 | 101 | ||
| 119 | template <class> | 102 | template <class> |
| 120 | friend struct __no_destroy; | 103 | friend struct __no_destroy; |
| 121 | struct __private_tag {}; | 104 | _LIBCPP_HIDE_FROM_ABI explicit locale(__private_constructor_tag, __imp* __loc) : __locale_(__loc) {} |
| 122 | _LIBCPP_HIDE_FROM_ABI explicit locale(__private_tag, __imp* __loc) : __locale_(__loc) {} | ||
| 123 | 105 | ||
| 124 | void __install_ctor(const locale&, facet*, long); | 106 | void __install_ctor(const locale&, facet*, long); |
| 125 | static locale& __global(); | 107 | static locale& __global(); |
| ... | @@ -364,12 +346,12 @@ public: | ... | @@ -364,12 +346,12 @@ public: |
| 364 | static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used | 346 | static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used |
| 365 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT | 347 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 366 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA | 348 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA |
| 367 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) | 349 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) |
| 368 | # ifdef __APPLE__ | 350 | # ifdef __APPLE__ |
| 369 | typedef __uint32_t mask; | 351 | typedef __uint32_t mask; |
| 370 | # elif defined(__FreeBSD__) | 352 | # elif defined(__FreeBSD__) |
| 371 | typedef unsigned long mask; | 353 | typedef unsigned long mask; |
| 372 | # elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) | 354 | # elif defined(__NetBSD__) |
| 373 | typedef unsigned short mask; | 355 | typedef unsigned short mask; |
| 374 | # endif | 356 | # endif |
| 375 | static const mask space = _CTYPE_S; | 357 | static const mask space = _CTYPE_S; |
| ... | @@ -1269,10 +1251,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char | ... | @@ -1269,10 +1251,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char |
| 1269 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 1251 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1270 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; | 1252 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; |
| 1271 | #endif | 1253 | #endif |
| 1272 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | 1254 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 |
| 1273 | codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 | 1255 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 |
| 1274 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | 1256 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 |
| 1275 | codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 | 1257 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 |
| 1276 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | 1258 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 1277 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 | 1259 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 |
| 1278 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 | 1260 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 |
lib/libcxx/include/__locale_dir/locale_base_api.h created+98| ... | @@ -0,0 +1,98 @@ | ||
| 1 | //===-----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H | ||
| 11 | |||
| 12 | #if defined(_LIBCPP_MSVCRT_LIKE) | ||
| 13 | # include <__locale_dir/locale_base_api/win32.h> | ||
| 14 | #elif defined(_AIX) || defined(__MVS__) | ||
| 15 | # include <__locale_dir/locale_base_api/ibm.h> | ||
| 16 | #elif defined(__ANDROID__) | ||
| 17 | # include <__locale_dir/locale_base_api/android.h> | ||
| 18 | #elif defined(__sun__) | ||
| 19 | # include <__locale_dir/locale_base_api/solaris.h> | ||
| 20 | #elif defined(_NEWLIB_VERSION) | ||
| 21 | # include <__locale_dir/locale_base_api/newlib.h> | ||
| 22 | #elif defined(__OpenBSD__) | ||
| 23 | # include <__locale_dir/locale_base_api/openbsd.h> | ||
| 24 | #elif defined(__Fuchsia__) | ||
| 25 | # include <__locale_dir/locale_base_api/fuchsia.h> | ||
| 26 | #elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) | ||
| 27 | # include <__locale_dir/locale_base_api/musl.h> | ||
| 28 | #elif defined(__APPLE__) || defined(__FreeBSD__) | ||
| 29 | # include <xlocale.h> | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 33 | # pragma GCC system_header | ||
| 34 | #endif | ||
| 35 | |||
| 36 | /* | ||
| 37 | The platform-specific headers have to provide the following interface: | ||
| 38 | |||
| 39 | // TODO: rename this to __libcpp_locale_t | ||
| 40 | using locale_t = implementation-defined; | ||
| 41 | |||
| 42 | implementation-defined __libcpp_mb_cur_max_l(locale_t); | ||
| 43 | wint_t __libcpp_btowc_l(int, locale_t); | ||
| 44 | int __libcpp_wctob_l(wint_t, locale_t); | ||
| 45 | size_t __libcpp_wcsnrtombs_l(char* dest, const wchar_t** src, size_t wide_char_count, size_t len, mbstate_t, locale_t); | ||
| 46 | size_t __libcpp_wcrtomb_l(char* str, wchar_t wide_char, mbstate_t*, locale_t); | ||
| 47 | size_t __libcpp_mbsnrtowcs_l(wchar_t* dest, const char** src, size_t max_out, size_t len, mbstate_t*, locale_t); | ||
| 48 | size_t __libcpp_mbrtowc_l(wchar_t* dest, cosnt char* src, size_t count, mbstate_t*, locale_t); | ||
| 49 | int __libcpp_mbtowc_l(wchar_t* dest, const char* src, size_t count, locale_t); | ||
| 50 | size_t __libcpp_mbrlen_l(const char* str, size_t count, mbstate_t*, locale_t); | ||
| 51 | lconv* __libcpp_localeconv_l(locale_t); | ||
| 52 | size_t __libcpp_mbsrtowcs_l(wchar_t* dest, const char** src, size_t len, mbstate_t*, locale_t); | ||
| 53 | int __libcpp_snprintf_l(char* dest, size_t buff_size, locale_t, const char* format, ...); | ||
| 54 | int __libcpp_asprintf_l(char** dest, locale_t, const char* format, ...); | ||
| 55 | int __libcpp_sscanf_l(const char* dest, locale_t, const char* format, ...); | ||
| 56 | |||
| 57 | // TODO: change these to reserved names | ||
| 58 | float strtof_l(const char* str, char** str_end, locale_t); | ||
| 59 | double strtod_l(const char* str, char** str_end, locale_t); | ||
| 60 | long double strtold_l(const char* str, char** str_end, locale_t); | ||
| 61 | long long strtoll_l(const char* str, char** str_end, locale_t); | ||
| 62 | unsigned long long strtoull_l(const char* str, char** str_end, locale_t); | ||
| 63 | |||
| 64 | locale_t newlocale(int category_mask, const char* locale, locale_t base); | ||
| 65 | void freelocale(locale_t); | ||
| 66 | |||
| 67 | int islower_l(int ch, locale_t); | ||
| 68 | int isupper_l(int ch, locale_t); | ||
| 69 | int isdigit_l(int ch, locale_t); | ||
| 70 | int isxdigit_l(int ch, locale_t); | ||
| 71 | int strcoll_l(const char* lhs, const char* rhs, locale_t); | ||
| 72 | size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t); | ||
| 73 | int wcscoll_l(const char* lhs, const char* rhs, locale_t); | ||
| 74 | size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t); | ||
| 75 | int toupper_l(int ch, locale_t); | ||
| 76 | int tolower_l(int ch, locale_t); | ||
| 77 | int iswspace_l(wint_t ch, locale_t); | ||
| 78 | int iswprint_l(wint_t ch, locale_t); | ||
| 79 | int iswcntrl_l(wint_t ch, locale_t); | ||
| 80 | int iswupper_l(wint_t ch, locale_t); | ||
| 81 | int iswlower_l(wint_t ch, locale_t); | ||
| 82 | int iswalpha_l(wint_t ch, locale_t); | ||
| 83 | int iswblank_l(wint_t ch, locale_t); | ||
| 84 | int iswdigit_l(wint_t ch, locale_t); | ||
| 85 | int iswpunct_l(wint_t ch, locale_t); | ||
| 86 | int iswxdigit_l(wint_t ch, locale_t); | ||
| 87 | wint_t towupper_l(wint_t ch, locale_t); | ||
| 88 | wint_t towlower_l(wint_t ch, locale_t); | ||
| 89 | size_t strftime_l(char* str, size_t len, const char* format, const tm*, locale_t); | ||
| 90 | |||
| 91 | |||
| 92 | These functions are equivalent to their C counterparts, | ||
| 93 | except that locale_t is used instead of the current global locale. | ||
| 94 | |||
| 95 | The variadic functions may be implemented as templates with a parameter pack instead of variadic functions. | ||
| 96 | */ | ||
| 97 | |||
| 98 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/android.h created+50| ... | @@ -0,0 +1,50 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H | ||
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H | ||
| 12 | |||
| 13 | #include <stdlib.h> | ||
| 14 | |||
| 15 | // FIXME: Is this actually required? | ||
| 16 | extern "C" { | ||
| 17 | #include <xlocale.h> | ||
| 18 | } | ||
| 19 | |||
| 20 | #include <android/api-level.h> | ||
| 21 | #if __ANDROID_API__ < 21 | ||
| 22 | # include <__support/xlocale/__posix_l_fallback.h> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | // If we do not have this header, we are in a platform build rather than an NDK | ||
| 26 | // build, which will always be at least as new as the ToT NDK, in which case we | ||
| 27 | // don't need any of the inlines below since libc provides them. | ||
| 28 | #if __has_include(<android/ndk-version.h>) | ||
| 29 | # include <android/ndk-version.h> | ||
| 30 | // In NDK versions later than 16, locale-aware functions are provided by | ||
| 31 | // legacy_stdlib_inlines.h | ||
| 32 | # if __NDK_MAJOR__ <= 16 | ||
| 33 | # if __ANDROID_API__ < 21 | ||
| 34 | # include <__support/xlocale/__strtonum_fallback.h> | ||
| 35 | # elif __ANDROID_API__ < 26 | ||
| 36 | |||
| 37 | inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) { | ||
| 38 | return ::strtof(__nptr, __endptr); | ||
| 39 | } | ||
| 40 | |||
| 41 | inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) { | ||
| 42 | return ::strtod(__nptr, __endptr); | ||
| 43 | } | ||
| 44 | |||
| 45 | # endif // __ANDROID_API__ < 26 | ||
| 46 | |||
| 47 | # endif // __NDK_MAJOR__ <= 16 | ||
| 48 | #endif // __has_include(<android/ndk-version.h>) | ||
| 49 | |||
| 50 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/fuchsia.h created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H | ||
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H | ||
| 12 | |||
| 13 | #include <__support/xlocale/__posix_l_fallback.h> | ||
| 14 | #include <__support/xlocale/__strtonum_fallback.h> | ||
| 15 | #include <cstdlib> | ||
| 16 | #include <cwchar> | ||
| 17 | |||
| 18 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/ibm.h created+108| ... | @@ -0,0 +1,108 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H | ||
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H | ||
| 12 | |||
| 13 | #if defined(__MVS__) | ||
| 14 | # include <__support/ibm/locale_mgmt_zos.h> | ||
| 15 | #endif // defined(__MVS__) | ||
| 16 | |||
| 17 | #include <locale.h> | ||
| 18 | #include <stdarg.h> | ||
| 19 | #include <stdio.h> | ||
| 20 | |||
| 21 | #include "cstdlib" | ||
| 22 | |||
| 23 | #if defined(__MVS__) | ||
| 24 | # include <wctype.h> | ||
| 25 | // POSIX routines | ||
| 26 | # include <__support/xlocale/__posix_l_fallback.h> | ||
| 27 | #endif // defined(__MVS__) | ||
| 28 | |||
| 29 | namespace { | ||
| 30 | |||
| 31 | struct __setAndRestore { | ||
| 32 | explicit __setAndRestore(locale_t locale) { | ||
| 33 | if (locale == (locale_t)0) { | ||
| 34 | __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0); | ||
| 35 | __stored = uselocale(__cloc); | ||
| 36 | } else { | ||
| 37 | __stored = uselocale(locale); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | ~__setAndRestore() { | ||
| 42 | uselocale(__stored); | ||
| 43 | if (__cloc) | ||
| 44 | freelocale(__cloc); | ||
| 45 | } | ||
| 46 | |||
| 47 | private: | ||
| 48 | locale_t __stored = (locale_t)0; | ||
| 49 | locale_t __cloc = (locale_t)0; | ||
| 50 | }; | ||
| 51 | |||
| 52 | } // namespace | ||
| 53 | |||
| 54 | // The following are not POSIX routines. These are quick-and-dirty hacks | ||
| 55 | // to make things pretend to work | ||
| 56 | inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { | ||
| 57 | __setAndRestore __newloc(locale); | ||
| 58 | return ::strtoll(__nptr, __endptr, __base); | ||
| 59 | } | ||
| 60 | |||
| 61 | inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) { | ||
| 62 | __setAndRestore __newloc(locale); | ||
| 63 | return ::strtod(__nptr, __endptr); | ||
| 64 | } | ||
| 65 | |||
| 66 | inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t locale) { | ||
| 67 | __setAndRestore __newloc(locale); | ||
| 68 | return ::strtof(__nptr, __endptr); | ||
| 69 | } | ||
| 70 | |||
| 71 | inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t locale) { | ||
| 72 | __setAndRestore __newloc(locale); | ||
| 73 | return ::strtold(__nptr, __endptr); | ||
| 74 | } | ||
| 75 | |||
| 76 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 77 | strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { | ||
| 78 | __setAndRestore __newloc(locale); | ||
| 79 | return ::strtoull(__nptr, __endptr, __base); | ||
| 80 | } | ||
| 81 | |||
| 82 | inline _LIBCPP_HIDE_FROM_ABI | ||
| 83 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) { | ||
| 84 | const size_t buff_size = 256; | ||
| 85 | if ((*strp = (char*)malloc(buff_size)) == NULL) { | ||
| 86 | return -1; | ||
| 87 | } | ||
| 88 | |||
| 89 | va_list ap_copy; | ||
| 90 | // va_copy may not be provided by the C library in C++03 mode. | ||
| 91 | #if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy) | ||
| 92 | __builtin_va_copy(ap_copy, ap); | ||
| 93 | #else | ||
| 94 | va_copy(ap_copy, ap); | ||
| 95 | #endif | ||
| 96 | int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy); | ||
| 97 | va_end(ap_copy); | ||
| 98 | |||
| 99 | if ((size_t)str_size >= buff_size) { | ||
| 100 | if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) { | ||
| 101 | return -1; | ||
| 102 | } | ||
| 103 | str_size = vsnprintf(*strp, str_size + 1, fmt, ap); | ||
| 104 | } | ||
| 105 | return str_size; | ||
| 106 | } | ||
| 107 | |||
| 108 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/locale_guard.h+2-3| ... | @@ -30,9 +30,8 @@ struct __libcpp_locale_guard { | ... | @@ -30,9 +30,8 @@ struct __libcpp_locale_guard { |
| 30 | 30 | ||
| 31 | locale_t __old_loc_; | 31 | locale_t __old_loc_; |
| 32 | 32 | ||
| 33 | private: | 33 | __libcpp_locale_guard(__libcpp_locale_guard const&) = delete; |
| 34 | __libcpp_locale_guard(__libcpp_locale_guard const&); | 34 | __libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete; |
| 35 | __libcpp_locale_guard& operator=(__libcpp_locale_guard const&); | ||
| 36 | }; | 35 | }; |
| 37 | #elif defined(_LIBCPP_MSVCRT_LIKE) | 36 | #elif defined(_LIBCPP_MSVCRT_LIKE) |
| 38 | struct __libcpp_locale_guard { | 37 | struct __libcpp_locale_guard { |
lib/libcxx/include/__locale_dir/locale_base_api/musl.h created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | // This adds support for the extended locale functions that are currently | ||
| 10 | // missing from the Musl C library. | ||
| 11 | // | ||
| 12 | // This only works when the specified locale is "C" or "POSIX", but that's | ||
| 13 | // about as good as we can do without implementing full xlocale support | ||
| 14 | // in Musl. | ||
| 15 | //===----------------------------------------------------------------------===// | ||
| 16 | |||
| 17 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H | ||
| 18 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H | ||
| 19 | |||
| 20 | #include <cstdlib> | ||
| 21 | #include <cwchar> | ||
| 22 | |||
| 23 | inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 24 | return ::strtoll(__nptr, __endptr, __base); | ||
| 25 | } | ||
| 26 | |||
| 27 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 28 | return ::strtoull(__nptr, __endptr, __base); | ||
| 29 | } | ||
| 30 | |||
| 31 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/newlib.h created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H | ||
| 10 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H | ||
| 11 | |||
| 12 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/openbsd.h created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H | ||
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H | ||
| 12 | |||
| 13 | #include <__support/xlocale/__strtonum_fallback.h> | ||
| 14 | #include <clocale> | ||
| 15 | #include <cstdlib> | ||
| 16 | #include <ctype.h> | ||
| 17 | #include <cwctype> | ||
| 18 | |||
| 19 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H | ||
lib/libcxx/include/__locale_dir/locale_base_api/win32.h created+235| ... | @@ -0,0 +1,235 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H | ||
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <cstddef> | ||
| 15 | #include <locale.h> // _locale_t | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <string> | ||
| 18 | |||
| 19 | #define _X_ALL LC_ALL | ||
| 20 | #define _X_COLLATE LC_COLLATE | ||
| 21 | #define _X_CTYPE LC_CTYPE | ||
| 22 | #define _X_MONETARY LC_MONETARY | ||
| 23 | #define _X_NUMERIC LC_NUMERIC | ||
| 24 | #define _X_TIME LC_TIME | ||
| 25 | #define _X_MAX LC_MAX | ||
| 26 | #define _X_MESSAGES 6 | ||
| 27 | #define _NCAT (_X_MESSAGES + 1) | ||
| 28 | |||
| 29 | #define _CATMASK(n) ((1 << (n)) >> 1) | ||
| 30 | #define _M_COLLATE _CATMASK(_X_COLLATE) | ||
| 31 | #define _M_CTYPE _CATMASK(_X_CTYPE) | ||
| 32 | #define _M_MONETARY _CATMASK(_X_MONETARY) | ||
| 33 | #define _M_NUMERIC _CATMASK(_X_NUMERIC) | ||
| 34 | #define _M_TIME _CATMASK(_X_TIME) | ||
| 35 | #define _M_MESSAGES _CATMASK(_X_MESSAGES) | ||
| 36 | #define _M_ALL (_CATMASK(_NCAT) - 1) | ||
| 37 | |||
| 38 | #define LC_COLLATE_MASK _M_COLLATE | ||
| 39 | #define LC_CTYPE_MASK _M_CTYPE | ||
| 40 | #define LC_MONETARY_MASK _M_MONETARY | ||
| 41 | #define LC_NUMERIC_MASK _M_NUMERIC | ||
| 42 | #define LC_TIME_MASK _M_TIME | ||
| 43 | #define LC_MESSAGES_MASK _M_MESSAGES | ||
| 44 | #define LC_ALL_MASK \ | ||
| 45 | (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK) | ||
| 46 | |||
| 47 | class __lconv_storage { | ||
| 48 | public: | ||
| 49 | __lconv_storage(const lconv* __lc_input) { | ||
| 50 | __lc_ = *__lc_input; | ||
| 51 | |||
| 52 | __decimal_point_ = __lc_input->decimal_point; | ||
| 53 | __thousands_sep_ = __lc_input->thousands_sep; | ||
| 54 | __grouping_ = __lc_input->grouping; | ||
| 55 | __int_curr_symbol_ = __lc_input->int_curr_symbol; | ||
| 56 | __currency_symbol_ = __lc_input->currency_symbol; | ||
| 57 | __mon_decimal_point_ = __lc_input->mon_decimal_point; | ||
| 58 | __mon_thousands_sep_ = __lc_input->mon_thousands_sep; | ||
| 59 | __mon_grouping_ = __lc_input->mon_grouping; | ||
| 60 | __positive_sign_ = __lc_input->positive_sign; | ||
| 61 | __negative_sign_ = __lc_input->negative_sign; | ||
| 62 | |||
| 63 | __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str()); | ||
| 64 | __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str()); | ||
| 65 | __lc_.grouping = const_cast<char*>(__grouping_.c_str()); | ||
| 66 | __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str()); | ||
| 67 | __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str()); | ||
| 68 | __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str()); | ||
| 69 | __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str()); | ||
| 70 | __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str()); | ||
| 71 | __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str()); | ||
| 72 | __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str()); | ||
| 73 | } | ||
| 74 | |||
| 75 | lconv* __get() { return &__lc_; } | ||
| 76 | |||
| 77 | private: | ||
| 78 | lconv __lc_; | ||
| 79 | std::string __decimal_point_; | ||
| 80 | std::string __thousands_sep_; | ||
| 81 | std::string __grouping_; | ||
| 82 | std::string __int_curr_symbol_; | ||
| 83 | std::string __currency_symbol_; | ||
| 84 | std::string __mon_decimal_point_; | ||
| 85 | std::string __mon_thousands_sep_; | ||
| 86 | std::string __mon_grouping_; | ||
| 87 | std::string __positive_sign_; | ||
| 88 | std::string __negative_sign_; | ||
| 89 | }; | ||
| 90 | |||
| 91 | class locale_t { | ||
| 92 | public: | ||
| 93 | locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {} | ||
| 94 | locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {} | ||
| 95 | locale_t(_locale_t __xlocale, const char* __xlocale_str) | ||
| 96 | : __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {} | ||
| 97 | locale_t(const locale_t& __l) : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {} | ||
| 98 | |||
| 99 | ~locale_t() { delete __lc_; } | ||
| 100 | |||
| 101 | locale_t& operator=(const locale_t& __l) { | ||
| 102 | __locale_ = __l.__locale_; | ||
| 103 | __locale_str_ = __l.__locale_str_; | ||
| 104 | // __lc_ not copied | ||
| 105 | return *this; | ||
| 106 | } | ||
| 107 | |||
| 108 | friend bool operator==(const locale_t& __left, const locale_t& __right) { | ||
| 109 | return __left.__locale_ == __right.__locale_; | ||
| 110 | } | ||
| 111 | |||
| 112 | friend bool operator==(const locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; } | ||
| 113 | |||
| 114 | friend bool operator==(const locale_t& __left, long long __right) { | ||
| 115 | return __left.__locale_ == nullptr && __right == 0; | ||
| 116 | } | ||
| 117 | |||
| 118 | friend bool operator==(const locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; } | ||
| 119 | |||
| 120 | friend bool operator==(int __left, const locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; } | ||
| 121 | |||
| 122 | friend bool operator==(std::nullptr_t, const locale_t& __right) { return nullptr == __right.__locale_; } | ||
| 123 | |||
| 124 | friend bool operator!=(const locale_t& __left, const locale_t& __right) { return !(__left == __right); } | ||
| 125 | |||
| 126 | friend bool operator!=(const locale_t& __left, int __right) { return !(__left == __right); } | ||
| 127 | |||
| 128 | friend bool operator!=(const locale_t& __left, long long __right) { return !(__left == __right); } | ||
| 129 | |||
| 130 | friend bool operator!=(const locale_t& __left, std::nullptr_t __right) { return !(__left == __right); } | ||
| 131 | |||
| 132 | friend bool operator!=(int __left, const locale_t& __right) { return !(__left == __right); } | ||
| 133 | |||
| 134 | friend bool operator!=(std::nullptr_t __left, const locale_t& __right) { return !(__left == __right); } | ||
| 135 | |||
| 136 | operator bool() const { return __locale_ != nullptr; } | ||
| 137 | |||
| 138 | const char* __get_locale() const { return __locale_str_; } | ||
| 139 | |||
| 140 | operator _locale_t() const { return __locale_; } | ||
| 141 | |||
| 142 | lconv* __store_lconv(const lconv* __input_lc) { | ||
| 143 | delete __lc_; | ||
| 144 | __lc_ = new __lconv_storage(__input_lc); | ||
| 145 | return __lc_->__get(); | ||
| 146 | } | ||
| 147 | |||
| 148 | private: | ||
| 149 | _locale_t __locale_; | ||
| 150 | const char* __locale_str_; | ||
| 151 | __lconv_storage* __lc_ = nullptr; | ||
| 152 | }; | ||
| 153 | |||
| 154 | // Locale management functions | ||
| 155 | #define freelocale _free_locale | ||
| 156 | // FIXME: base currently unused. Needs manual work to construct the new locale | ||
| 157 | locale_t newlocale(int __mask, const char* __locale, locale_t __base); | ||
| 158 | // uselocale can't be implemented on Windows because Windows allows partial modification | ||
| 159 | // of thread-local locale and so _get_current_locale() returns a copy while uselocale does | ||
| 160 | // not create any copies. | ||
| 161 | // We can still implement raii even without uselocale though. | ||
| 162 | |||
| 163 | lconv* localeconv_l(locale_t& __loc); | ||
| 164 | size_t mbrlen_l(const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 165 | size_t mbsrtowcs_l( | ||
| 166 | wchar_t* __restrict __dst, const char** __restrict __src, size_t __len, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 167 | size_t wcrtomb_l(char* __restrict __s, wchar_t __wc, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 168 | size_t mbrtowc_l( | ||
| 169 | wchar_t* __restrict __pwc, const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 170 | size_t mbsnrtowcs_l(wchar_t* __restrict __dst, | ||
| 171 | const char** __restrict __src, | ||
| 172 | size_t __nms, | ||
| 173 | size_t __len, | ||
| 174 | mbstate_t* __restrict __ps, | ||
| 175 | locale_t __loc); | ||
| 176 | size_t wcsnrtombs_l(char* __restrict __dst, | ||
| 177 | const wchar_t** __restrict __src, | ||
| 178 | size_t __nwc, | ||
| 179 | size_t __len, | ||
| 180 | mbstate_t* __restrict __ps, | ||
| 181 | locale_t __loc); | ||
| 182 | wint_t btowc_l(int __c, locale_t __loc); | ||
| 183 | int wctob_l(wint_t __c, locale_t __loc); | ||
| 184 | |||
| 185 | decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l); | ||
| 186 | |||
| 187 | // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ | ||
| 188 | #define mbtowc_l _mbtowc_l | ||
| 189 | #define strtoll_l _strtoi64_l | ||
| 190 | #define strtoull_l _strtoui64_l | ||
| 191 | #define strtod_l _strtod_l | ||
| 192 | #if defined(_LIBCPP_MSVCRT) | ||
| 193 | # define strtof_l _strtof_l | ||
| 194 | # define strtold_l _strtold_l | ||
| 195 | #else | ||
| 196 | _LIBCPP_EXPORTED_FROM_ABI float strtof_l(const char*, char**, locale_t); | ||
| 197 | _LIBCPP_EXPORTED_FROM_ABI long double strtold_l(const char*, char**, locale_t); | ||
| 198 | #endif | ||
| 199 | inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, _locale_t __loc) { return _islower_l((int)__c, __loc); } | ||
| 200 | |||
| 201 | inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, _locale_t __loc) { return _isupper_l((int)__c, __loc); } | ||
| 202 | |||
| 203 | #define isdigit_l _isdigit_l | ||
| 204 | #define isxdigit_l _isxdigit_l | ||
| 205 | #define strcoll_l _strcoll_l | ||
| 206 | #define strxfrm_l _strxfrm_l | ||
| 207 | #define wcscoll_l _wcscoll_l | ||
| 208 | #define wcsxfrm_l _wcsxfrm_l | ||
| 209 | #define toupper_l _toupper_l | ||
| 210 | #define tolower_l _tolower_l | ||
| 211 | #define iswspace_l _iswspace_l | ||
| 212 | #define iswprint_l _iswprint_l | ||
| 213 | #define iswcntrl_l _iswcntrl_l | ||
| 214 | #define iswupper_l _iswupper_l | ||
| 215 | #define iswlower_l _iswlower_l | ||
| 216 | #define iswalpha_l _iswalpha_l | ||
| 217 | #define iswdigit_l _iswdigit_l | ||
| 218 | #define iswpunct_l _iswpunct_l | ||
| 219 | #define iswxdigit_l _iswxdigit_l | ||
| 220 | #define towupper_l _towupper_l | ||
| 221 | #define towlower_l _towlower_l | ||
| 222 | #if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800 | ||
| 223 | _LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc); | ||
| 224 | #else | ||
| 225 | # define strftime_l _strftime_l | ||
| 226 | #endif | ||
| 227 | #define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__) | ||
| 228 | _LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...); | ||
| 229 | _LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...); | ||
| 230 | _LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap); | ||
| 231 | |||
| 232 | // not-so-pressing FIXME: use locale to determine blank characters | ||
| 233 | inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); } | ||
| 234 | |||
| 235 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H | ||
lib/libcxx/include/__math/abs.h+4-4| ... | @@ -23,19 +23,19 @@ namespace __math { | ... | @@ -23,19 +23,19 @@ namespace __math { |
| 23 | 23 | ||
| 24 | // fabs | 24 | // fabs |
| 25 | 25 | ||
| 26 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } | 26 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } |
| 27 | 27 | ||
| 28 | template <class = int> | 28 | template <class = int> |
| 29 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { | 29 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { |
| 30 | return __builtin_fabs(__x); | 30 | return __builtin_fabs(__x); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { | 33 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { |
| 34 | return __builtin_fabsl(__x); | 34 | return __builtin_fabsl(__x); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 37 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 38 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { | 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { |
| 39 | return __builtin_fabs((double)__x); | 39 | return __builtin_fabs((double)__x); |
| 40 | } | 40 | } |
| 41 | 41 |
lib/libcxx/include/__math/copysign.h+3-4| ... | @@ -25,17 +25,16 @@ namespace __math { | ... | @@ -25,17 +25,16 @@ namespace __math { |
| 25 | 25 | ||
| 26 | // copysign | 26 | // copysign |
| 27 | 27 | ||
| 28 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { | 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { |
| 29 | return ::__builtin_copysignf(__x, __y); | 29 | return ::__builtin_copysignf(__x, __y); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { | 32 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { |
| 33 | return ::__builtin_copysignl(__x, __y); | 33 | return ::__builtin_copysignl(__x, __y); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 36 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 37 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type | 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 38 | copysign(_A1 __x, _A2 __y) _NOEXCEPT { | ||
| 39 | return ::__builtin_copysign(__x, __y); | 38 | return ::__builtin_copysign(__x, __y); |
| 40 | } | 39 | } |
| 41 | 40 |
lib/libcxx/include/__math/exponential_functions.h+1-1| ... | @@ -160,7 +160,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _ | ... | @@ -160,7 +160,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _ |
| 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 typename __promote<_A1, _A2>::type pow(_A1 __x, _A2 __y) _NOEXCEPT { |
| 162 | using __result_type = typename __promote<_A1, _A2>::type; | 162 | using __result_type = typename __promote<_A1, _A2>::type; |
| 163 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 163 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 164 | return __math::pow((__result_type)__x, (__result_type)__y); | 164 | return __math::pow((__result_type)__x, (__result_type)__y); |
| 165 | } | 165 | } |
| 166 | 166 |
lib/libcxx/include/__math/fdim.h+1-1| ... | @@ -37,7 +37,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) | ... | @@ -37,7 +37,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) |
| 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 typename __promote<_A1, _A2>::type fdim(_A1 __x, _A2 __y) _NOEXCEPT { |
| 39 | using __result_type = typename __promote<_A1, _A2>::type; | 39 | using __result_type = typename __promote<_A1, _A2>::type; |
| 40 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 40 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 41 | return __math::fdim((__result_type)__x, (__result_type)__y); | 41 | return __math::fdim((__result_type)__x, (__result_type)__y); |
| 42 | } | 42 | } |
| 43 | 43 |
lib/libcxx/include/__math/fma.h+3-3| ... | @@ -42,9 +42,9 @@ template <class _A1, | ... | @@ -42,9 +42,9 @@ template <class _A1, |
| 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 typename __promote<_A1, _A2, _A3>::type fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { |
| 44 | using __result_type = typename __promote<_A1, _A2, _A3>::type; | 44 | using __result_type = typename __promote<_A1, _A2, _A3>::type; |
| 45 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && | 45 | static_assert( |
| 46 | _IsSame<_A3, __result_type>::value)), | 46 | !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value), |
| 47 | ""); | 47 | ""); |
| 48 | return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); | 48 | return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); |
| 49 | } | 49 | } |
| 50 | 50 |
lib/libcxx/include/__math/hypot.h+62-1| ... | @@ -9,16 +9,25 @@ | ... | @@ -9,16 +9,25 @@ |
| 9 | #ifndef _LIBCPP___MATH_HYPOT_H | 9 | #ifndef _LIBCPP___MATH_HYPOT_H |
| 10 | #define _LIBCPP___MATH_HYPOT_H | 10 | #define _LIBCPP___MATH_HYPOT_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/max.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__math/abs.h> | ||
| 15 | #include <__math/exponential_functions.h> | ||
| 16 | #include <__math/roots.h> | ||
| 13 | #include <__type_traits/enable_if.h> | 17 | #include <__type_traits/enable_if.h> |
| 14 | #include <__type_traits/is_arithmetic.h> | 18 | #include <__type_traits/is_arithmetic.h> |
| 15 | #include <__type_traits/is_same.h> | 19 | #include <__type_traits/is_same.h> |
| 16 | #include <__type_traits/promote.h> | 20 | #include <__type_traits/promote.h> |
| 21 | #include <__utility/pair.h> | ||
| 22 | #include <limits> | ||
| 17 | 23 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header | 25 | # pragma GCC system_header |
| 20 | #endif | 26 | #endif |
| 21 | 27 | ||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 32 | ||
| 24 | namespace __math { | 33 | namespace __math { |
| ... | @@ -37,12 +46,64 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) | ... | @@ -37,12 +46,64 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) |
| 37 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 46 | 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 hypot(_A1 __x, _A2 __y) _NOEXCEPT { | 47 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _A2 __y) _NOEXCEPT { |
| 39 | using __result_type = typename __promote<_A1, _A2>::type; | 48 | using __result_type = typename __promote<_A1, _A2>::type; |
| 40 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 49 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 41 | return __math::hypot((__result_type)__x, (__result_type)__y); | 50 | return __math::hypot((__result_type)__x, (__result_type)__y); |
| 42 | } | 51 | } |
| 43 | 52 | ||
| 53 | #if _LIBCPP_STD_VER >= 17 | ||
| 54 | // Computes the three-dimensional hypotenuse: `std::hypot(x,y,z)`. | ||
| 55 | // The naive implementation might over-/underflow which is why this implementation is more involved: | ||
| 56 | // If the square of an argument might run into issues, we scale the arguments appropriately. | ||
| 57 | // See https://github.com/llvm/llvm-project/issues/92782 for a detailed discussion and summary. | ||
| 58 | template <class _Real> | ||
| 59 | _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) { | ||
| 60 | // Factors needed to determine if over-/underflow might happen | ||
| 61 | constexpr int __exp = std::numeric_limits<_Real>::max_exponent / 2; | ||
| 62 | const _Real __overflow_threshold = __math::ldexp(_Real(1), __exp); | ||
| 63 | const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20)); | ||
| 64 | |||
| 65 | // Scale arguments depending on their size | ||
| 66 | const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z))); | ||
| 67 | _Real __scale; | ||
| 68 | if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow | ||
| 69 | __scale = __overflow_scale; | ||
| 70 | } else if (__max_abs < 1 / __overflow_threshold) { // x*x + y*y + z*z might underflow | ||
| 71 | __scale = 1 / __overflow_scale; | ||
| 72 | } else { | ||
| 73 | __scale = 1; | ||
| 74 | } | ||
| 75 | __x *= __scale; | ||
| 76 | __y *= __scale; | ||
| 77 | __z *= __scale; | ||
| 78 | |||
| 79 | // Compute hypot of scaled arguments and undo scaling | ||
| 80 | return __math::sqrt(__x * __x + __y * __y + __z * __z) / __scale; | ||
| 81 | } | ||
| 82 | |||
| 83 | inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { return __math::__hypot(__x, __y, __z); } | ||
| 84 | |||
| 85 | inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { return __math::__hypot(__x, __y, __z); } | ||
| 86 | |||
| 87 | inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) { | ||
| 88 | return __math::__hypot(__x, __y, __z); | ||
| 89 | } | ||
| 90 | |||
| 91 | template <class _A1, | ||
| 92 | class _A2, | ||
| 93 | class _A3, | ||
| 94 | std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 > | ||
| 95 | _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { | ||
| 96 | using __result_type = typename __promote<_A1, _A2, _A3>::type; | ||
| 97 | static_assert(!( | ||
| 98 | std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>)); | ||
| 99 | return __math::__hypot( | ||
| 100 | static_cast<__result_type>(__x), static_cast<__result_type>(__y), static_cast<__result_type>(__z)); | ||
| 101 | } | ||
| 102 | #endif | ||
| 103 | |||
| 44 | } // namespace __math | 104 | } // namespace __math |
| 45 | 105 | ||
| 46 | _LIBCPP_END_NAMESPACE_STD | 106 | _LIBCPP_END_NAMESPACE_STD |
| 107 | _LIBCPP_POP_MACROS | ||
| 47 | 108 | ||
| 48 | #endif // _LIBCPP___MATH_HYPOT_H | 109 | #endif // _LIBCPP___MATH_HYPOT_H |
lib/libcxx/include/__math/inverse_trigonometric_functions.h+1-1| ... | @@ -88,7 +88,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) | ... | @@ -88,7 +88,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) |
| 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 typename __promote<_A1, _A2>::type atan2(_A1 __y, _A2 __x) _NOEXCEPT { |
| 90 | using __result_type = typename __promote<_A1, _A2>::type; | 90 | using __result_type = typename __promote<_A1, _A2>::type; |
| 91 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 91 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 92 | return __math::atan2((__result_type)__y, (__result_type)__x); | 92 | return __math::atan2((__result_type)__y, (__result_type)__x); |
| 93 | } | 93 | } |
| 94 | 94 |
lib/libcxx/include/__math/min_max.h+10-10| ... | @@ -25,45 +25,45 @@ namespace __math { | ... | @@ -25,45 +25,45 @@ namespace __math { |
| 25 | 25 | ||
| 26 | // fmax | 26 | // fmax |
| 27 | 27 | ||
| 28 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { | 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { |
| 29 | return __builtin_fmaxf(__x, __y); | 29 | return __builtin_fmaxf(__x, __y); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | template <class = int> | 32 | template <class = int> |
| 33 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { | 33 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { |
| 34 | return __builtin_fmax(__x, __y); | 34 | return __builtin_fmax(__x, __y); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { | 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { |
| 38 | return __builtin_fmaxl(__x, __y); | 38 | return __builtin_fmaxl(__x, __y); |
| 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 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { | 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { |
| 43 | using __result_type = typename __promote<_A1, _A2>::type; | 43 | using __result_type = typename __promote<_A1, _A2>::type; |
| 44 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 44 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 45 | return __math::fmax((__result_type)__x, (__result_type)__y); | 45 | return __math::fmax((__result_type)__x, (__result_type)__y); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | // fmin | 48 | // fmin |
| 49 | 49 | ||
| 50 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { | 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { |
| 51 | return __builtin_fminf(__x, __y); | 51 | return __builtin_fminf(__x, __y); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | template <class = int> | 54 | template <class = int> |
| 55 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { | 55 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { |
| 56 | return __builtin_fmin(__x, __y); | 56 | return __builtin_fmin(__x, __y); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { | 59 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { |
| 60 | return __builtin_fminl(__x, __y); | 60 | return __builtin_fminl(__x, __y); |
| 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 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { | 64 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { |
| 65 | using __result_type = typename __promote<_A1, _A2>::type; | 65 | using __result_type = typename __promote<_A1, _A2>::type; |
| 66 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 66 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 67 | return __math::fmin((__result_type)__x, (__result_type)__y); | 67 | return __math::fmin((__result_type)__x, (__result_type)__y); |
| 68 | } | 68 | } |
| 69 | 69 |
lib/libcxx/include/__math/modulo.h+1-1| ... | @@ -39,7 +39,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) | ... | @@ -39,7 +39,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) |
| 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 typename __promote<_A1, _A2>::type fmod(_A1 __x, _A2 __y) _NOEXCEPT { |
| 41 | using __result_type = typename __promote<_A1, _A2>::type; | 41 | using __result_type = typename __promote<_A1, _A2>::type; |
| 42 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 42 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 43 | return __math::fmod((__result_type)__x, (__result_type)__y); | 43 | return __math::fmod((__result_type)__x, (__result_type)__y); |
| 44 | } | 44 | } |
| 45 | 45 |
lib/libcxx/include/__math/remainder.h+2-2| ... | @@ -40,7 +40,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double | ... | @@ -40,7 +40,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double |
| 40 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 40 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 41 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remainder(_A1 __x, _A2 __y) _NOEXCEPT { | 41 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remainder(_A1 __x, _A2 __y) _NOEXCEPT { |
| 42 | using __result_type = typename __promote<_A1, _A2>::type; | 42 | using __result_type = typename __promote<_A1, _A2>::type; |
| 43 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 43 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 44 | return __math::remainder((__result_type)__x, (__result_type)__y); | 44 | return __math::remainder((__result_type)__x, (__result_type)__y); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| ... | @@ -62,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y | ... | @@ -62,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y |
| 62 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 62 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 63 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT { | 63 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT { |
| 64 | using __result_type = typename __promote<_A1, _A2>::type; | 64 | using __result_type = typename __promote<_A1, _A2>::type; |
| 65 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 65 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 66 | return __math::remquo((__result_type)__x, (__result_type)__y, __z); | 66 | return __math::remquo((__result_type)__x, (__result_type)__y, __z); |
| 67 | } | 67 | } |
| 68 | 68 |
lib/libcxx/include/__math/roots.h+4-4| ... | @@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT { | ... | @@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT { |
| 39 | 39 | ||
| 40 | // cbrt | 40 | // cbrt |
| 41 | 41 | ||
| 42 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } | 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } |
| 43 | 43 | ||
| 44 | template <class = int> | 44 | template <class = int> |
| 45 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { | 45 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { |
| 46 | return __builtin_cbrt(__x); | 46 | return __builtin_cbrt(__x); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { | 49 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { |
| 50 | return __builtin_cbrtl(__x); | 50 | return __builtin_cbrtl(__x); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 53 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 54 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { | 54 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { |
| 55 | return __builtin_cbrt((double)__x); | 55 | return __builtin_cbrt((double)__x); |
| 56 | } | 56 | } |
| 57 | 57 |
lib/libcxx/include/__math/rounding_functions.h+25-25| ... | @@ -26,37 +26,37 @@ namespace __math { | ... | @@ -26,37 +26,37 @@ namespace __math { |
| 26 | 26 | ||
| 27 | // ceil | 27 | // ceil |
| 28 | 28 | ||
| 29 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } | 29 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } |
| 30 | 30 | ||
| 31 | template <class = int> | 31 | template <class = int> |
| 32 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { | 32 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { |
| 33 | return __builtin_ceil(__x); | 33 | return __builtin_ceil(__x); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { | 36 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { |
| 37 | return __builtin_ceill(__x); | 37 | return __builtin_ceill(__x); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 40 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 41 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { | 41 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { |
| 42 | return __builtin_ceil((double)__x); | 42 | return __builtin_ceil((double)__x); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | // floor | 45 | // floor |
| 46 | 46 | ||
| 47 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } | 47 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } |
| 48 | 48 | ||
| 49 | template <class = int> | 49 | template <class = int> |
| 50 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { | 50 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { |
| 51 | return __builtin_floor(__x); | 51 | return __builtin_floor(__x); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { | 54 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { |
| 55 | return __builtin_floorl(__x); | 55 | return __builtin_floorl(__x); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 58 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 59 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { | 59 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { |
| 60 | return __builtin_floor((double)__x); | 60 | return __builtin_floor((double)__x); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| ... | @@ -126,21 +126,21 @@ inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT { | ... | @@ -126,21 +126,21 @@ inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT { |
| 126 | 126 | ||
| 127 | // nearbyint | 127 | // nearbyint |
| 128 | 128 | ||
| 129 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { | 129 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { |
| 130 | return __builtin_nearbyintf(__x); | 130 | return __builtin_nearbyintf(__x); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | template <class = int> | 133 | template <class = int> |
| 134 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { | 134 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { |
| 135 | return __builtin_nearbyint(__x); | 135 | return __builtin_nearbyint(__x); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { | 138 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { |
| 139 | return __builtin_nearbyintl(__x); | 139 | return __builtin_nearbyintl(__x); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 142 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 143 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { | 143 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { |
| 144 | return __builtin_nearbyint((double)__x); | 144 | return __builtin_nearbyint((double)__x); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| ... | @@ -160,7 +160,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double | ... | @@ -160,7 +160,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double |
| 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 typename __promote<_A1, _A2>::type nextafter(_A1 __x, _A2 __y) _NOEXCEPT { |
| 162 | using __result_type = typename __promote<_A1, _A2>::type; | 162 | using __result_type = typename __promote<_A1, _A2>::type; |
| 163 | static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); | 163 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 164 | return __math::nextafter((__result_type)__x, (__result_type)__y); | 164 | return __math::nextafter((__result_type)__x, (__result_type)__y); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| ... | @@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE | ... | @@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE |
| 186 | 186 | ||
| 187 | // rint | 187 | // rint |
| 188 | 188 | ||
| 189 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } | 189 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } |
| 190 | 190 | ||
| 191 | template <class = int> | 191 | template <class = int> |
| 192 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { | 192 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { |
| 193 | return __builtin_rint(__x); | 193 | return __builtin_rint(__x); |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { | 196 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { |
| 197 | return __builtin_rintl(__x); | 197 | return __builtin_rintl(__x); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 200 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 201 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { | 201 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { |
| 202 | return __builtin_rint((double)__x); | 202 | return __builtin_rint((double)__x); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | // round | 205 | // round |
| 206 | 206 | ||
| 207 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); } | 207 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); } |
| 208 | 208 | ||
| 209 | template <class = int> | 209 | template <class = int> |
| 210 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { | 210 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { |
| 211 | return __builtin_round(__x); | 211 | return __builtin_round(__x); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { | 214 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { |
| 215 | return __builtin_roundl(__x); | 215 | return __builtin_roundl(__x); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 218 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 219 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { | 219 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { |
| 220 | return __builtin_round((double)__x); | 220 | return __builtin_round((double)__x); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | // trunc | 223 | // trunc |
| 224 | 224 | ||
| 225 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); } | 225 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); } |
| 226 | 226 | ||
| 227 | template <class = int> | 227 | template <class = int> |
| 228 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { | 228 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { |
| 229 | return __builtin_trunc(__x); | 229 | return __builtin_trunc(__x); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { | 232 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { |
| 233 | return __builtin_truncl(__x); | 233 | return __builtin_truncl(__x); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 236 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 237 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { | 237 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { |
| 238 | return __builtin_trunc((double)__x); | 238 | return __builtin_trunc((double)__x); |
| 239 | } | 239 | } |
| 240 | 240 |
lib/libcxx/include/__math/special_functions.h created+84| ... | @@ -0,0 +1,84 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___MATH_SPECIAL_FUNCTIONS_H | ||
| 11 | #define _LIBCPP___MATH_SPECIAL_FUNCTIONS_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__math/copysign.h> | ||
| 15 | #include <__math/traits.h> | ||
| 16 | #include <__type_traits/enable_if.h> | ||
| 17 | #include <__type_traits/is_integral.h> | ||
| 18 | #include <limits> | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 25 | |||
| 26 | #if _LIBCPP_STD_VER >= 17 | ||
| 27 | |||
| 28 | template <class _Real> | ||
| 29 | _LIBCPP_HIDE_FROM_ABI _Real __hermite(unsigned __n, _Real __x) { | ||
| 30 | // The Hermite polynomial H_n(x). | ||
| 31 | // The implementation is based on the recurrence formula: H_{n+1}(x) = 2x H_n(x) - 2n H_{n-1}. | ||
| 32 | // Press, William H., et al. Numerical recipes 3rd edition: The art of scientific computing. | ||
| 33 | // Cambridge university press, 2007, p. 183. | ||
| 34 | |||
| 35 | // NOLINTBEGIN(readability-identifier-naming) | ||
| 36 | if (__math::isnan(__x)) | ||
| 37 | return __x; | ||
| 38 | |||
| 39 | _Real __H_0{1}; | ||
| 40 | if (__n == 0) | ||
| 41 | return __H_0; | ||
| 42 | |||
| 43 | _Real __H_n_prev = __H_0; | ||
| 44 | _Real __H_n = 2 * __x; | ||
| 45 | for (unsigned __i = 1; __i < __n; ++__i) { | ||
| 46 | _Real __H_n_next = 2 * (__x * __H_n - __i * __H_n_prev); | ||
| 47 | __H_n_prev = __H_n; | ||
| 48 | __H_n = __H_n_next; | ||
| 49 | } | ||
| 50 | |||
| 51 | if (!__math::isfinite(__H_n)) { | ||
| 52 | // Overflow occured. Two possible cases: | ||
| 53 | // n is odd: return infinity of the same sign as x. | ||
| 54 | // n is even: return +Inf | ||
| 55 | _Real __inf = std::numeric_limits<_Real>::infinity(); | ||
| 56 | return (__n & 1) ? __math::copysign(__inf, __x) : __inf; | ||
| 57 | } | ||
| 58 | return __H_n; | ||
| 59 | // NOLINTEND(readability-identifier-naming) | ||
| 60 | } | ||
| 61 | |||
| 62 | inline _LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, double __x) { return std::__hermite(__n, __x); } | ||
| 63 | |||
| 64 | inline _LIBCPP_HIDE_FROM_ABI float hermite(unsigned __n, float __x) { | ||
| 65 | // use double internally -- float is too prone to overflow! | ||
| 66 | return static_cast<float>(std::hermite(__n, static_cast<double>(__x))); | ||
| 67 | } | ||
| 68 | |||
| 69 | inline _LIBCPP_HIDE_FROM_ABI long double hermite(unsigned __n, long double __x) { return std::__hermite(__n, __x); } | ||
| 70 | |||
| 71 | inline _LIBCPP_HIDE_FROM_ABI float hermitef(unsigned __n, float __x) { return std::hermite(__n, __x); } | ||
| 72 | |||
| 73 | inline _LIBCPP_HIDE_FROM_ABI long double hermitel(unsigned __n, long double __x) { return std::hermite(__n, __x); } | ||
| 74 | |||
| 75 | template <class _Integer, std::enable_if_t<std::is_integral_v<_Integer>, int> = 0> | ||
| 76 | _LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, _Integer __x) { | ||
| 77 | return std::hermite(__n, static_cast<double>(__x)); | ||
| 78 | } | ||
| 79 | |||
| 80 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 81 | |||
| 82 | _LIBCPP_END_NAMESPACE_STD | ||
| 83 | |||
| 84 | #endif // _LIBCPP___MATH_SPECIAL_FUNCTIONS_H | ||
lib/libcxx/include/__math/traits.h+35-23| ... | @@ -29,55 +29,67 @@ namespace __math { | ... | @@ -29,55 +29,67 @@ namespace __math { |
| 29 | // signbit | 29 | // signbit |
| 30 | 30 | ||
| 31 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | 31 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> |
| 32 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | 32 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { |
| 33 | return __builtin_signbit(__x); | 33 | return __builtin_signbit(__x); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0> | 36 | template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0> |
| 37 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { |
| 38 | return __x < 0; | 38 | return __x < 0; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0> | 41 | template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0> |
| 42 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { | 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { |
| 43 | return false; | 43 | return false; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | // isfinite | 46 | // isfinite |
| 47 | 47 | ||
| 48 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> | 48 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> |
| 49 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { | 49 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { |
| 50 | return __builtin_isfinite((typename __promote<_A1>::type)__x); | 50 | return __builtin_isfinite((typename __promote<_A1>::type)__x); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> | 53 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> |
| 54 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { | 54 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { |
| 55 | return true; | 55 | return true; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT { | ||
| 59 | return __builtin_isfinite(__x); | ||
| 60 | } | ||
| 61 | |||
| 62 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT { | ||
| 63 | return __builtin_isfinite(__x); | ||
| 64 | } | ||
| 65 | |||
| 66 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT { | ||
| 67 | return __builtin_isfinite(__x); | ||
| 68 | } | ||
| 69 | |||
| 58 | // isinf | 70 | // isinf |
| 59 | 71 | ||
| 60 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> | 72 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> |
| 61 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { | 73 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { |
| 62 | return __builtin_isinf((typename __promote<_A1>::type)__x); | 74 | return __builtin_isinf((typename __promote<_A1>::type)__x); |
| 63 | } | 75 | } |
| 64 | 76 | ||
| 65 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> | 77 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> |
| 66 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { | 78 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { |
| 67 | return false; | 79 | return false; |
| 68 | } | 80 | } |
| 69 | 81 | ||
| 70 | #ifdef _LIBCPP_PREFERRED_OVERLOAD | 82 | #ifdef _LIBCPP_PREFERRED_OVERLOAD |
| 71 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { | 83 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { |
| 72 | return __builtin_isinf(__x); | 84 | return __builtin_isinf(__x); |
| 73 | } | 85 | } |
| 74 | 86 | ||
| 75 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool | 87 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool |
| 76 | isinf(double __x) _NOEXCEPT { | 88 | isinf(double __x) _NOEXCEPT { |
| 77 | return __builtin_isinf(__x); | 89 | return __builtin_isinf(__x); |
| 78 | } | 90 | } |
| 79 | 91 | ||
| 80 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { | 92 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { |
| 81 | return __builtin_isinf(__x); | 93 | return __builtin_isinf(__x); |
| 82 | } | 94 | } |
| 83 | #endif | 95 | #endif |
| ... | @@ -85,26 +97,26 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI | ... | @@ -85,26 +97,26 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI |
| 85 | // isnan | 97 | // isnan |
| 86 | 98 | ||
| 87 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | 99 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> |
| 88 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { | 100 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { |
| 89 | return __builtin_isnan(__x); | 101 | return __builtin_isnan(__x); |
| 90 | } | 102 | } |
| 91 | 103 | ||
| 92 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 104 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 93 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { | 105 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { |
| 94 | return false; | 106 | return false; |
| 95 | } | 107 | } |
| 96 | 108 | ||
| 97 | #ifdef _LIBCPP_PREFERRED_OVERLOAD | 109 | #ifdef _LIBCPP_PREFERRED_OVERLOAD |
| 98 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { | 110 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { |
| 99 | return __builtin_isnan(__x); | 111 | return __builtin_isnan(__x); |
| 100 | } | 112 | } |
| 101 | 113 | ||
| 102 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool | 114 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool |
| 103 | isnan(double __x) _NOEXCEPT { | 115 | isnan(double __x) _NOEXCEPT { |
| 104 | return __builtin_isnan(__x); | 116 | return __builtin_isnan(__x); |
| 105 | } | 117 | } |
| 106 | 118 | ||
| 107 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { | 119 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { |
| 108 | return __builtin_isnan(__x); | 120 | return __builtin_isnan(__x); |
| 109 | } | 121 | } |
| 110 | #endif | 122 | #endif |
| ... | @@ -112,19 +124,19 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI | ... | @@ -112,19 +124,19 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI |
| 112 | // isnormal | 124 | // isnormal |
| 113 | 125 | ||
| 114 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | 126 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> |
| 115 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { | 127 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { |
| 116 | return __builtin_isnormal(__x); | 128 | return __builtin_isnormal(__x); |
| 117 | } | 129 | } |
| 118 | 130 | ||
| 119 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 131 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 120 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { | 132 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { |
| 121 | return __x != 0; | 133 | return __x != 0; |
| 122 | } | 134 | } |
| 123 | 135 | ||
| 124 | // isgreater | 136 | // isgreater |
| 125 | 137 | ||
| 126 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 138 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 127 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { | 139 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 128 | using type = typename __promote<_A1, _A2>::type; | 140 | using type = typename __promote<_A1, _A2>::type; |
| 129 | return __builtin_isgreater((type)__x, (type)__y); | 141 | return __builtin_isgreater((type)__x, (type)__y); |
| 130 | } | 142 | } |
| ... | @@ -132,7 +144,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 _ | ... | @@ -132,7 +144,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 _ |
| 132 | // isgreaterequal | 144 | // isgreaterequal |
| 133 | 145 | ||
| 134 | 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> |
| 135 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { | 147 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 136 | using type = typename __promote<_A1, _A2>::type; | 148 | using type = typename __promote<_A1, _A2>::type; |
| 137 | return __builtin_isgreaterequal((type)__x, (type)__y); | 149 | return __builtin_isgreaterequal((type)__x, (type)__y); |
| 138 | } | 150 | } |
| ... | @@ -140,7 +152,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, | ... | @@ -140,7 +152,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, |
| 140 | // isless | 152 | // isless |
| 141 | 153 | ||
| 142 | 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> |
| 143 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { | 155 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { |
| 144 | using type = typename __promote<_A1, _A2>::type; | 156 | using type = typename __promote<_A1, _A2>::type; |
| 145 | return __builtin_isless((type)__x, (type)__y); | 157 | return __builtin_isless((type)__x, (type)__y); |
| 146 | } | 158 | } |
| ... | @@ -148,7 +160,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) | ... | @@ -148,7 +160,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) |
| 148 | // islessequal | 160 | // islessequal |
| 149 | 161 | ||
| 150 | 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> |
| 151 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { | 163 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 152 | using type = typename __promote<_A1, _A2>::type; | 164 | using type = typename __promote<_A1, _A2>::type; |
| 153 | return __builtin_islessequal((type)__x, (type)__y); | 165 | return __builtin_islessequal((type)__x, (type)__y); |
| 154 | } | 166 | } |
| ... | @@ -156,7 +168,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 | ... | @@ -156,7 +168,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 |
| 156 | // islessgreater | 168 | // islessgreater |
| 157 | 169 | ||
| 158 | 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> |
| 159 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { | 171 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 160 | using type = typename __promote<_A1, _A2>::type; | 172 | using type = typename __promote<_A1, _A2>::type; |
| 161 | return __builtin_islessgreater((type)__x, (type)__y); | 173 | return __builtin_islessgreater((type)__x, (type)__y); |
| 162 | } | 174 | } |
| ... | @@ -164,7 +176,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _ | ... | @@ -164,7 +176,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _ |
| 164 | // isunordered | 176 | // isunordered |
| 165 | 177 | ||
| 166 | 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> |
| 167 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { | 179 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { |
| 168 | using type = typename __promote<_A1, _A2>::type; | 180 | using type = typename __promote<_A1, _A2>::type; |
| 169 | return __builtin_isunordered((type)__x, (type)__y); | 181 | return __builtin_isunordered((type)__x, (type)__y); |
| 170 | } | 182 | } |
lib/libcxx/include/__mdspan/extents.h+19-6| ... | @@ -137,9 +137,9 @@ private: | ... | @@ -137,9 +137,9 @@ private: |
| 137 | // static mapping of indices to the position in the dynamic values array | 137 | // static mapping of indices to the position in the dynamic values array |
| 138 | using _DynamicIdxMap = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>; | 138 | using _DynamicIdxMap = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>; |
| 139 | 139 | ||
| 140 | template <size_t... Indices> | 140 | template <size_t... _Indices> |
| 141 | _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<Indices...>) noexcept { | 141 | _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<_Indices...>) noexcept { |
| 142 | return _DynamicValues{((void)Indices, 0)...}; | 142 | return _DynamicValues{((void)_Indices, 0)...}; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | public: | 145 | public: |
| ... | @@ -165,7 +165,7 @@ public: | ... | @@ -165,7 +165,7 @@ public: |
| 165 | template <class... _DynVals> | 165 | template <class... _DynVals> |
| 166 | requires(sizeof...(_DynVals) != __size_dynamic_) | 166 | requires(sizeof...(_DynVals) != __size_dynamic_) |
| 167 | _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(_DynVals... __vals) { | 167 | _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(_DynVals... __vals) { |
| 168 | static_assert((sizeof...(_DynVals) == __size_), "Invalid number of values."); | 168 | static_assert(sizeof...(_DynVals) == __size_, "Invalid number of values."); |
| 169 | _TDynamic __values[__size_] = {static_cast<_TDynamic>(__vals)...}; | 169 | _TDynamic __values[__size_] = {static_cast<_TDynamic>(__vals)...}; |
| 170 | for (size_t __i = 0; __i < __size_; __i++) { | 170 | for (size_t __i = 0; __i < __size_; __i++) { |
| 171 | _TStatic __static_val = _StaticValues::__get(__i); | 171 | _TStatic __static_val = _StaticValues::__get(__i); |
| ... | @@ -185,7 +185,7 @@ public: | ... | @@ -185,7 +185,7 @@ public: |
| 185 | template <class _Tp, size_t _Size> | 185 | template <class _Tp, size_t _Size> |
| 186 | requires(_Size != __size_dynamic_) | 186 | requires(_Size != __size_dynamic_) |
| 187 | _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(const span<_Tp, _Size>& __vals) { | 187 | _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(const span<_Tp, _Size>& __vals) { |
| 188 | static_assert((_Size == __size_) || (__size_ == dynamic_extent)); | 188 | static_assert(_Size == __size_ || __size_ == dynamic_extent); |
| 189 | for (size_t __i = 0; __i < __size_; __i++) { | 189 | for (size_t __i = 0; __i < __size_; __i++) { |
| 190 | _TStatic __static_val = _StaticValues::__get(__i); | 190 | _TStatic __static_val = _StaticValues::__get(__i); |
| 191 | if (__static_val == _DynTag) { | 191 | if (__static_val == _DynTag) { |
| ... | @@ -454,9 +454,22 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { | ... | @@ -454,9 +454,22 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { |
| 454 | template <class _IndexType, size_t _Rank> | 454 | template <class _IndexType, size_t _Rank> |
| 455 | using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type; | 455 | using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type; |
| 456 | 456 | ||
| 457 | # if _LIBCPP_STD_VER >= 26 | ||
| 458 | // [mdspan.extents.dims], alias template `dims` | ||
| 459 | template <size_t _Rank, class _IndexType = size_t> | ||
| 460 | using dims = dextents<_IndexType, _Rank>; | ||
| 461 | # endif | ||
| 462 | |||
| 457 | // Deduction guide for extents | 463 | // Deduction guide for extents |
| 464 | # if _LIBCPP_STD_VER >= 26 | ||
| 465 | template <class... _IndexTypes> | ||
| 466 | requires(is_convertible_v<_IndexTypes, size_t> && ...) | ||
| 467 | explicit extents(_IndexTypes...) -> extents<size_t, __maybe_static_ext<_IndexTypes>...>; | ||
| 468 | # else | ||
| 458 | template <class... _IndexTypes> | 469 | template <class... _IndexTypes> |
| 459 | extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>; | 470 | requires(is_convertible_v<_IndexTypes, size_t> && ...) |
| 471 | explicit extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>; | ||
| 472 | # endif | ||
| 460 | 473 | ||
| 461 | namespace __mdspan_detail { | 474 | namespace __mdspan_detail { |
| 462 | 475 |
lib/libcxx/include/__mdspan/layout_left.h+1-1| ... | @@ -67,7 +67,7 @@ private: | ... | @@ -67,7 +67,7 @@ private: |
| 67 | return true; | 67 | return true; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static_assert((extents_type::rank_dynamic() > 0) || __required_span_size_is_representable(extents_type()), | 70 | static_assert(extents_type::rank_dynamic() > 0 || __required_span_size_is_representable(extents_type()), |
| 71 | "layout_left::mapping product of static extents must be representable as index_type."); | 71 | "layout_left::mapping product of static extents must be representable as index_type."); |
| 72 | 72 | ||
| 73 | public: | 73 | public: |
lib/libcxx/include/__mdspan/layout_right.h+1-1| ... | @@ -66,7 +66,7 @@ private: | ... | @@ -66,7 +66,7 @@ private: |
| 66 | return true; | 66 | return true; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | static_assert((extents_type::rank_dynamic() > 0) || __required_span_size_is_representable(extents_type()), | 69 | static_assert(extents_type::rank_dynamic() > 0 || __required_span_size_is_representable(extents_type()), |
| 70 | "layout_right::mapping product of static extents must be representable as index_type."); | 70 | "layout_right::mapping product of static extents must be representable as index_type."); |
| 71 | 71 | ||
| 72 | public: | 72 | public: |
lib/libcxx/include/__mdspan/layout_stride.h+1-1| ... | @@ -149,7 +149,7 @@ private: | ... | @@ -149,7 +149,7 @@ private: |
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static_assert((extents_type::rank_dynamic() > 0) || __required_span_size_is_representable(extents_type()), | 152 | static_assert(extents_type::rank_dynamic() > 0 || __required_span_size_is_representable(extents_type()), |
| 153 | "layout_stride::mapping product of static extents must be representable as index_type."); | 153 | "layout_stride::mapping product of static extents must be representable as index_type."); |
| 154 | 154 | ||
| 155 | public: | 155 | public: |
lib/libcxx/include/__mdspan/mdspan.h+9-3| ... | @@ -27,7 +27,6 @@ | ... | @@ -27,7 +27,6 @@ |
| 27 | #include <__type_traits/is_array.h> | 27 | #include <__type_traits/is_array.h> |
| 28 | #include <__type_traits/is_constructible.h> | 28 | #include <__type_traits/is_constructible.h> |
| 29 | #include <__type_traits/is_convertible.h> | 29 | #include <__type_traits/is_convertible.h> |
| 30 | #include <__type_traits/is_default_constructible.h> | ||
| 31 | #include <__type_traits/is_nothrow_constructible.h> | 30 | #include <__type_traits/is_nothrow_constructible.h> |
| 32 | #include <__type_traits/is_pointer.h> | 31 | #include <__type_traits/is_pointer.h> |
| 33 | #include <__type_traits/is_same.h> | 32 | #include <__type_traits/is_same.h> |
| ... | @@ -267,10 +266,17 @@ private: | ... | @@ -267,10 +266,17 @@ private: |
| 267 | friend class mdspan; | 266 | friend class mdspan; |
| 268 | }; | 267 | }; |
| 269 | 268 | ||
| 269 | # if _LIBCPP_STD_VER >= 26 | ||
| 270 | template <class _ElementType, class... _OtherIndexTypes> | 270 | template <class _ElementType, class... _OtherIndexTypes> |
| 271 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) | 271 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) |
| 272 | explicit mdspan(_ElementType*, _OtherIndexTypes...) | 272 | explicit mdspan(_ElementType*, |
| 273 | -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>; | 273 | _OtherIndexTypes...) -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>; |
| 274 | # else | ||
| 275 | template <class _ElementType, class... _OtherIndexTypes> | ||
| 276 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) | ||
| 277 | explicit mdspan(_ElementType*, | ||
| 278 | _OtherIndexTypes...) -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>; | ||
| 279 | # endif | ||
| 274 | 280 | ||
| 275 | template <class _Pointer> | 281 | template <class _Pointer> |
| 276 | requires(is_pointer_v<remove_reference_t<_Pointer>>) | 282 | requires(is_pointer_v<remove_reference_t<_Pointer>>) |
lib/libcxx/include/__memory/allocate_at_least.h+6-20| ... | @@ -20,28 +20,14 @@ | ... | @@ -20,28 +20,14 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 23 | 22 | #if _LIBCPP_STD_VER >= 23 |
| 23 | template <class _Pointer> | ||
| 24 | struct allocation_result { | ||
| 25 | _Pointer ptr; | ||
| 26 | size_t count; | ||
| 27 | }; | ||
| 28 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); | ||
| 29 | |||
| 30 | template <class _Alloc> | ||
| 31 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<typename allocator_traits<_Alloc>::pointer> | ||
| 32 | allocate_at_least(_Alloc& __alloc, size_t __n) { | ||
| 33 | if constexpr (requires { __alloc.allocate_at_least(__n); }) { | ||
| 34 | return __alloc.allocate_at_least(__n); | ||
| 35 | } else { | ||
| 36 | return {__alloc.allocate(__n), __n}; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | 23 | ||
| 40 | template <class _Alloc> | 24 | template <class _Alloc> |
| 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) { |
| 42 | return std::allocate_at_least(__alloc, __n); | 26 | return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n); |
| 43 | } | 27 | } |
| 28 | |||
| 44 | #else | 29 | #else |
| 30 | |||
| 45 | template <class _Pointer> | 31 | template <class _Pointer> |
| 46 | struct __allocation_result { | 32 | struct __allocation_result { |
| 47 | _Pointer ptr; | 33 | _Pointer ptr; |
| ... | @@ -49,9 +35,9 @@ struct __allocation_result { | ... | @@ -49,9 +35,9 @@ struct __allocation_result { |
| 49 | }; | 35 | }; |
| 50 | 36 | ||
| 51 | template <class _Alloc> | 37 | template <class _Alloc> |
| 52 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 38 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI |
| 53 | __allocation_result<typename allocator_traits<_Alloc>::pointer> | 39 | _LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer> |
| 54 | __allocate_at_least(_Alloc& __alloc, size_t __n) { | 40 | __allocate_at_least(_Alloc& __alloc, size_t __n) { |
| 55 | return {__alloc.allocate(__n), __n}; | 41 | return {__alloc.allocate(__n), __n}; |
| 56 | } | 42 | } |
| 57 | 43 |
lib/libcxx/include/__memory/allocator.h+21-27| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | #include <__memory/addressof.h> | 14 | #include <__memory/addressof.h> |
| 15 | #include <__memory/allocate_at_least.h> | 15 | #include <__memory/allocate_at_least.h> |
| 16 | #include <__memory/allocator_traits.h> | 16 | #include <__memory/allocator_traits.h> |
| 17 | #include <__type_traits/is_const.h> | ||
| 17 | #include <__type_traits/is_constant_evaluated.h> | 18 | #include <__type_traits/is_constant_evaluated.h> |
| 18 | #include <__type_traits/is_same.h> | 19 | #include <__type_traits/is_same.h> |
| 19 | #include <__type_traits/is_void.h> | 20 | #include <__type_traits/is_void.h> |
| ... | @@ -31,19 +32,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -31,19 +32,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | template <class _Tp> | 32 | template <class _Tp> |
| 32 | class allocator; | 33 | class allocator; |
| 33 | 34 | ||
| 34 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | 35 | #if _LIBCPP_STD_VER <= 17 |
| 35 | # pragma clang deprecated( \ | ||
| 36 | _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS, \ | ||
| 37 | "_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS is deprecated in LLVM 18 and will be removed in LLVM 19") | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION) | ||
| 41 | // These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. | 36 | // These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. |
| 42 | // Specializing allocator<void> is deprecated, but not using it. | 37 | // Specializing allocator<void> is deprecated, but not using it. |
| 43 | template <> | 38 | template <> |
| 44 | class _LIBCPP_TEMPLATE_VIS allocator<void> { | 39 | class _LIBCPP_TEMPLATE_VIS allocator<void> { |
| 45 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 46 | |||
| 47 | public: | 40 | public: |
| 48 | _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; | 41 | _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; |
| 49 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; | 42 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; |
| ... | @@ -53,13 +46,12 @@ public: | ... | @@ -53,13 +46,12 @@ public: |
| 53 | struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { | 46 | struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { |
| 54 | typedef allocator<_Up> other; | 47 | typedef allocator<_Up> other; |
| 55 | }; | 48 | }; |
| 56 | # endif | ||
| 57 | }; | 49 | }; |
| 58 | 50 | ||
| 51 | // TODO(LLVM 20): Remove the escape hatch | ||
| 52 | # ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | ||
| 59 | template <> | 53 | template <> |
| 60 | class _LIBCPP_TEMPLATE_VIS allocator<const void> { | 54 | class _LIBCPP_TEMPLATE_VIS allocator<const void> { |
| 61 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | ||
| 62 | |||
| 63 | public: | 55 | public: |
| 64 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; | 56 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; |
| 65 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; | 57 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; |
| ... | @@ -69,9 +61,9 @@ public: | ... | @@ -69,9 +61,9 @@ public: |
| 69 | struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { | 61 | struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { |
| 70 | typedef allocator<_Up> other; | 62 | typedef allocator<_Up> other; |
| 71 | }; | 63 | }; |
| 72 | # endif | ||
| 73 | }; | 64 | }; |
| 74 | #endif | 65 | # endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST |
| 66 | #endif // _LIBCPP_STD_VER <= 17 | ||
| 75 | 67 | ||
| 76 | // This class provides a non-trivial default constructor to the class that derives from it | 68 | // This class provides a non-trivial default constructor to the class that derives from it |
| 77 | // if the condition is satisfied. | 69 | // if the condition is satisfied. |
| ... | @@ -100,6 +92,7 @@ struct __non_trivial_if<true, _Unique> { | ... | @@ -100,6 +92,7 @@ struct __non_trivial_if<true, _Unique> { |
| 100 | 92 | ||
| 101 | template <class _Tp> | 93 | template <class _Tp> |
| 102 | class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > { | 94 | class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > { |
| 95 | static_assert(!is_const<_Tp>::value, "std::allocator does not support const types"); | ||
| 103 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); | 96 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); |
| 104 | 97 | ||
| 105 | public: | 98 | public: |
| ... | @@ -116,7 +109,7 @@ public: | ... | @@ -116,7 +109,7 @@ public: |
| 116 | template <class _Up> | 109 | template <class _Up> |
| 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} | 110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} |
| 118 | 111 | ||
| 119 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { | 112 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { |
| 120 | if (__n > allocator_traits<allocator>::max_size(*this)) | 113 | if (__n > allocator_traits<allocator>::max_size(*this)) |
| 121 | __throw_bad_array_new_length(); | 114 | __throw_bad_array_new_length(); |
| 122 | if (__libcpp_is_constant_evaluated()) { | 115 | if (__libcpp_is_constant_evaluated()) { |
| ... | @@ -141,7 +134,7 @@ public: | ... | @@ -141,7 +134,7 @@ public: |
| 141 | } | 134 | } |
| 142 | 135 | ||
| 143 | // C++20 Removed members | 136 | // C++20 Removed members |
| 144 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | 137 | #if _LIBCPP_STD_VER <= 17 |
| 145 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer; | 138 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer; |
| 146 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; | 139 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; |
| 147 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference; | 140 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference; |
| ... | @@ -159,8 +152,7 @@ public: | ... | @@ -159,8 +152,7 @@ public: |
| 159 | return std::addressof(__x); | 152 | return std::addressof(__x); |
| 160 | } | 153 | } |
| 161 | 154 | ||
| 162 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* | 155 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) { |
| 163 | allocate(size_t __n, const void*) { | ||
| 164 | return allocate(__n); | 156 | return allocate(__n); |
| 165 | } | 157 | } |
| 166 | 158 | ||
| ... | @@ -177,6 +169,8 @@ public: | ... | @@ -177,6 +169,8 @@ public: |
| 177 | #endif | 169 | #endif |
| 178 | }; | 170 | }; |
| 179 | 171 | ||
| 172 | // TODO(LLVM 20): Remove the escape hatch | ||
| 173 | #ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | ||
| 180 | template <class _Tp> | 174 | template <class _Tp> |
| 181 | class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> | 175 | class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> |
| 182 | : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > { | 176 | : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > { |
| ... | @@ -187,16 +181,16 @@ public: | ... | @@ -187,16 +181,16 @@ public: |
| 187 | typedef ptrdiff_t difference_type; | 181 | typedef ptrdiff_t difference_type; |
| 188 | typedef const _Tp value_type; | 182 | typedef const _Tp value_type; |
| 189 | typedef true_type propagate_on_container_move_assignment; | 183 | typedef true_type propagate_on_container_move_assignment; |
| 190 | #if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS) | 184 | # if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS) |
| 191 | _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal; | 185 | _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal; |
| 192 | #endif | 186 | # endif |
| 193 | 187 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; | 188 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; |
| 195 | 189 | ||
| 196 | template <class _Up> | 190 | template <class _Up> |
| 197 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} | 191 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} |
| 198 | 192 | ||
| 199 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) { | 193 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) { |
| 200 | if (__n > allocator_traits<allocator>::max_size(*this)) | 194 | if (__n > allocator_traits<allocator>::max_size(*this)) |
| 201 | __throw_bad_array_new_length(); | 195 | __throw_bad_array_new_length(); |
| 202 | if (__libcpp_is_constant_evaluated()) { | 196 | if (__libcpp_is_constant_evaluated()) { |
| ... | @@ -206,11 +200,11 @@ public: | ... | @@ -206,11 +200,11 @@ public: |
| 206 | } | 200 | } |
| 207 | } | 201 | } |
| 208 | 202 | ||
| 209 | #if _LIBCPP_STD_VER >= 23 | 203 | # if _LIBCPP_STD_VER >= 23 |
| 210 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) { | 204 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) { |
| 211 | return {allocate(__n), __n}; | 205 | return {allocate(__n), __n}; |
| 212 | } | 206 | } |
| 213 | #endif | 207 | # endif |
| 214 | 208 | ||
| 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) { | 209 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) { |
| 216 | if (__libcpp_is_constant_evaluated()) { | 210 | if (__libcpp_is_constant_evaluated()) { |
| ... | @@ -221,7 +215,7 @@ public: | ... | @@ -221,7 +215,7 @@ public: |
| 221 | } | 215 | } |
| 222 | 216 | ||
| 223 | // C++20 Removed members | 217 | // C++20 Removed members |
| 224 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | 218 | # if _LIBCPP_STD_VER <= 17 |
| 225 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; | 219 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; |
| 226 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; | 220 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; |
| 227 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; | 221 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; |
| ... | @@ -236,8 +230,7 @@ public: | ... | @@ -236,8 +230,7 @@ public: |
| 236 | return std::addressof(__x); | 230 | return std::addressof(__x); |
| 237 | } | 231 | } |
| 238 | 232 | ||
| 239 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* | 233 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) { |
| 240 | allocate(size_t __n, const void*) { | ||
| 241 | return allocate(__n); | 234 | return allocate(__n); |
| 242 | } | 235 | } |
| 243 | 236 | ||
| ... | @@ -251,8 +244,9 @@ public: | ... | @@ -251,8 +244,9 @@ public: |
| 251 | } | 244 | } |
| 252 | 245 | ||
| 253 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); } | 246 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); } |
| 254 | #endif | 247 | # endif |
| 255 | }; | 248 | }; |
| 249 | #endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | ||
| 256 | 250 | ||
| 257 | template <class _Tp, class _Up> | 251 | template <class _Tp, class _Up> |
| 258 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 252 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
lib/libcxx/include/__memory/allocator_traits.h+52-33| ... | @@ -14,14 +14,15 @@ | ... | @@ -14,14 +14,15 @@ |
| 14 | #include <__memory/construct_at.h> | 14 | #include <__memory/construct_at.h> |
| 15 | #include <__memory/pointer_traits.h> | 15 | #include <__memory/pointer_traits.h> |
| 16 | #include <__type_traits/enable_if.h> | 16 | #include <__type_traits/enable_if.h> |
| 17 | #include <__type_traits/is_copy_constructible.h> | 17 | #include <__type_traits/is_constructible.h> |
| 18 | #include <__type_traits/is_empty.h> | 18 | #include <__type_traits/is_empty.h> |
| 19 | #include <__type_traits/is_move_constructible.h> | 19 | #include <__type_traits/is_same.h> |
| 20 | #include <__type_traits/make_unsigned.h> | 20 | #include <__type_traits/make_unsigned.h> |
| 21 | #include <__type_traits/remove_reference.h> | 21 | #include <__type_traits/remove_reference.h> |
| 22 | #include <__type_traits/void_t.h> | 22 | #include <__type_traits/void_t.h> |
| 23 | #include <__utility/declval.h> | 23 | #include <__utility/declval.h> |
| 24 | #include <__utility/forward.h> | 24 | #include <__utility/forward.h> |
| 25 | #include <cstddef> | ||
| 25 | #include <limits> | 26 | #include <limits> |
| 26 | 27 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -40,7 +41,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -40,7 +41,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {} | 41 | struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {} |
| 41 | 42 | ||
| 42 | // __pointer | 43 | // __pointer |
| 43 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer); | ||
| 44 | template <class _Tp, | 44 | template <class _Tp, |
| 45 | class _Alloc, | 45 | class _Alloc, |
| 46 | class _RawAlloc = __libcpp_remove_reference_t<_Alloc>, | 46 | class _RawAlloc = __libcpp_remove_reference_t<_Alloc>, |
| ... | @@ -231,6 +231,17 @@ struct __has_select_on_container_copy_construction< | ... | @@ -231,6 +231,17 @@ struct __has_select_on_container_copy_construction< |
| 231 | 231 | ||
| 232 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 232 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 233 | 233 | ||
| 234 | #if _LIBCPP_STD_VER >= 23 | ||
| 235 | |||
| 236 | template <class _Pointer, class _SizeType = size_t> | ||
| 237 | struct allocation_result { | ||
| 238 | _Pointer ptr; | ||
| 239 | _SizeType count; | ||
| 240 | }; | ||
| 241 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); | ||
| 242 | |||
| 243 | #endif // _LIBCPP_STD_VER | ||
| 244 | |||
| 234 | template <class _Alloc> | 245 | template <class _Alloc> |
| 235 | struct _LIBCPP_TEMPLATE_VIS allocator_traits { | 246 | struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 236 | using allocator_type = _Alloc; | 247 | using allocator_type = _Alloc; |
| ... | @@ -264,32 +275,44 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { | ... | @@ -264,32 +275,44 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 264 | }; | 275 | }; |
| 265 | #endif // _LIBCPP_CXX03_LANG | 276 | #endif // _LIBCPP_CXX03_LANG |
| 266 | 277 | ||
| 267 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 278 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 268 | allocate(allocator_type& __a, size_type __n) { | 279 | allocate(allocator_type& __a, size_type __n) { |
| 269 | return __a.allocate(__n); | 280 | return __a.allocate(__n); |
| 270 | } | 281 | } |
| 271 | 282 | ||
| 272 | template <class _Ap = _Alloc, class = __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> > | 283 | template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> |
| 273 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 284 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 274 | allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { | 285 | allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { |
| 275 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 286 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 276 | return __a.allocate(__n, __hint); | 287 | return __a.allocate(__n, __hint); |
| 277 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 288 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 278 | } | 289 | } |
| 279 | template <class _Ap = _Alloc, | 290 | template <class _Ap = _Alloc, |
| 280 | class = void, | 291 | class = void, |
| 281 | class = __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> > | 292 | __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> |
| 282 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 293 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 283 | allocate(allocator_type& __a, size_type __n, const_void_pointer) { | 294 | allocate(allocator_type& __a, size_type __n, const_void_pointer) { |
| 284 | return __a.allocate(__n); | 295 | return __a.allocate(__n); |
| 285 | } | 296 | } |
| 286 | 297 | ||
| 298 | #if _LIBCPP_STD_VER >= 23 | ||
| 299 | template <class _Ap = _Alloc> | ||
| 300 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr allocation_result<pointer, size_type> | ||
| 301 | allocate_at_least(_Ap& __alloc, size_type __n) { | ||
| 302 | if constexpr (requires { __alloc.allocate_at_least(__n); }) { | ||
| 303 | return __alloc.allocate_at_least(__n); | ||
| 304 | } else { | ||
| 305 | return {__alloc.allocate(__n), __n}; | ||
| 306 | } | ||
| 307 | } | ||
| 308 | #endif | ||
| 309 | |||
| 287 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void | 310 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void |
| 288 | deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT { | 311 | deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT { |
| 289 | __a.deallocate(__p, __n); | 312 | __a.deallocate(__p, __n); |
| 290 | } | 313 | } |
| 291 | 314 | ||
| 292 | template <class _Tp, class... _Args, class = __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> > | 315 | template <class _Tp, class... _Args, __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0> |
| 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void | 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void |
| 294 | construct(allocator_type& __a, _Tp* __p, _Args&&... __args) { | 317 | construct(allocator_type& __a, _Tp* __p, _Args&&... __args) { |
| 295 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 318 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | @@ -298,43 +321,43 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { | ... | @@ -298,43 +321,43 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 298 | } | 321 | } |
| 299 | template <class _Tp, | 322 | template <class _Tp, |
| 300 | class... _Args, | 323 | class... _Args, |
| 301 | class = void, | 324 | class = void, |
| 302 | class = __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> > | 325 | __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0> |
| 303 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void | 326 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void |
| 304 | construct(allocator_type&, _Tp* __p, _Args&&... __args) { | 327 | construct(allocator_type&, _Tp* __p, _Args&&... __args) { |
| 305 | std::__construct_at(__p, std::forward<_Args>(__args)...); | 328 | std::__construct_at(__p, std::forward<_Args>(__args)...); |
| 306 | } | 329 | } |
| 307 | 330 | ||
| 308 | template <class _Tp, class = __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> > | 331 | template <class _Tp, __enable_if_t<__has_destroy<allocator_type, _Tp*>::value, int> = 0> |
| 309 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) { | 332 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) { |
| 310 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 333 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 311 | __a.destroy(__p); | 334 | __a.destroy(__p); |
| 312 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 335 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 313 | } | 336 | } |
| 314 | template <class _Tp, class = void, class = __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> > | 337 | template <class _Tp, class = void, __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value, int> = 0> |
| 315 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) { | 338 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) { |
| 316 | std::__destroy_at(__p); | 339 | std::__destroy_at(__p); |
| 317 | } | 340 | } |
| 318 | 341 | ||
| 319 | template <class _Ap = _Alloc, class = __enable_if_t<__has_max_size<const _Ap>::value> > | 342 | template <class _Ap = _Alloc, __enable_if_t<__has_max_size<const _Ap>::value, int> = 0> |
| 320 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT { | 343 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT { |
| 321 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 344 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 322 | return __a.max_size(); | 345 | return __a.max_size(); |
| 323 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 346 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 324 | } | 347 | } |
| 325 | template <class _Ap = _Alloc, class = void, class = __enable_if_t<!__has_max_size<const _Ap>::value> > | 348 | template <class _Ap = _Alloc, class = void, __enable_if_t<!__has_max_size<const _Ap>::value, int> = 0> |
| 326 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT { | 349 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT { |
| 327 | return numeric_limits<size_type>::max() / sizeof(value_type); | 350 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 328 | } | 351 | } |
| 329 | 352 | ||
| 330 | template <class _Ap = _Alloc, class = __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> > | 353 | template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value, int> = 0> |
| 331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type | 354 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type |
| 332 | select_on_container_copy_construction(const allocator_type& __a) { | 355 | select_on_container_copy_construction(const allocator_type& __a) { |
| 333 | return __a.select_on_container_copy_construction(); | 356 | return __a.select_on_container_copy_construction(); |
| 334 | } | 357 | } |
| 335 | template <class _Ap = _Alloc, | 358 | template <class _Ap = _Alloc, |
| 336 | class = void, | 359 | class = void, |
| 337 | class = __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> > | 360 | __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value, int> = 0> |
| 338 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type | 361 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type |
| 339 | select_on_container_copy_construction(const allocator_type& __a) { | 362 | select_on_container_copy_construction(const allocator_type& __a) { |
| 340 | return __a; | 363 | return __a; |
| ... | @@ -349,6 +372,14 @@ template <class _Traits, class _Tp> | ... | @@ -349,6 +372,14 @@ template <class _Traits, class _Tp> |
| 349 | using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other; | 372 | using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other; |
| 350 | #endif | 373 | #endif |
| 351 | 374 | ||
| 375 | template <class _Alloc> | ||
| 376 | struct __check_valid_allocator : true_type { | ||
| 377 | using _Traits = std::allocator_traits<_Alloc>; | ||
| 378 | static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value, | ||
| 379 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 380 | "original allocator"); | ||
| 381 | }; | ||
| 382 | |||
| 352 | // __is_default_allocator | 383 | // __is_default_allocator |
| 353 | template <class _Tp> | 384 | template <class _Tp> |
| 354 | struct __is_default_allocator : false_type {}; | 385 | struct __is_default_allocator : false_type {}; |
| ... | @@ -384,18 +415,6 @@ struct __is_cpp17_copy_insertable< | ... | @@ -384,18 +415,6 @@ struct __is_cpp17_copy_insertable< |
| 384 | __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > > | 415 | __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > > |
| 385 | : __is_cpp17_move_insertable<_Alloc> {}; | 416 | : __is_cpp17_move_insertable<_Alloc> {}; |
| 386 | 417 | ||
| 387 | // ASan choices | ||
| 388 | #ifndef _LIBCPP_HAS_NO_ASAN | ||
| 389 | # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 | ||
| 390 | #endif | ||
| 391 | |||
| 392 | #ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS | ||
| 393 | template <class _Alloc> | ||
| 394 | struct __asan_annotate_container_with_allocator : true_type {}; | ||
| 395 | template <class _Tp> | ||
| 396 | struct __asan_annotate_container_with_allocator<allocator<_Tp> > : true_type {}; | ||
| 397 | #endif | ||
| 398 | |||
| 399 | #undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX | 418 | #undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX |
| 400 | 419 | ||
| 401 | _LIBCPP_END_NAMESPACE_STD | 420 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__memory/compressed_pair.h+9-9| ... | @@ -11,13 +11,12 @@ | ... | @@ -11,13 +11,12 @@ |
| 11 | #define _LIBCPP___MEMORY_COMPRESSED_PAIR_H | 11 | #define _LIBCPP___MEMORY_COMPRESSED_PAIR_H |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__fwd/get.h> | ||
| 15 | #include <__fwd/tuple.h> | 14 | #include <__fwd/tuple.h> |
| 16 | #include <__tuple/tuple_indices.h> | 15 | #include <__tuple/tuple_indices.h> |
| 17 | #include <__type_traits/decay.h> | 16 | #include <__type_traits/decay.h> |
| 18 | #include <__type_traits/dependent_type.h> | 17 | #include <__type_traits/dependent_type.h> |
| 19 | #include <__type_traits/enable_if.h> | 18 | #include <__type_traits/enable_if.h> |
| 20 | #include <__type_traits/is_default_constructible.h> | 19 | #include <__type_traits/is_constructible.h> |
| 21 | #include <__type_traits/is_empty.h> | 20 | #include <__type_traits/is_empty.h> |
| 22 | #include <__type_traits/is_final.h> | 21 | #include <__type_traits/is_final.h> |
| 23 | #include <__type_traits/is_same.h> | 22 | #include <__type_traits/is_same.h> |
| ... | @@ -49,7 +48,7 @@ struct __compressed_pair_elem { | ... | @@ -49,7 +48,7 @@ struct __compressed_pair_elem { |
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} | 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} |
| 50 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {} | 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {} |
| 51 | 50 | ||
| 52 | template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value> > | 51 | template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0> |
| 53 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) | 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) |
| 54 | : __value_(std::forward<_Up>(__u)) {} | 53 | : __value_(std::forward<_Up>(__u)) {} |
| 55 | 54 | ||
| ... | @@ -78,7 +77,7 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { | ... | @@ -78,7 +77,7 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { |
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} | 77 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} |
| 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {} | 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {} |
| 80 | 79 | ||
| 81 | template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value> > | 80 | template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0> |
| 82 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) | 81 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) |
| 83 | : __value_type(std::forward<_Up>(__u)) {} | 82 | : __value_type(std::forward<_Up>(__u)) {} |
| 84 | 83 | ||
| ... | @@ -108,9 +107,10 @@ public: | ... | @@ -108,9 +107,10 @@ public: |
| 108 | using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>; | 107 | using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>; |
| 109 | using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>; | 108 | using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>; |
| 110 | 109 | ||
| 111 | template <bool _Dummy = true, | 110 | template <bool _Dummy = true, |
| 112 | class = __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value && | 111 | __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value && |
| 113 | __dependent_type<is_default_constructible<_T2>, _Dummy>::value > > | 112 | __dependent_type<is_default_constructible<_T2>, _Dummy>::value, |
| 113 | int> = 0> | ||
| 114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair() | 114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair() |
| 115 | : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} | 115 | : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} |
| 116 | 116 | ||
| ... | @@ -150,7 +150,7 @@ public: | ... | @@ -150,7 +150,7 @@ public: |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x) | 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x) |
| 153 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) { | 153 | _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { |
| 154 | using std::swap; | 154 | using std::swap; |
| 155 | swap(first(), __x.first()); | 155 | swap(first(), __x.first()); |
| 156 | swap(second(), __x.second()); | 156 | swap(second(), __x.second()); |
| ... | @@ -160,7 +160,7 @@ public: | ... | @@ -160,7 +160,7 @@ public: |
| 160 | template <class _T1, class _T2> | 160 | template <class _T1, class _T2> |
| 161 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 161 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 162 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) | 162 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) |
| 163 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) { | 163 | _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { |
| 164 | __x.swap(__y); | 164 | __x.swap(__y); |
| 165 | } | 165 | } |
| 166 | 166 |
lib/libcxx/include/__memory/construct_at.h+1-1| ... | @@ -44,7 +44,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __ | ... | @@ -44,7 +44,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __ |
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> | 46 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> |
| 47 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) { | 47 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __location, _Args&&... __args) { |
| 48 | #if _LIBCPP_STD_VER >= 20 | 48 | #if _LIBCPP_STD_VER >= 20 |
| 49 | return std::construct_at(__location, std::forward<_Args>(__args)...); | 49 | return std::construct_at(__location, std::forward<_Args>(__args)...); |
| 50 | #else | 50 | #else |
lib/libcxx/include/__memory/inout_ptr.h created+109| ... | @@ -0,0 +1,109 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___INOUT_PTR_H | ||
| 11 | #define _LIBCPP___INOUT_PTR_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__memory/addressof.h> | ||
| 15 | #include <__memory/pointer_traits.h> | ||
| 16 | #include <__memory/shared_ptr.h> | ||
| 17 | #include <__memory/unique_ptr.h> | ||
| 18 | #include <__type_traits/is_same.h> | ||
| 19 | #include <__type_traits/is_specialization.h> | ||
| 20 | #include <__type_traits/is_void.h> | ||
| 21 | #include <__utility/forward.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | #include <tuple> | ||
| 24 | |||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 26 | # pragma GCC system_header | ||
| 27 | #endif | ||
| 28 | |||
| 29 | _LIBCPP_PUSH_MACROS | ||
| 30 | #include <__undef_macros> | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | #if _LIBCPP_STD_VER >= 23 | ||
| 35 | |||
| 36 | template <class _Smart, class _Pointer, class... _Args> | ||
| 37 | class _LIBCPP_TEMPLATE_VIS inout_ptr_t { | ||
| 38 | static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr."); | ||
| 39 | |||
| 40 | public: | ||
| 41 | _LIBCPP_HIDE_FROM_ABI explicit inout_ptr_t(_Smart& __smart, _Args... __args) | ||
| 42 | : __s_(__smart), __a_(std::forward<_Args>(__args)...), __p_([&__smart] { | ||
| 43 | if constexpr (is_pointer_v<_Smart>) { | ||
| 44 | return __smart; | ||
| 45 | } else { | ||
| 46 | return __smart.get(); | ||
| 47 | } | ||
| 48 | }()) { | ||
| 49 | if constexpr (requires { __s_.release(); }) { | ||
| 50 | __s_.release(); | ||
| 51 | } else { | ||
| 52 | __s_ = _Smart(); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | _LIBCPP_HIDE_FROM_ABI inout_ptr_t(const inout_ptr_t&) = delete; | ||
| 57 | |||
| 58 | _LIBCPP_HIDE_FROM_ABI ~inout_ptr_t() { | ||
| 59 | // LWG-3897 inout_ptr will not update raw pointer to null | ||
| 60 | if constexpr (!is_pointer_v<_Smart>) { | ||
| 61 | if (!__p_) { | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>; | ||
| 67 | if constexpr (is_pointer_v<_Smart>) { | ||
| 68 | std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, | ||
| 69 | std::move(__a_)); | ||
| 70 | } else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) { | ||
| 71 | std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, | ||
| 72 | std::move(__a_)); | ||
| 73 | } else { | ||
| 74 | static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>, | ||
| 75 | "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args..."); | ||
| 76 | std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, | ||
| 77 | std::move(__a_)); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); } | ||
| 82 | |||
| 83 | _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept | ||
| 84 | requires(!is_same_v<_Pointer, void*>) | ||
| 85 | { | ||
| 86 | static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer."); | ||
| 87 | |||
| 88 | return reinterpret_cast<void**>(static_cast<_Pointer*>(*this)); | ||
| 89 | } | ||
| 90 | |||
| 91 | private: | ||
| 92 | _Smart& __s_; | ||
| 93 | tuple<_Args...> __a_; | ||
| 94 | _Pointer __p_; | ||
| 95 | }; | ||
| 96 | |||
| 97 | template <class _Pointer = void, class _Smart, class... _Args> | ||
| 98 | _LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) { | ||
| 99 | using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; | ||
| 100 | return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); | ||
| 101 | } | ||
| 102 | |||
| 103 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 104 | |||
| 105 | _LIBCPP_END_NAMESPACE_STD | ||
| 106 | |||
| 107 | _LIBCPP_POP_MACROS | ||
| 108 | |||
| 109 | #endif // _LIBCPP___INOUT_PTR_H | ||
lib/libcxx/include/__memory/out_ptr.h created+101| ... | @@ -0,0 +1,101 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___OUT_PTR_H | ||
| 11 | #define _LIBCPP___OUT_PTR_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__memory/addressof.h> | ||
| 15 | #include <__memory/pointer_traits.h> | ||
| 16 | #include <__memory/shared_ptr.h> | ||
| 17 | #include <__memory/unique_ptr.h> | ||
| 18 | #include <__type_traits/is_specialization.h> | ||
| 19 | #include <__type_traits/is_void.h> | ||
| 20 | #include <__utility/forward.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | #include <tuple> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | #if _LIBCPP_STD_VER >= 23 | ||
| 34 | |||
| 35 | template <class _Smart, class _Pointer, class... _Args> | ||
| 36 | class _LIBCPP_TEMPLATE_VIS out_ptr_t { | ||
| 37 | static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0, | ||
| 38 | "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported."); | ||
| 39 | |||
| 40 | public: | ||
| 41 | _LIBCPP_HIDE_FROM_ABI explicit out_ptr_t(_Smart& __smart, _Args... __args) | ||
| 42 | : __s_(__smart), __a_(std::forward<_Args>(__args)...), __p_() { | ||
| 43 | using _Ptr = decltype(__smart); | ||
| 44 | if constexpr (__resettable_smart_pointer<_Ptr>) { | ||
| 45 | __s_.reset(); | ||
| 46 | } else if constexpr (is_constructible_v<_Smart>) { | ||
| 47 | __s_ = _Smart(); | ||
| 48 | } else { | ||
| 49 | static_assert(__resettable_smart_pointer<_Ptr> || is_constructible_v<_Smart>, | ||
| 50 | "The adapted pointer type must have a reset() member function or be default constructible."); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | _LIBCPP_HIDE_FROM_ABI out_ptr_t(const out_ptr_t&) = delete; | ||
| 55 | |||
| 56 | _LIBCPP_HIDE_FROM_ABI ~out_ptr_t() { | ||
| 57 | if (!__p_) { | ||
| 58 | return; | ||
| 59 | } | ||
| 60 | |||
| 61 | using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>; | ||
| 62 | if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) { | ||
| 63 | std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, | ||
| 64 | std::move(__a_)); | ||
| 65 | } else { | ||
| 66 | static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>, | ||
| 67 | "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args..."); | ||
| 68 | std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, | ||
| 69 | std::move(__a_)); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); } | ||
| 74 | |||
| 75 | _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept | ||
| 76 | requires(!is_same_v<_Pointer, void*>) | ||
| 77 | { | ||
| 78 | static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer."); | ||
| 79 | |||
| 80 | return reinterpret_cast<void**>(static_cast<_Pointer*>(*this)); | ||
| 81 | } | ||
| 82 | |||
| 83 | private: | ||
| 84 | _Smart& __s_; | ||
| 85 | tuple<_Args...> __a_; | ||
| 86 | _Pointer __p_ = _Pointer(); | ||
| 87 | }; | ||
| 88 | |||
| 89 | template <class _Pointer = void, class _Smart, class... _Args> | ||
| 90 | _LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) { | ||
| 91 | using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; | ||
| 92 | return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); | ||
| 93 | } | ||
| 94 | |||
| 95 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 96 | |||
| 97 | _LIBCPP_END_NAMESPACE_STD | ||
| 98 | |||
| 99 | _LIBCPP_POP_MACROS | ||
| 100 | |||
| 101 | #endif // _LIBCPP___OUT_PTR_H | ||
lib/libcxx/include/__memory/pointer_traits.h+76-14| ... | @@ -20,19 +20,28 @@ | ... | @@ -20,19 +20,28 @@ |
| 20 | #include <__type_traits/is_void.h> | 20 | #include <__type_traits/is_void.h> |
| 21 | #include <__type_traits/void_t.h> | 21 | #include <__type_traits/void_t.h> |
| 22 | #include <__utility/declval.h> | 22 | #include <__utility/declval.h> |
| 23 | #include <__utility/forward.h> | ||
| 23 | #include <cstddef> | 24 | #include <cstddef> |
| 24 | 25 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | # pragma GCC system_header | 27 | # pragma GCC system_header |
| 27 | #endif | 28 | #endif |
| 28 | 29 | ||
| 30 | _LIBCPP_PUSH_MACROS | ||
| 31 | #include <__undef_macros> | ||
| 32 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 34 | ||
| 31 | template <class _Tp, class = void> | 35 | // clang-format off |
| 32 | struct __has_element_type : false_type {}; | 36 | #define _LIBCPP_CLASS_TRAITS_HAS_XXX(NAME, PROPERTY) \ |
| 37 | template <class _Tp, class = void> \ | ||
| 38 | struct NAME : false_type {}; \ | ||
| 39 | template <class _Tp> \ | ||
| 40 | struct NAME<_Tp, __void_t<typename _Tp::PROPERTY> > : true_type {} | ||
| 41 | // clang-format on | ||
| 33 | 42 | ||
| 34 | template <class _Tp> | 43 | _LIBCPP_CLASS_TRAITS_HAS_XXX(__has_pointer, pointer); |
| 35 | struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {}; | 44 | _LIBCPP_CLASS_TRAITS_HAS_XXX(__has_element_type, element_type); |
| 36 | 45 | ||
| 37 | template <class _Ptr, bool = __has_element_type<_Ptr>::value> | 46 | template <class _Ptr, bool = __has_element_type<_Ptr>::value> |
| 38 | struct __pointer_traits_element_type {}; | 47 | struct __pointer_traits_element_type {}; |
| ... | @@ -201,17 +210,17 @@ struct _IsFancyPointer { | ... | @@ -201,17 +210,17 @@ struct _IsFancyPointer { |
| 201 | }; | 210 | }; |
| 202 | 211 | ||
| 203 | // enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers | 212 | // enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers |
| 204 | template <class _Pointer, class = __enable_if_t< _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value > > | 213 | template <class _Pointer, __enable_if_t< _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value, int> = 0> |
| 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 214 | _LIBCPP_HIDE_FROM_ABI |
| 206 | __decay_t<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))> | 215 | _LIBCPP_CONSTEXPR __decay_t<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))> |
| 207 | __to_address(const _Pointer& __p) _NOEXCEPT { | 216 | __to_address(const _Pointer& __p) _NOEXCEPT { |
| 208 | return __to_address_helper<_Pointer>::__call(__p); | 217 | return __to_address_helper<_Pointer>::__call(__p); |
| 209 | } | 218 | } |
| 210 | 219 | ||
| 211 | template <class _Pointer, class> | 220 | template <class _Pointer, class> |
| 212 | struct __to_address_helper { | 221 | struct __to_address_helper { |
| 213 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static decltype(std::__to_address( | 222 | _LIBCPP_HIDE_FROM_ABI |
| 214 | std::declval<const _Pointer&>().operator->())) | 223 | _LIBCPP_CONSTEXPR static decltype(std::__to_address(std::declval<const _Pointer&>().operator->())) |
| 215 | __call(const _Pointer& __p) _NOEXCEPT { | 224 | __call(const _Pointer& __p) _NOEXCEPT { |
| 216 | return std::__to_address(__p.operator->()); | 225 | return std::__to_address(__p.operator->()); |
| 217 | } | 226 | } |
| ... | @@ -220,8 +229,8 @@ struct __to_address_helper { | ... | @@ -220,8 +229,8 @@ struct __to_address_helper { |
| 220 | template <class _Pointer> | 229 | template <class _Pointer> |
| 221 | struct __to_address_helper<_Pointer, | 230 | struct __to_address_helper<_Pointer, |
| 222 | decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> { | 231 | decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> { |
| 223 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static decltype(pointer_traits<_Pointer>::to_address( | 232 | _LIBCPP_HIDE_FROM_ABI |
| 224 | std::declval<const _Pointer&>())) | 233 | _LIBCPP_CONSTEXPR static decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>())) |
| 225 | __call(const _Pointer& __p) _NOEXCEPT { | 234 | __call(const _Pointer& __p) _NOEXCEPT { |
| 226 | return pointer_traits<_Pointer>::to_address(__p); | 235 | return pointer_traits<_Pointer>::to_address(__p); |
| 227 | } | 236 | } |
| ... | @@ -234,12 +243,65 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept { | ... | @@ -234,12 +243,65 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept { |
| 234 | } | 243 | } |
| 235 | 244 | ||
| 236 | template <class _Pointer> | 245 | template <class _Pointer> |
| 237 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(const _Pointer& __p) noexcept | 246 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 238 | -> decltype(std::__to_address(__p)) { | 247 | to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) { |
| 239 | return std::__to_address(__p); | 248 | return std::__to_address(__p); |
| 240 | } | 249 | } |
| 241 | #endif | 250 | #endif |
| 242 | 251 | ||
| 252 | #if _LIBCPP_STD_VER >= 23 | ||
| 253 | |||
| 254 | template <class _Tp> | ||
| 255 | struct __pointer_of {}; | ||
| 256 | |||
| 257 | template <class _Tp> | ||
| 258 | requires(__has_pointer<_Tp>::value) | ||
| 259 | struct __pointer_of<_Tp> { | ||
| 260 | using type = typename _Tp::pointer; | ||
| 261 | }; | ||
| 262 | |||
| 263 | template <class _Tp> | ||
| 264 | requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value) | ||
| 265 | struct __pointer_of<_Tp> { | ||
| 266 | using type = typename _Tp::element_type*; | ||
| 267 | }; | ||
| 268 | |||
| 269 | template <class _Tp> | ||
| 270 | requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value && | ||
| 271 | __has_element_type<pointer_traits<_Tp>>::value) | ||
| 272 | struct __pointer_of<_Tp> { | ||
| 273 | using type = typename pointer_traits<_Tp>::element_type*; | ||
| 274 | }; | ||
| 275 | |||
| 276 | template <typename _Tp> | ||
| 277 | using __pointer_of_t = typename __pointer_of<_Tp>::type; | ||
| 278 | |||
| 279 | template <class _Tp, class _Up> | ||
| 280 | struct __pointer_of_or { | ||
| 281 | using type _LIBCPP_NODEBUG = _Up; | ||
| 282 | }; | ||
| 283 | |||
| 284 | template <class _Tp, class _Up> | ||
| 285 | requires requires { typename __pointer_of_t<_Tp>; } | ||
| 286 | struct __pointer_of_or<_Tp, _Up> { | ||
| 287 | using type _LIBCPP_NODEBUG = __pointer_of_t<_Tp>; | ||
| 288 | }; | ||
| 289 | |||
| 290 | template <typename _Tp, typename _Up> | ||
| 291 | using __pointer_of_or_t = typename __pointer_of_or<_Tp, _Up>::type; | ||
| 292 | |||
| 293 | template <class _Smart> | ||
| 294 | concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); }; | ||
| 295 | |||
| 296 | template <class _Smart, class _Pointer, class... _Args> | ||
| 297 | concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p, _Args... __args) { | ||
| 298 | __s.reset(static_cast<__pointer_of_or_t<_Smart, _Pointer>>(__p), std::forward<_Args>(__args)...); | ||
| 299 | }; | ||
| 300 | |||
| 301 | #endif | ||
| 302 | |||
| 243 | _LIBCPP_END_NAMESPACE_STD | 303 | _LIBCPP_END_NAMESPACE_STD |
| 244 | 304 | ||
| 305 | _LIBCPP_POP_MACROS | ||
| 306 | |||
| 245 | #endif // _LIBCPP___MEMORY_POINTER_TRAITS_H | 307 | #endif // _LIBCPP___MEMORY_POINTER_TRAITS_H |
lib/libcxx/include/__memory/shared_ptr.h+73-49| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___MEMORY_SHARED_PTR_H | 10 | #ifndef _LIBCPP___MEMORY_SHARED_PTR_H |
| 11 | #define _LIBCPP___MEMORY_SHARED_PTR_H | 11 | #define _LIBCPP___MEMORY_SHARED_PTR_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__compare/compare_three_way.h> | 13 | #include <__compare/compare_three_way.h> |
| 15 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 16 | #include <__config> | 15 | #include <__config> |
| ... | @@ -37,8 +36,8 @@ | ... | @@ -37,8 +36,8 @@ |
| 37 | #include <__type_traits/disjunction.h> | 36 | #include <__type_traits/disjunction.h> |
| 38 | #include <__type_traits/is_array.h> | 37 | #include <__type_traits/is_array.h> |
| 39 | #include <__type_traits/is_bounded_array.h> | 38 | #include <__type_traits/is_bounded_array.h> |
| 39 | #include <__type_traits/is_constructible.h> | ||
| 40 | #include <__type_traits/is_convertible.h> | 40 | #include <__type_traits/is_convertible.h> |
| 41 | #include <__type_traits/is_move_constructible.h> | ||
| 42 | #include <__type_traits/is_reference.h> | 41 | #include <__type_traits/is_reference.h> |
| 43 | #include <__type_traits/is_unbounded_array.h> | 42 | #include <__type_traits/is_unbounded_array.h> |
| 44 | #include <__type_traits/nat.h> | 43 | #include <__type_traits/nat.h> |
| ... | @@ -260,7 +259,7 @@ struct __shared_ptr_emplace : __shared_weak_count { | ... | @@ -260,7 +259,7 @@ struct __shared_ptr_emplace : __shared_weak_count { |
| 260 | class _Allocator = _Alloc, | 259 | class _Allocator = _Alloc, |
| 261 | __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> | 260 | __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> |
| 262 | _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) { | 261 | _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) { |
| 263 | using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type; | 262 | using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __remove_cv_t<_Tp> >::type; |
| 264 | _TpAlloc __tmp(*__get_alloc()); | 263 | _TpAlloc __tmp(*__get_alloc()); |
| 265 | allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...); | 264 | allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...); |
| 266 | } | 265 | } |
| ... | @@ -279,7 +278,7 @@ private: | ... | @@ -279,7 +278,7 @@ private: |
| 279 | template <class _Allocator = _Alloc, | 278 | template <class _Allocator = _Alloc, |
| 280 | __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> | 279 | __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> |
| 281 | _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT { | 280 | _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT { |
| 282 | using _TpAlloc = typename __allocator_traits_rebind<_Allocator, _Tp>::type; | 281 | using _TpAlloc = typename __allocator_traits_rebind<_Allocator, __remove_cv_t<_Tp> >::type; |
| 283 | _TpAlloc __tmp(*__get_alloc()); | 282 | _TpAlloc __tmp(*__get_alloc()); |
| 284 | allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem()); | 283 | allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem()); |
| 285 | } | 284 | } |
| ... | @@ -404,6 +403,9 @@ struct __shared_ptr_deleter_ctor_reqs { | ... | @@ -404,6 +403,9 @@ struct __shared_ptr_deleter_ctor_reqs { |
| 404 | __well_formed_deleter<_Dp, _Yp*>::value; | 403 | __well_formed_deleter<_Dp, _Yp*>::value; |
| 405 | }; | 404 | }; |
| 406 | 405 | ||
| 406 | template <class _Dp> | ||
| 407 | using __shared_ptr_nullptr_deleter_ctor_reqs = _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >; | ||
| 408 | |||
| 407 | #if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI) | 409 | #if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI) |
| 408 | # define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__)) | 410 | # define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__)) |
| 409 | #else | 411 | #else |
| ... | @@ -412,6 +414,8 @@ struct __shared_ptr_deleter_ctor_reqs { | ... | @@ -412,6 +414,8 @@ struct __shared_ptr_deleter_ctor_reqs { |
| 412 | 414 | ||
| 413 | template <class _Tp> | 415 | template <class _Tp> |
| 414 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { | 416 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { |
| 417 | struct __nullptr_sfinae_tag {}; | ||
| 418 | |||
| 415 | public: | 419 | public: |
| 416 | #if _LIBCPP_STD_VER >= 17 | 420 | #if _LIBCPP_STD_VER >= 17 |
| 417 | typedef weak_ptr<_Tp> weak_type; | 421 | typedef weak_ptr<_Tp> weak_type; |
| ... | @@ -420,6 +424,10 @@ public: | ... | @@ -420,6 +424,10 @@ public: |
| 420 | typedef _Tp element_type; | 424 | typedef _Tp element_type; |
| 421 | #endif | 425 | #endif |
| 422 | 426 | ||
| 427 | // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require | ||
| 428 | // any bookkeeping, so it's always trivially relocatable. | ||
| 429 | using __trivially_relocatable = shared_ptr; | ||
| 430 | |||
| 423 | private: | 431 | private: |
| 424 | element_type* __ptr_; | 432 | element_type* __ptr_; |
| 425 | __shared_weak_count* __cntrl_; | 433 | __shared_weak_count* __cntrl_; |
| ... | @@ -430,15 +438,16 @@ public: | ... | @@ -430,15 +438,16 @@ public: |
| 430 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {} | 438 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {} |
| 431 | 439 | ||
| 432 | template <class _Yp, | 440 | template <class _Yp, |
| 433 | class = __enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp> | 441 | __enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp> |
| 434 | // In C++03 we get errors when trying to do SFINAE with the | 442 | // In C++03 we get errors when trying to do SFINAE with the |
| 435 | // delete operator, so we always pretend that it's deletable. | 443 | // delete operator, so we always pretend that it's deletable. |
| 436 | // The same happens on GCC. | 444 | // The same happens on GCC. |
| 437 | #if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC) | 445 | #if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC) |
| 438 | , | 446 | , |
| 439 | _If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> > | 447 | _If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> > |
| 440 | #endif | 448 | #endif |
| 441 | >::value > > | 449 | >::value, |
| 450 | int> = 0> | ||
| 442 | _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(_Yp* __p) : __ptr_(__p) { | 451 | _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(_Yp* __p) : __ptr_(__p) { |
| 443 | unique_ptr<_Yp> __hold(__p); | 452 | unique_ptr<_Yp> __hold(__p); |
| 444 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | 453 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| ... | @@ -448,7 +457,7 @@ public: | ... | @@ -448,7 +457,7 @@ public: |
| 448 | __enable_weak_this(__p, __p); | 457 | __enable_weak_this(__p, __p); |
| 449 | } | 458 | } |
| 450 | 459 | ||
| 451 | template <class _Yp, class _Dp, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> > | 460 | template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 452 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { | 461 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { |
| 453 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 462 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 454 | try { | 463 | try { |
| ... | @@ -472,7 +481,7 @@ public: | ... | @@ -472,7 +481,7 @@ public: |
| 472 | template <class _Yp, | 481 | template <class _Yp, |
| 473 | class _Dp, | 482 | class _Dp, |
| 474 | class _Alloc, | 483 | class _Alloc, |
| 475 | class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> > | 484 | __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 476 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { | 485 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { |
| 477 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 486 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 478 | try { | 487 | try { |
| ... | @@ -499,7 +508,11 @@ public: | ... | @@ -499,7 +508,11 @@ public: |
| 499 | } | 508 | } |
| 500 | 509 | ||
| 501 | template <class _Dp> | 510 | template <class _Dp> |
| 502 | _LIBCPP_HIDE_FROM_ABI shared_ptr(nullptr_t __p, _Dp __d) : __ptr_(nullptr) { | 511 | _LIBCPP_HIDE_FROM_ABI shared_ptr( |
| 512 | nullptr_t __p, | ||
| 513 | _Dp __d, | ||
| 514 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) | ||
| 515 | : __ptr_(nullptr) { | ||
| 503 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 516 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 504 | try { | 517 | try { |
| 505 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 518 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| ... | @@ -519,7 +532,12 @@ public: | ... | @@ -519,7 +532,12 @@ public: |
| 519 | } | 532 | } |
| 520 | 533 | ||
| 521 | template <class _Dp, class _Alloc> | 534 | template <class _Dp, class _Alloc> |
| 522 | _LIBCPP_HIDE_FROM_ABI shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) : __ptr_(nullptr) { | 535 | _LIBCPP_HIDE_FROM_ABI shared_ptr( |
| 536 | nullptr_t __p, | ||
| 537 | _Dp __d, | ||
| 538 | _Alloc __a, | ||
| 539 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) | ||
| 540 | : __ptr_(nullptr) { | ||
| 523 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 541 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 524 | try { | 542 | try { |
| 525 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 543 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| ... | @@ -567,7 +585,7 @@ public: | ... | @@ -567,7 +585,7 @@ public: |
| 567 | __cntrl_->__add_shared(); | 585 | __cntrl_->__add_shared(); |
| 568 | } | 586 | } |
| 569 | 587 | ||
| 570 | template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | 588 | template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> |
| 571 | _LIBCPP_HIDE_FROM_ABI shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) { | 589 | _LIBCPP_HIDE_FROM_ABI shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) { |
| 572 | if (__cntrl_) | 590 | if (__cntrl_) |
| 573 | __cntrl_->__add_shared(); | 591 | __cntrl_->__add_shared(); |
| ... | @@ -578,13 +596,13 @@ public: | ... | @@ -578,13 +596,13 @@ public: |
| 578 | __r.__cntrl_ = nullptr; | 596 | __r.__cntrl_ = nullptr; |
| 579 | } | 597 | } |
| 580 | 598 | ||
| 581 | template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | 599 | template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> |
| 582 | _LIBCPP_HIDE_FROM_ABI shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) { | 600 | _LIBCPP_HIDE_FROM_ABI shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) { |
| 583 | __r.__ptr_ = nullptr; | 601 | __r.__ptr_ = nullptr; |
| 584 | __r.__cntrl_ = nullptr; | 602 | __r.__cntrl_ = nullptr; |
| 585 | } | 603 | } |
| 586 | 604 | ||
| 587 | template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | 605 | template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> |
| 588 | _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r) | 606 | _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r) |
| 589 | : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) { | 607 | : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) { |
| 590 | if (__cntrl_ == nullptr) | 608 | if (__cntrl_ == nullptr) |
| ... | @@ -592,10 +610,10 @@ public: | ... | @@ -592,10 +610,10 @@ public: |
| 592 | } | 610 | } |
| 593 | 611 | ||
| 594 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | 612 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) |
| 595 | template <class _Yp, class = __enable_if_t<is_convertible<_Yp*, element_type*>::value> > | 613 | template <class _Yp, __enable_if_t<is_convertible<_Yp*, element_type*>::value, int> = 0> |
| 596 | _LIBCPP_HIDE_FROM_ABI shared_ptr(auto_ptr<_Yp>&& __r) : __ptr_(__r.get()) { | 614 | _LIBCPP_HIDE_FROM_ABI shared_ptr(auto_ptr<_Yp>&& __r) : __ptr_(__r.get()) { |
| 597 | typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 615 | typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<__remove_cv_t<_Yp> > > _CntrlBlk; |
| 598 | __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); | 616 | __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<__remove_cv_t<_Yp> >()); |
| 599 | __enable_weak_this(__r.get(), __r.get()); | 617 | __enable_weak_this(__r.get(), __r.get()); |
| 600 | __r.release(); | 618 | __r.release(); |
| 601 | } | 619 | } |
| ... | @@ -603,8 +621,9 @@ public: | ... | @@ -603,8 +621,9 @@ public: |
| 603 | 621 | ||
| 604 | template <class _Yp, | 622 | template <class _Yp, |
| 605 | class _Dp, | 623 | class _Dp, |
| 606 | class = __enable_if_t< !is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value && | 624 | __enable_if_t<!is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value && |
| 607 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value > > | 625 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, |
| 626 | int> = 0> | ||
| 608 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { | 627 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { |
| 609 | #if _LIBCPP_STD_VER >= 14 | 628 | #if _LIBCPP_STD_VER >= 14 |
| 610 | if (__ptr_ == nullptr) | 629 | if (__ptr_ == nullptr) |
| ... | @@ -622,9 +641,10 @@ public: | ... | @@ -622,9 +641,10 @@ public: |
| 622 | 641 | ||
| 623 | template <class _Yp, | 642 | template <class _Yp, |
| 624 | class _Dp, | 643 | class _Dp, |
| 625 | class = void, | 644 | class = void, |
| 626 | class = __enable_if_t< is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value && | 645 | __enable_if_t<is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value && |
| 627 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value > > | 646 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, |
| 647 | int> = 0> | ||
| 628 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { | 648 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { |
| 629 | #if _LIBCPP_STD_VER >= 14 | 649 | #if _LIBCPP_STD_VER >= 14 |
| 630 | if (__ptr_ == nullptr) | 650 | if (__ptr_ == nullptr) |
| ... | @@ -653,7 +673,7 @@ public: | ... | @@ -653,7 +673,7 @@ public: |
| 653 | return *this; | 673 | return *this; |
| 654 | } | 674 | } |
| 655 | 675 | ||
| 656 | template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | 676 | template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> |
| 657 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT { | 677 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT { |
| 658 | shared_ptr(__r).swap(*this); | 678 | shared_ptr(__r).swap(*this); |
| 659 | return *this; | 679 | return *this; |
| ... | @@ -664,7 +684,7 @@ public: | ... | @@ -664,7 +684,7 @@ public: |
| 664 | return *this; | 684 | return *this; |
| 665 | } | 685 | } |
| 666 | 686 | ||
| 667 | template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | 687 | template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> |
| 668 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(shared_ptr<_Yp>&& __r) { | 688 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(shared_ptr<_Yp>&& __r) { |
| 669 | shared_ptr(std::move(__r)).swap(*this); | 689 | shared_ptr(std::move(__r)).swap(*this); |
| 670 | return *this; | 690 | return *this; |
| ... | @@ -672,19 +692,19 @@ public: | ... | @@ -672,19 +692,19 @@ public: |
| 672 | 692 | ||
| 673 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | 693 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) |
| 674 | template <class _Yp, | 694 | template <class _Yp, |
| 675 | class = __enable_if_t< !is_array<_Yp>::value && | 695 | __enable_if_t<!is_array<_Yp>::value && is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, |
| 676 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value > > | 696 | int> = 0> |
| 677 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(auto_ptr<_Yp>&& __r) { | 697 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(auto_ptr<_Yp>&& __r) { |
| 678 | shared_ptr(std::move(__r)).swap(*this); | 698 | shared_ptr(std::move(__r)).swap(*this); |
| 679 | return *this; | 699 | return *this; |
| 680 | } | 700 | } |
| 681 | #endif | 701 | #endif |
| 682 | 702 | ||
| 683 | template < | 703 | template <class _Yp, |
| 684 | class _Yp, | 704 | class _Dp, |
| 685 | class _Dp, | 705 | __enable_if_t<_And< __compatible_with<_Yp, _Tp>, |
| 686 | class = __enable_if_t<_And< __compatible_with<_Yp, _Tp>, | 706 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*> >::value, |
| 687 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*> >::value> > | 707 | int> = 0> |
| 688 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r) { | 708 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r) { |
| 689 | shared_ptr(std::move(__r)).swap(*this); | 709 | shared_ptr(std::move(__r)).swap(*this); |
| 690 | return *this; | 710 | return *this; |
| ... | @@ -697,12 +717,12 @@ public: | ... | @@ -697,12 +717,12 @@ public: |
| 697 | 717 | ||
| 698 | _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT { shared_ptr().swap(*this); } | 718 | _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT { shared_ptr().swap(*this); } |
| 699 | 719 | ||
| 700 | template <class _Yp, class = __enable_if_t< __raw_pointer_compatible_with<_Yp, _Tp>::value > > | 720 | template <class _Yp, __enable_if_t<__raw_pointer_compatible_with<_Yp, _Tp>::value, int> = 0> |
| 701 | _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p) { | 721 | _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p) { |
| 702 | shared_ptr(__p).swap(*this); | 722 | shared_ptr(__p).swap(*this); |
| 703 | } | 723 | } |
| 704 | 724 | ||
| 705 | template <class _Yp, class _Dp, class = __enable_if_t< __shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> > | 725 | template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 706 | _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d) { | 726 | _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d) { |
| 707 | shared_ptr(__p, __d).swap(*this); | 727 | shared_ptr(__p, __d).swap(*this); |
| 708 | } | 728 | } |
| ... | @@ -710,7 +730,7 @@ public: | ... | @@ -710,7 +730,7 @@ public: |
| 710 | template <class _Yp, | 730 | template <class _Yp, |
| 711 | class _Dp, | 731 | class _Dp, |
| 712 | class _Alloc, | 732 | class _Alloc, |
| 713 | class = __enable_if_t< __shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> > | 733 | __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 714 | _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d, _Alloc __a) { | 734 | _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d, _Alloc __a) { |
| 715 | shared_ptr(__p, __d, __a).swap(*this); | 735 | shared_ptr(__p, __d, __a).swap(*this); |
| 716 | } | 736 | } |
| ... | @@ -770,7 +790,7 @@ public: | ... | @@ -770,7 +790,7 @@ public: |
| 770 | private: | 790 | private: |
| 771 | template <class _Yp, bool = is_function<_Yp>::value> | 791 | template <class _Yp, bool = is_function<_Yp>::value> |
| 772 | struct __shared_ptr_default_allocator { | 792 | struct __shared_ptr_default_allocator { |
| 773 | typedef allocator<_Yp> type; | 793 | typedef allocator<__remove_cv_t<_Yp> > type; |
| 774 | }; | 794 | }; |
| 775 | 795 | ||
| 776 | template <class _Yp> | 796 | template <class _Yp> |
| ... | @@ -780,7 +800,7 @@ private: | ... | @@ -780,7 +800,7 @@ private: |
| 780 | 800 | ||
| 781 | template <class _Yp, | 801 | template <class _Yp, |
| 782 | class _OrigPtr, | 802 | class _OrigPtr, |
| 783 | class = __enable_if_t< is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value > > | 803 | __enable_if_t<is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value, int> = 0> |
| 784 | _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT { | 804 | _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT { |
| 785 | typedef __remove_cv_t<_Yp> _RawYp; | 805 | typedef __remove_cv_t<_Yp> _RawYp; |
| 786 | if (__e && __e->__weak_this_.expired()) { | 806 | if (__e && __e->__weak_this_.expired()) { |
| ... | @@ -815,7 +835,7 @@ shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; | ... | @@ -815,7 +835,7 @@ shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; |
| 815 | // | 835 | // |
| 816 | // std::allocate_shared and std::make_shared | 836 | // std::allocate_shared and std::make_shared |
| 817 | // | 837 | // |
| 818 | template <class _Tp, class _Alloc, class... _Args, class = __enable_if_t<!is_array<_Tp>::value> > | 838 | template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 819 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) { | 839 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) { |
| 820 | using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>; | 840 | using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>; |
| 821 | using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type; | 841 | using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type; |
| ... | @@ -826,9 +846,9 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& | ... | @@ -826,9 +846,9 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& |
| 826 | (*__control_block).__get_elem(), std::addressof(*__control_block)); | 846 | (*__control_block).__get_elem(), std::addressof(*__control_block)); |
| 827 | } | 847 | } |
| 828 | 848 | ||
| 829 | template <class _Tp, class... _Args, class = __enable_if_t<!is_array<_Tp>::value> > | 849 | template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 830 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(_Args&&... __args) { | 850 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(_Args&&... __args) { |
| 831 | return std::allocate_shared<_Tp>(allocator<_Tp>(), std::forward<_Args>(__args)...); | 851 | return std::allocate_shared<_Tp>(allocator<__remove_cv_t<_Tp> >(), std::forward<_Args>(__args)...); |
| 832 | } | 852 | } |
| 833 | 853 | ||
| 834 | #if _LIBCPP_STD_VER >= 20 | 854 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -842,7 +862,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc | ... | @@ -842,7 +862,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc |
| 842 | 862 | ||
| 843 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 863 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 844 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { | 864 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { |
| 845 | return std::allocate_shared_for_overwrite<_Tp>(allocator<_Tp>()); | 865 | return std::allocate_shared_for_overwrite<_Tp>(allocator<__remove_cv_t<_Tp>>()); |
| 846 | } | 866 | } |
| 847 | 867 | ||
| 848 | #endif // _LIBCPP_STD_VER >= 20 | 868 | #endif // _LIBCPP_STD_VER >= 20 |
| ... | @@ -1032,12 +1052,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _ | ... | @@ -1032,12 +1052,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _ |
| 1032 | #if _LIBCPP_STD_VER >= 20 | 1052 | #if _LIBCPP_STD_VER >= 20 |
| 1033 | 1053 | ||
| 1034 | // bounded array variants | 1054 | // bounded array variants |
| 1035 | template <class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>> | 1055 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 1036 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a) { | 1056 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a) { |
| 1037 | return std::__allocate_shared_bounded_array<_Tp>(__a); | 1057 | return std::__allocate_shared_bounded_array<_Tp>(__a); |
| 1038 | } | 1058 | } |
| 1039 | 1059 | ||
| 1040 | template <class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>> | 1060 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 1041 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) { | 1061 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) { |
| 1042 | return std::__allocate_shared_bounded_array<_Tp>(__a, __u); | 1062 | return std::__allocate_shared_bounded_array<_Tp>(__a, __u); |
| 1043 | } | 1063 | } |
| ... | @@ -1049,12 +1069,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc | ... | @@ -1049,12 +1069,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc |
| 1049 | return std::__allocate_shared_bounded_array<_Tp>(__alloc); | 1069 | return std::__allocate_shared_bounded_array<_Tp>(__alloc); |
| 1050 | } | 1070 | } |
| 1051 | 1071 | ||
| 1052 | template <class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>> | 1072 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 1053 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared() { | 1073 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared() { |
| 1054 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>()); | 1074 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>()); |
| 1055 | } | 1075 | } |
| 1056 | 1076 | ||
| 1057 | template <class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>> | 1077 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 1058 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) { | 1078 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) { |
| 1059 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u); | 1079 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u); |
| 1060 | } | 1080 | } |
| ... | @@ -1065,12 +1085,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { | ... | @@ -1065,12 +1085,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { |
| 1065 | } | 1085 | } |
| 1066 | 1086 | ||
| 1067 | // unbounded array variants | 1087 | // unbounded array variants |
| 1068 | template <class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | 1088 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 1069 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) { | 1089 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) { |
| 1070 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n); | 1090 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n); |
| 1071 | } | 1091 | } |
| 1072 | 1092 | ||
| 1073 | template <class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | 1093 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 1074 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) { | 1094 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) { |
| 1075 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u); | 1095 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u); |
| 1076 | } | 1096 | } |
| ... | @@ -1082,12 +1102,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc | ... | @@ -1082,12 +1102,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc |
| 1082 | return std::__allocate_shared_unbounded_array<_Tp>(__alloc, __n); | 1102 | return std::__allocate_shared_unbounded_array<_Tp>(__alloc, __n); |
| 1083 | } | 1103 | } |
| 1084 | 1104 | ||
| 1085 | template <class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | 1105 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 1086 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n) { | 1106 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n) { |
| 1087 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n); | 1107 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n); |
| 1088 | } | 1108 | } |
| 1089 | 1109 | ||
| 1090 | template <class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | 1110 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 1091 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) { | 1111 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) { |
| 1092 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u); | 1112 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u); |
| 1093 | } | 1113 | } |
| ... | @@ -1299,6 +1319,10 @@ public: | ... | @@ -1299,6 +1319,10 @@ public: |
| 1299 | typedef _Tp element_type; | 1319 | typedef _Tp element_type; |
| 1300 | #endif | 1320 | #endif |
| 1301 | 1321 | ||
| 1322 | // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require | ||
| 1323 | // any bookkeeping, so it's always trivially relocatable. | ||
| 1324 | using __trivially_relocatable = weak_ptr; | ||
| 1325 | |||
| 1302 | private: | 1326 | private: |
| 1303 | element_type* __ptr_; | 1327 | element_type* __ptr_; |
| 1304 | __shared_weak_count* __cntrl_; | 1328 | __shared_weak_count* __cntrl_; |
lib/libcxx/include/__memory/swap_allocator.h+2-2| ... | @@ -26,7 +26,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc | ... | @@ -26,7 +26,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc |
| 26 | #if _LIBCPP_STD_VER >= 14 | 26 | #if _LIBCPP_STD_VER >= 14 |
| 27 | _NOEXCEPT | 27 | _NOEXCEPT |
| 28 | #else | 28 | #else |
| 29 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) | 29 | _NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>) |
| 30 | #endif | 30 | #endif |
| 31 | { | 31 | { |
| 32 | using std::swap; | 32 | using std::swap; |
| ... | @@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator | ... | @@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator |
| 42 | #if _LIBCPP_STD_VER >= 14 | 42 | #if _LIBCPP_STD_VER >= 14 |
| 43 | _NOEXCEPT | 43 | _NOEXCEPT |
| 44 | #else | 44 | #else |
| 45 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) | 45 | _NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>) |
| 46 | #endif | 46 | #endif |
| 47 | { | 47 | { |
| 48 | std::__swap_allocator( | 48 | std::__swap_allocator( |
lib/libcxx/include/__memory/temporary_buffer.h+1-2| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H | 11 | #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/alignment_of.h> | ||
| 15 | #include <__utility/pair.h> | 14 | #include <__utility/pair.h> |
| 16 | #include <cstddef> | 15 | #include <cstddef> |
| 17 | #include <new> | 16 | #include <new> |
| ... | @@ -23,7 +22,7 @@ | ... | @@ -23,7 +22,7 @@ |
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 23 | ||
| 25 | template <class _Tp> | 24 | template <class _Tp> |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> | 25 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> |
| 27 | get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT { | 26 | get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT { |
| 28 | pair<_Tp*, ptrdiff_t> __r(0, 0); | 27 | pair<_Tp*, ptrdiff_t> __r(0, 0); |
| 29 | const ptrdiff_t __m = | 28 | const ptrdiff_t __m = |
lib/libcxx/include/__memory/uninitialized_algorithms.h+48-51| ... | @@ -25,10 +25,9 @@ | ... | @@ -25,10 +25,9 @@ |
| 25 | #include <__type_traits/extent.h> | 25 | #include <__type_traits/extent.h> |
| 26 | #include <__type_traits/is_array.h> | 26 | #include <__type_traits/is_array.h> |
| 27 | #include <__type_traits/is_constant_evaluated.h> | 27 | #include <__type_traits/is_constant_evaluated.h> |
| 28 | #include <__type_traits/is_trivially_copy_assignable.h> | 28 | #include <__type_traits/is_trivially_assignable.h> |
| 29 | #include <__type_traits/is_trivially_copy_constructible.h> | 29 | #include <__type_traits/is_trivially_constructible.h> |
| 30 | #include <__type_traits/is_trivially_move_assignable.h> | 30 | #include <__type_traits/is_trivially_relocatable.h> |
| 31 | #include <__type_traits/is_trivially_move_constructible.h> | ||
| 32 | #include <__type_traits/is_unbounded_array.h> | 31 | #include <__type_traits/is_unbounded_array.h> |
| 33 | #include <__type_traits/negation.h> | 32 | #include <__type_traits/negation.h> |
| 34 | #include <__type_traits/remove_const.h> | 33 | #include <__type_traits/remove_const.h> |
| ... | @@ -365,7 +364,7 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir | ... | @@ -365,7 +364,7 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir |
| 365 | // the correct type. | 364 | // the correct type. |
| 366 | template <class _Alloc, | 365 | template <class _Alloc, |
| 367 | class _BidirIter, | 366 | class _BidirIter, |
| 368 | class = __enable_if_t< __has_bidirectional_iterator_category<_BidirIter>::value >> | 367 | __enable_if_t<__has_bidirectional_iterator_category<_BidirIter>::value, int> = 0> |
| 369 | _LIBCPP_HIDE_FROM_ABI constexpr void | 368 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 370 | __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept { | 369 | __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept { |
| 371 | using _ValueType = typename iterator_traits<_BidirIter>::value_type; | 370 | using _ValueType = typename iterator_traits<_BidirIter>::value_type; |
| ... | @@ -568,8 +567,9 @@ template <class _Alloc, | ... | @@ -568,8 +567,9 @@ template <class _Alloc, |
| 568 | __enable_if_t< | 567 | __enable_if_t< |
| 569 | // using _RawTypeIn because of the allocator<T const> extension | 568 | // using _RawTypeIn because of the allocator<T const> extension |
| 570 | is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && | 569 | is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && |
| 571 | is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && | 570 | is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && |
| 572 | __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value>* = nullptr> | 571 | __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value, |
| 572 | int> = 0> | ||
| 573 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* | 573 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* |
| 574 | __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) { | 574 | __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) { |
| 575 | // TODO: Remove the const_cast once we drop support for std::allocator<T const> | 575 | // TODO: Remove the const_cast once we drop support for std::allocator<T const> |
| ... | @@ -594,60 +594,57 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, | ... | @@ -594,60 +594,57 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, |
| 594 | return std::__rewrap_iter(__first2, __result); | 594 | return std::__rewrap_iter(__first2, __result); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | // Move-construct the elements [__first1, __last1) into [__first2, __first2 + N) | ||
| 598 | // if the move constructor is noexcept, where N is distance(__first1, __last1). | ||
| 599 | // | ||
| 600 | // Otherwise try to copy all elements. If an exception is thrown the already copied | ||
| 601 | // elements are destroyed in reverse order of their construction. | ||
| 602 | template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> | ||
| 603 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 | ||
| 604 | __uninitialized_allocator_move_if_noexcept(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { | ||
| 605 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, | ||
| 606 | "The specified type does not meet the requirements of Cpp17MoveInsertable"); | ||
| 607 | auto __destruct_first = __first2; | ||
| 608 | auto __guard = | ||
| 609 | std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)); | ||
| 610 | while (__first1 != __last1) { | ||
| 611 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 612 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1)); | ||
| 613 | #else | ||
| 614 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1)); | ||
| 615 | #endif | ||
| 616 | ++__first1; | ||
| 617 | ++__first2; | ||
| 618 | } | ||
| 619 | __guard.__complete(); | ||
| 620 | return __first2; | ||
| 621 | } | ||
| 622 | |||
| 623 | template <class _Alloc, class _Type> | 597 | template <class _Alloc, class _Type> |
| 624 | struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {}; | 598 | struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {}; |
| 625 | 599 | ||
| 626 | template <class _Type> | 600 | template <class _Type> |
| 627 | struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {}; | 601 | struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {}; |
| 628 | 602 | ||
| 629 | #ifndef _LIBCPP_COMPILER_GCC | 603 | template <class _Alloc, class _Tp> |
| 630 | template < | 604 | struct __allocator_has_trivial_destroy : _Not<__has_destroy<_Alloc, _Tp*> > {}; |
| 631 | class _Alloc, | 605 | |
| 632 | class _Iter1, | 606 | template <class _Tp, class _Up> |
| 633 | class _Iter2, | 607 | struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {}; |
| 634 | class _Type = typename iterator_traits<_Iter1>::value_type, | 608 | |
| 635 | class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value && | 609 | // __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result. |
| 636 | __allocator_has_trivial_move_construct<_Alloc, _Type>::value> > | 610 | // Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy, |
| 637 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 | 611 | // except that the move constructor and destructor may never be called if they are known to be equivalent to a memcpy. |
| 638 | __uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) { | 612 | // |
| 639 | if (__libcpp_is_constant_evaluated()) { | 613 | // Preconditions: __result doesn't contain any objects and [__first, __last) contains objects |
| 640 | while (__first1 != __last1) { | 614 | // Postconditions: __result contains the objects from [__first, __last) and |
| 641 | std::__construct_at(std::__to_address(__first2), std::move(*__first1)); | 615 | // [__first, __last) doesn't contain any objects |
| 642 | ++__first1; | 616 | // |
| 643 | ++__first2; | 617 | // The strong exception guarantee is provided if any of the following are true: |
| 618 | // - is_nothrow_move_constructible<_Tp> | ||
| 619 | // - is_copy_constructible<_Tp> | ||
| 620 | // - __libcpp_is_trivially_relocatable<_Tp> | ||
| 621 | template <class _Alloc, class _Tp> | ||
| 622 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | ||
| 623 | __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _Tp* __result) { | ||
| 624 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, | ||
| 625 | "The specified type does not meet the requirements of Cpp17MoveInsertable"); | ||
| 626 | if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_Tp>::value || | ||
| 627 | !__allocator_has_trivial_move_construct<_Alloc, _Tp>::value || | ||
| 628 | !__allocator_has_trivial_destroy<_Alloc, _Tp>::value) { | ||
| 629 | auto __destruct_first = __result; | ||
| 630 | auto __guard = | ||
| 631 | std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Tp*>(__alloc, __destruct_first, __result)); | ||
| 632 | auto __iter = __first; | ||
| 633 | while (__iter != __last) { | ||
| 634 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 635 | allocator_traits<_Alloc>::construct(__alloc, __result, std::move_if_noexcept(*__iter)); | ||
| 636 | #else | ||
| 637 | allocator_traits<_Alloc>::construct(__alloc, __result, std::move(*__iter)); | ||
| 638 | #endif | ||
| 639 | ++__iter; | ||
| 640 | ++__result; | ||
| 644 | } | 641 | } |
| 645 | return __first2; | 642 | __guard.__complete(); |
| 643 | std::__allocator_destroy(__alloc, __first, __last); | ||
| 646 | } else { | 644 | } else { |
| 647 | return std::move(__first1, __last1, __first2); | 645 | __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first)); |
| 648 | } | 646 | } |
| 649 | } | 647 | } |
| 650 | #endif // _LIBCPP_COMPILER_GCC | ||
| 651 | 648 | ||
| 652 | _LIBCPP_END_NAMESPACE_STD | 649 | _LIBCPP_END_NAMESPACE_STD |
| 653 | 650 |
lib/libcxx/include/__memory/unique_ptr.h+46-9| ... | @@ -21,21 +21,24 @@ | ... | @@ -21,21 +21,24 @@ |
| 21 | #include <__memory/compressed_pair.h> | 21 | #include <__memory/compressed_pair.h> |
| 22 | #include <__type_traits/add_lvalue_reference.h> | 22 | #include <__type_traits/add_lvalue_reference.h> |
| 23 | #include <__type_traits/common_type.h> | 23 | #include <__type_traits/common_type.h> |
| 24 | #include <__type_traits/conditional.h> | ||
| 24 | #include <__type_traits/dependent_type.h> | 25 | #include <__type_traits/dependent_type.h> |
| 25 | #include <__type_traits/integral_constant.h> | 26 | #include <__type_traits/integral_constant.h> |
| 26 | #include <__type_traits/is_array.h> | 27 | #include <__type_traits/is_array.h> |
| 27 | #include <__type_traits/is_assignable.h> | 28 | #include <__type_traits/is_assignable.h> |
| 28 | #include <__type_traits/is_constructible.h> | 29 | #include <__type_traits/is_constructible.h> |
| 29 | #include <__type_traits/is_convertible.h> | 30 | #include <__type_traits/is_convertible.h> |
| 30 | #include <__type_traits/is_default_constructible.h> | ||
| 31 | #include <__type_traits/is_function.h> | 31 | #include <__type_traits/is_function.h> |
| 32 | #include <__type_traits/is_pointer.h> | 32 | #include <__type_traits/is_pointer.h> |
| 33 | #include <__type_traits/is_reference.h> | 33 | #include <__type_traits/is_reference.h> |
| 34 | #include <__type_traits/is_same.h> | 34 | #include <__type_traits/is_same.h> |
| 35 | #include <__type_traits/is_swappable.h> | 35 | #include <__type_traits/is_swappable.h> |
| 36 | #include <__type_traits/is_trivially_relocatable.h> | ||
| 36 | #include <__type_traits/is_void.h> | 37 | #include <__type_traits/is_void.h> |
| 37 | #include <__type_traits/remove_extent.h> | 38 | #include <__type_traits/remove_extent.h> |
| 39 | #include <__type_traits/remove_pointer.h> | ||
| 38 | #include <__type_traits/type_identity.h> | 40 | #include <__type_traits/type_identity.h> |
| 41 | #include <__utility/declval.h> | ||
| 39 | #include <__utility/forward.h> | 42 | #include <__utility/forward.h> |
| 40 | #include <__utility/move.h> | 43 | #include <__utility/move.h> |
| 41 | #include <cstddef> | 44 | #include <cstddef> |
| ... | @@ -49,6 +52,17 @@ _LIBCPP_PUSH_MACROS | ... | @@ -49,6 +52,17 @@ _LIBCPP_PUSH_MACROS |
| 49 | 52 | ||
| 50 | _LIBCPP_BEGIN_NAMESPACE_STD | 53 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 51 | 54 | ||
| 55 | #ifndef _LIBCPP_CXX03_LANG | ||
| 56 | |||
| 57 | template <class _Ptr> | ||
| 58 | struct __is_noexcept_deref_or_void { | ||
| 59 | static constexpr bool value = noexcept(*std::declval<_Ptr>()); | ||
| 60 | }; | ||
| 61 | |||
| 62 | template <> | ||
| 63 | struct __is_noexcept_deref_or_void<void*> : true_type {}; | ||
| 64 | #endif | ||
| 65 | |||
| 52 | template <class _Tp> | 66 | template <class _Tp> |
| 53 | struct _LIBCPP_TEMPLATE_VIS default_delete { | 67 | struct _LIBCPP_TEMPLATE_VIS default_delete { |
| 54 | static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types"); | 68 | static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types"); |
| ... | @@ -129,6 +143,17 @@ public: | ... | @@ -129,6 +143,17 @@ public: |
| 129 | 143 | ||
| 130 | static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference"); | 144 | static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference"); |
| 131 | 145 | ||
| 146 | // A unique_ptr contains the following members which may be trivially relocatable: | ||
| 147 | // - pointer : this may be trivially relocatable, so it's checked | ||
| 148 | // - deleter_type: this may be trivially relocatable, so it's checked | ||
| 149 | // | ||
| 150 | // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no | ||
| 151 | // references to itself. This means that the entire structure is trivially relocatable if its members are. | ||
| 152 | using __trivially_relocatable = __conditional_t< | ||
| 153 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, | ||
| 154 | unique_ptr, | ||
| 155 | void>; | ||
| 156 | |||
| 132 | private: | 157 | private: |
| 133 | __compressed_pair<pointer, deleter_type> __ptr_; | 158 | __compressed_pair<pointer, deleter_type> __ptr_; |
| 134 | 159 | ||
| ... | @@ -171,8 +196,8 @@ public: | ... | @@ -171,8 +196,8 @@ public: |
| 171 | : __ptr_(__value_init_tag(), __value_init_tag()) {} | 196 | : __ptr_(__value_init_tag(), __value_init_tag()) {} |
| 172 | 197 | ||
| 173 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > | 198 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 174 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT | 199 | _LIBCPP_HIDE_FROM_ABI |
| 175 | : __ptr_(__p, __value_init_tag()) {} | 200 | _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} |
| 176 | 201 | ||
| 177 | template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > | 202 | template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > |
| 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT | 203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT |
| ... | @@ -240,7 +265,8 @@ public: | ... | @@ -240,7 +265,8 @@ public: |
| 240 | return *this; | 265 | return *this; |
| 241 | } | 266 | } |
| 242 | 267 | ||
| 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const { | 268 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const |
| 269 | _NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) { | ||
| 244 | return *__ptr_.first(); | 270 | return *__ptr_.first(); |
| 245 | } | 271 | } |
| 246 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); } | 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); } |
| ... | @@ -276,6 +302,17 @@ public: | ... | @@ -276,6 +302,17 @@ public: |
| 276 | typedef _Dp deleter_type; | 302 | typedef _Dp deleter_type; |
| 277 | typedef typename __pointer<_Tp, deleter_type>::type pointer; | 303 | typedef typename __pointer<_Tp, deleter_type>::type pointer; |
| 278 | 304 | ||
| 305 | // A unique_ptr contains the following members which may be trivially relocatable: | ||
| 306 | // - pointer : this may be trivially relocatable, so it's checked | ||
| 307 | // - deleter_type: this may be trivially relocatable, so it's checked | ||
| 308 | // | ||
| 309 | // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no | ||
| 310 | // references to itself. This means that the entire structure is trivially relocatable if its members are. | ||
| 311 | using __trivially_relocatable = __conditional_t< | ||
| 312 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, | ||
| 313 | unique_ptr, | ||
| 314 | void>; | ||
| 315 | |||
| 279 | private: | 316 | private: |
| 280 | __compressed_pair<pointer, deleter_type> __ptr_; | 317 | __compressed_pair<pointer, deleter_type> __ptr_; |
| 281 | 318 | ||
| ... | @@ -336,8 +373,8 @@ public: | ... | @@ -336,8 +373,8 @@ public: |
| 336 | bool _Dummy = true, | 373 | bool _Dummy = true, |
| 337 | class = _EnableIfDeleterDefaultConstructible<_Dummy>, | 374 | class = _EnableIfDeleterDefaultConstructible<_Dummy>, |
| 338 | class = _EnableIfPointerConvertible<_Pp> > | 375 | class = _EnableIfPointerConvertible<_Pp> > |
| 339 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT | 376 | _LIBCPP_HIDE_FROM_ABI |
| 340 | : __ptr_(__p, __value_init_tag()) {} | 377 | _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} |
| 341 | 378 | ||
| 342 | template <class _Pp, | 379 | template <class _Pp, |
| 343 | bool _Dummy = true, | 380 | bool _Dummy = true, |
| ... | @@ -448,7 +485,7 @@ public: | ... | @@ -448,7 +485,7 @@ public: |
| 448 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); } | 485 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); } |
| 449 | }; | 486 | }; |
| 450 | 487 | ||
| 451 | template <class _Tp, class _Dp, __enable_if_t<__is_swappable<_Dp>::value, int> = 0> | 488 | template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0> |
| 452 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void | 489 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void |
| 453 | swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT { | 490 | swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT { |
| 454 | __x.swap(__y); | 491 | __x.swap(__y); |
| ... | @@ -494,8 +531,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const unique_ptr<_T1, _D1>& __x, co | ... | @@ -494,8 +531,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const unique_ptr<_T1, _D1>& __x, co |
| 494 | template <class _T1, class _D1, class _T2, class _D2> | 531 | template <class _T1, class _D1, class _T2, class _D2> |
| 495 | requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer> | 532 | requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer> |
| 496 | _LIBCPP_HIDE_FROM_ABI | 533 | _LIBCPP_HIDE_FROM_ABI |
| 497 | compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer> | 534 | compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer> |
| 498 | operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) { | 535 | operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) { |
| 499 | return compare_three_way()(__x.get(), __y.get()); | 536 | return compare_three_way()(__x.get(), __y.get()); |
| 500 | } | 537 | } |
| 501 | #endif | 538 | #endif |
lib/libcxx/include/__memory/uses_allocator_construction.h+6-14| ... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__memory/construct_at.h> | 13 | #include <__memory/construct_at.h> |
| 14 | #include <__memory/uses_allocator.h> | 14 | #include <__memory/uses_allocator.h> |
| 15 | #include <__tuple/pair_like.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> | 17 | #include <__type_traits/is_same.h> |
| 18 | #include <__type_traits/remove_cv.h> | 18 | #include <__type_traits/remove_cv.h> |
| ... | @@ -128,11 +128,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& | ... | @@ -128,11 +128,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& |
| 128 | std::forward_as_tuple(std::get<1>(std::move(__pair)))); | 128 | std::forward_as_tuple(std::get<1>(std::move(__pair)))); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | template < class _Pair, | 131 | template <class _Pair, class _Alloc, __pair_like_no_subrange _PairLike, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> |
| 132 | class _Alloc, | ||
| 133 | __pair_like _PairLike, | ||
| 134 | __enable_if_t<__is_cv_std_pair<_Pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value, | ||
| 135 | int> = 0> | ||
| 136 | _LIBCPP_HIDE_FROM_ABI constexpr auto | 132 | _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 137 | __uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept { | 133 | __uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept { |
| 138 | return std::__uses_allocator_construction_args<_Pair>( | 134 | return std::__uses_allocator_construction_args<_Pair>( |
| ... | @@ -161,9 +157,7 @@ inline constexpr bool __convertible_to_const_pair_ref = | ... | @@ -161,9 +157,7 @@ inline constexpr bool __convertible_to_const_pair_ref = |
| 161 | # if _LIBCPP_STD_VER >= 23 | 157 | # if _LIBCPP_STD_VER >= 23 |
| 162 | template <class _Tp, class _Up> | 158 | template <class _Tp, class _Up> |
| 163 | inline constexpr bool __uses_allocator_constraints = | 159 | inline constexpr bool __uses_allocator_constraints = |
| 164 | __is_cv_std_pair<_Tp> && | 160 | __is_cv_std_pair<_Tp> && !__pair_like_no_subrange<_Up> && !__convertible_to_const_pair_ref<_Up>; |
| 165 | (__is_specialization_of_subrange<remove_cvref_t<_Up>>::value || | ||
| 166 | (!__pair_like<_Up> && !__convertible_to_const_pair_ref<_Up>)); | ||
| 167 | # else | 161 | # else |
| 168 | template <class _Tp, class _Up> | 162 | template <class _Tp, class _Up> |
| 169 | inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !__convertible_to_const_pair_ref<_Up>; | 163 | inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !__convertible_to_const_pair_ref<_Up>; |
| ... | @@ -190,20 +184,18 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexc | ... | @@ -190,20 +184,18 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexc |
| 190 | struct __pair_constructor { | 184 | struct __pair_constructor { |
| 191 | using _PairMutable = remove_cv_t<_Pair>; | 185 | using _PairMutable = remove_cv_t<_Pair>; |
| 192 | 186 | ||
| 193 | _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(const _PairMutable& __pair) const { | 187 | _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const { |
| 194 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair); | 188 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair); |
| 195 | } | 189 | } |
| 196 | 190 | ||
| 197 | _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(_PairMutable&& __pair) const { | 191 | _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const { |
| 198 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair)); | 192 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair)); |
| 199 | } | 193 | } |
| 200 | 194 | ||
| 201 | const _Alloc& __alloc_; | 195 | const _Alloc& __alloc_; |
| 202 | _Type& __value_; | 196 | _Type& __value_; |
| 203 | 197 | ||
| 204 | _LIBCPP_HIDE_FROM_ABI constexpr operator _PairMutable() const { | 198 | _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); } |
| 205 | return __do_construct(std::forward<_Type>(this->__value_)); | ||
| 206 | } | ||
| 207 | }; | 199 | }; |
| 208 | 200 | ||
| 209 | return std::make_tuple(__pair_constructor{__alloc, __value}); | 201 | return std::make_tuple(__pair_constructor{__alloc, __value}); |
lib/libcxx/include/__memory_resource/memory_resource.h+2-4| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H | 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H |
| 10 | #define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H | 10 | #define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <__fwd/memory_resource.h> | 13 | #include <__fwd/memory_resource.h> |
| 15 | #include <cstddef> | 14 | #include <cstddef> |
| ... | @@ -32,9 +31,8 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource { | ... | @@ -32,9 +31,8 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource { |
| 32 | public: | 31 | public: |
| 33 | virtual ~memory_resource(); | 32 | virtual ~memory_resource(); |
| 34 | 33 | ||
| 35 | _LIBCPP_NODISCARD_AFTER_CXX17 | 34 | [[nodiscard]] [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]] |
| 36 | [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]] _LIBCPP_HIDE_FROM_ABI void* | 35 | _LIBCPP_HIDE_FROM_ABI void* allocate(size_t __bytes, size_t __align = __max_align) { |
| 37 | allocate(size_t __bytes, size_t __align = __max_align) { | ||
| 38 | return do_allocate(__bytes, __align); | 36 | return do_allocate(__bytes, __align); |
| 39 | } | 37 | } |
| 40 | 38 |
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H | 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H |
| 10 | #define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H | 10 | #define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <__memory/addressof.h> | 13 | #include <__memory/addressof.h> |
| 15 | #include <__memory_resource/memory_resource.h> | 14 | #include <__memory_resource/memory_resource.h> |
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+2-2| ... | @@ -10,8 +10,8 @@ | ... | @@ -10,8 +10,8 @@ |
| 10 | #define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H | 10 | #define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H |
| 11 | 11 | ||
| 12 | #include <__assert> | 12 | #include <__assert> |
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__fwd/pair.h> | ||
| 15 | #include <__memory_resource/memory_resource.h> | 15 | #include <__memory_resource/memory_resource.h> |
| 16 | #include <__utility/exception_guard.h> | 16 | #include <__utility/exception_guard.h> |
| 17 | #include <cstddef> | 17 | #include <cstddef> |
| ... | @@ -60,7 +60,7 @@ public: | ... | @@ -60,7 +60,7 @@ public: |
| 60 | 60 | ||
| 61 | // [mem.poly.allocator.mem] | 61 | // [mem.poly.allocator.mem] |
| 62 | 62 | ||
| 63 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) { | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) { |
| 64 | if (__n > __max_size()) { | 64 | if (__n > __max_size()) { |
| 65 | __throw_bad_array_new_length(); | 65 | __throw_bad_array_new_length(); |
| 66 | } | 66 | } |
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H | 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H |
| 10 | #define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H | 10 | #define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <__memory_resource/memory_resource.h> | 13 | #include <__memory_resource/memory_resource.h> |
| 15 | #include <__memory_resource/pool_options.h> | 14 | #include <__memory_resource/pool_options.h> |
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H | 9 | #ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H |
| 10 | #define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H | 10 | #define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H |
| 11 | 11 | ||
| 12 | #include <__availability> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <__memory_resource/memory_resource.h> | 13 | #include <__memory_resource/memory_resource.h> |
| 15 | #include <__memory_resource/pool_options.h> | 14 | #include <__memory_resource/pool_options.h> |
lib/libcxx/include/__mutex/lock_guard.h+3-8| ... | @@ -16,8 +16,6 @@ | ... | @@ -16,8 +16,6 @@ |
| 16 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 20 | ||
| 23 | template <class _Mutex> | 21 | template <class _Mutex> |
| ... | @@ -29,18 +27,17 @@ private: | ... | @@ -29,18 +27,17 @@ private: |
| 29 | mutex_type& __m_; | 27 | mutex_type& __m_; |
| 30 | 28 | ||
| 31 | public: | 29 | public: |
| 32 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) | 30 | _LIBCPP_NODISCARD |
| 33 | _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) | 31 | _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) |
| 34 | : __m_(__m) { | 32 | : __m_(__m) { |
| 35 | __m_.lock(); | 33 | __m_.lock(); |
| 36 | } | 34 | } |
| 37 | 35 | ||
| 38 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) | 36 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) |
| 39 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) | 37 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) |
| 40 | : __m_(__m) {} | 38 | : __m_(__m) {} |
| 41 | _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } | 39 | _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } |
| 42 | 40 | ||
| 43 | private: | ||
| 44 | lock_guard(lock_guard const&) = delete; | 41 | lock_guard(lock_guard const&) = delete; |
| 45 | lock_guard& operator=(lock_guard const&) = delete; | 42 | lock_guard& operator=(lock_guard const&) = delete; |
| 46 | }; | 43 | }; |
| ... | @@ -48,6 +45,4 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard); | ... | @@ -48,6 +45,4 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard); |
| 48 | 45 | ||
| 49 | _LIBCPP_END_NAMESPACE_STD | 46 | _LIBCPP_END_NAMESPACE_STD |
| 50 | 47 | ||
| 51 | #endif // _LIBCPP_HAS_NO_THREADS | ||
| 52 | |||
| 53 | #endif // _LIBCPP___MUTEX_LOCK_GUARD_H | 48 | #endif // _LIBCPP___MUTEX_LOCK_GUARD_H |
lib/libcxx/include/__mutex/mutex.h+2-2| ... | @@ -10,8 +10,8 @@ | ... | @@ -10,8 +10,8 @@ |
| 10 | #define _LIBCPP___MUTEX_MUTEX_H | 10 | #define _LIBCPP___MUTEX_MUTEX_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__threading_support> | 13 | #include <__thread/support.h> |
| 14 | #include <__type_traits/is_nothrow_default_constructible.h> | 14 | #include <__type_traits/is_nothrow_constructible.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 |
lib/libcxx/include/__mutex/tag_types.h+3-7| ... | @@ -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 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 19 | ||
| 22 | struct _LIBCPP_EXPORTED_FROM_ABI defer_lock_t { | 20 | struct _LIBCPP_EXPORTED_FROM_ABI defer_lock_t { |
| ... | @@ -31,18 +29,16 @@ struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t { | ... | @@ -31,18 +29,16 @@ struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t { |
| 31 | explicit adopt_lock_t() = default; | 29 | explicit adopt_lock_t() = default; |
| 32 | }; | 30 | }; |
| 33 | 31 | ||
| 34 | # if _LIBCPP_STD_VER >= 17 | 32 | #if _LIBCPP_STD_VER >= 17 |
| 35 | inline constexpr defer_lock_t defer_lock = defer_lock_t(); | 33 | inline constexpr defer_lock_t defer_lock = defer_lock_t(); |
| 36 | inline constexpr try_to_lock_t try_to_lock = try_to_lock_t(); | 34 | inline constexpr try_to_lock_t try_to_lock = try_to_lock_t(); |
| 37 | inline constexpr adopt_lock_t adopt_lock = adopt_lock_t(); | 35 | inline constexpr adopt_lock_t adopt_lock = adopt_lock_t(); |
| 38 | # elif !defined(_LIBCPP_CXX03_LANG) | 36 | #elif !defined(_LIBCPP_CXX03_LANG) |
| 39 | constexpr defer_lock_t defer_lock = defer_lock_t(); | 37 | constexpr defer_lock_t defer_lock = defer_lock_t(); |
| 40 | constexpr try_to_lock_t try_to_lock = try_to_lock_t(); | 38 | constexpr try_to_lock_t try_to_lock = try_to_lock_t(); |
| 41 | constexpr adopt_lock_t adopt_lock = adopt_lock_t(); | 39 | constexpr adopt_lock_t adopt_lock = adopt_lock_t(); |
| 42 | # endif | 40 | #endif |
| 43 | 41 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | 42 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 43 | ||
| 46 | #endif // _LIBCPP_HAS_NO_THREADS | ||
| 47 | |||
| 48 | #endif // _LIBCPP___MUTEX_TAG_TYPES_H | 44 | #endif // _LIBCPP___MUTEX_TAG_TYPES_H |
lib/libcxx/include/__mutex/unique_lock.h+12-8| ... | @@ -36,26 +36,28 @@ private: | ... | @@ -36,26 +36,28 @@ private: |
| 36 | bool __owns_; | 36 | bool __owns_; |
| 37 | 37 | ||
| 38 | public: | 38 | public: |
| 39 | _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} | 39 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} |
| 40 | _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) : __m_(std::addressof(__m)), __owns_(true) { | 40 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) |
| 41 | : __m_(std::addressof(__m)), __owns_(true) { | ||
| 41 | __m_->lock(); | 42 | __m_->lock(); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT | 45 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT |
| 45 | : __m_(std::addressof(__m)), | 46 | : __m_(std::addressof(__m)), |
| 46 | __owns_(false) {} | 47 | __owns_(false) {} |
| 47 | 48 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t) | 49 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t) |
| 49 | : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {} | 50 | : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {} |
| 50 | 51 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) : __m_(std::addressof(__m)), __owns_(true) {} | 52 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) |
| 53 | : __m_(std::addressof(__m)), __owns_(true) {} | ||
| 52 | 54 | ||
| 53 | template <class _Clock, class _Duration> | 55 | template <class _Clock, class _Duration> |
| 54 | _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) | 56 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) |
| 55 | : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {} | 57 | : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {} |
| 56 | 58 | ||
| 57 | template <class _Rep, class _Period> | 59 | template <class _Rep, class _Period> |
| 58 | _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) | 60 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) |
| 59 | : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {} | 61 | : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {} |
| 60 | 62 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI ~unique_lock() { | 63 | _LIBCPP_HIDE_FROM_ABI ~unique_lock() { |
| ... | @@ -66,7 +68,9 @@ public: | ... | @@ -66,7 +68,9 @@ public: |
| 66 | unique_lock(unique_lock const&) = delete; | 68 | unique_lock(unique_lock const&) = delete; |
| 67 | unique_lock& operator=(unique_lock const&) = delete; | 69 | unique_lock& operator=(unique_lock const&) = delete; |
| 68 | 70 | ||
| 69 | _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) { | 71 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT |
| 72 | : __m_(__u.__m_), | ||
| 73 | __owns_(__u.__owns_) { | ||
| 70 | __u.__m_ = nullptr; | 74 | __u.__m_ = nullptr; |
| 71 | __u.__owns_ = false; | 75 | __u.__owns_ = false; |
| 72 | } | 76 | } |
lib/libcxx/include/__node_handle+1-1| ... | @@ -147,7 +147,7 @@ public: | ... | @@ -147,7 +147,7 @@ public: |
| 147 | 147 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ptr_ != nullptr; } | 148 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ptr_ != nullptr; } |
| 149 | 149 | ||
| 150 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __ptr_ == nullptr; } | 150 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return __ptr_ == nullptr; } |
| 151 | 151 | ||
| 152 | _LIBCPP_HIDE_FROM_ABI void swap(__basic_node_handle& __other) noexcept( | 152 | _LIBCPP_HIDE_FROM_ABI void swap(__basic_node_handle& __other) noexcept( |
| 153 | __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value) { | 153 | __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value) { |
lib/libcxx/include/__numeric/gcd_lcm.h+58-16| ... | @@ -10,7 +10,9 @@ | ... | @@ -10,7 +10,9 @@ |
| 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> | ||
| 13 | #include <__assert> | 14 | #include <__assert> |
| 15 | #include <__bit/countr.h> | ||
| 14 | #include <__config> | 16 | #include <__config> |
| 15 | #include <__type_traits/common_type.h> | 17 | #include <__type_traits/common_type.h> |
| 16 | #include <__type_traits/is_integral.h> | 18 | #include <__type_traits/is_integral.h> |
| ... | @@ -35,7 +37,7 @@ struct __ct_abs; | ... | @@ -35,7 +37,7 @@ struct __ct_abs; |
| 35 | 37 | ||
| 36 | template <typename _Result, typename _Source> | 38 | template <typename _Result, typename _Source> |
| 37 | struct __ct_abs<_Result, _Source, true> { | 39 | struct __ct_abs<_Result, _Source, true> { |
| 38 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { | 40 | constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { |
| 39 | if (__t >= 0) | 41 | if (__t >= 0) |
| 40 | return __t; | 42 | return __t; |
| 41 | if (__t == numeric_limits<_Source>::min()) | 43 | if (__t == numeric_limits<_Source>::min()) |
| ... | @@ -46,20 +48,58 @@ struct __ct_abs<_Result, _Source, true> { | ... | @@ -46,20 +48,58 @@ struct __ct_abs<_Result, _Source, true> { |
| 46 | 48 | ||
| 47 | template <typename _Result, typename _Source> | 49 | template <typename _Result, typename _Source> |
| 48 | struct __ct_abs<_Result, _Source, false> { | 50 | struct __ct_abs<_Result, _Source, false> { |
| 49 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; } | 51 | constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; } |
| 50 | }; | 52 | }; |
| 51 | 53 | ||
| 52 | template <class _Tp> | 54 | template <class _Tp> |
| 53 | _LIBCPP_CONSTEXPR _LIBCPP_HIDDEN _Tp __gcd(_Tp __m, _Tp __n) { | 55 | constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { |
| 54 | static_assert((!is_signed<_Tp>::value), ""); | 56 | static_assert(!is_signed<_Tp>::value, ""); |
| 55 | return __n == 0 ? __m : std::__gcd<_Tp>(__n, __m % __n); | 57 | |
| 58 | // From: https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor | ||
| 59 | // | ||
| 60 | // If power of two divides both numbers, we can push it out. | ||
| 61 | // - gcd( 2^x * a, 2^x * b) = 2^x * gcd(a, b) | ||
| 62 | // | ||
| 63 | // If and only if exactly one number is even, we can divide that number by that power. | ||
| 64 | // - if a, b are odd, then gcd(2^x * a, b) = gcd(a, b) | ||
| 65 | // | ||
| 66 | // And standard gcd algorithm where instead of modulo, minus is used. | ||
| 67 | |||
| 68 | if (__a < __b) { | ||
| 69 | _Tp __tmp = __b; | ||
| 70 | __b = __a; | ||
| 71 | __a = __tmp; | ||
| 72 | } | ||
| 73 | if (__b == 0) | ||
| 74 | return __a; | ||
| 75 | __a %= __b; // Make both argument of the same size, and early result in the easy case. | ||
| 76 | if (__a == 0) | ||
| 77 | return __b; | ||
| 78 | |||
| 79 | int __az = std::__countr_zero(__a); | ||
| 80 | int __bz = std::__countr_zero(__b); | ||
| 81 | int __shift = std::min(__az, __bz); | ||
| 82 | __a >>= __az; | ||
| 83 | __b >>= __bz; | ||
| 84 | do { | ||
| 85 | _Tp __diff = __a - __b; | ||
| 86 | if (__a > __b) { | ||
| 87 | __a = __b; | ||
| 88 | __b = __diff; | ||
| 89 | } else { | ||
| 90 | __b = __b - __a; | ||
| 91 | } | ||
| 92 | if (__diff != 0) | ||
| 93 | __b >>= std::__countr_zero(__diff); | ||
| 94 | } while (__b != 0); | ||
| 95 | return __a << __shift; | ||
| 56 | } | 96 | } |
| 57 | 97 | ||
| 58 | template <class _Tp, class _Up> | 98 | template <class _Tp, class _Up> |
| 59 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) { | 99 | constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) { |
| 60 | static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); | 100 | static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to gcd must be integer types"); |
| 61 | static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to gcd cannot be bool"); | 101 | static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to gcd cannot be bool"); |
| 62 | static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to gcd cannot be bool"); | 102 | static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to gcd cannot be bool"); |
| 63 | using _Rp = common_type_t<_Tp, _Up>; | 103 | using _Rp = common_type_t<_Tp, _Up>; |
| 64 | using _Wp = make_unsigned_t<_Rp>; | 104 | using _Wp = make_unsigned_t<_Rp>; |
| 65 | return static_cast<_Rp>( | 105 | return static_cast<_Rp>( |
| ... | @@ -67,21 +107,23 @@ _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up | ... | @@ -67,21 +107,23 @@ _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up |
| 67 | } | 107 | } |
| 68 | 108 | ||
| 69 | template <class _Tp, class _Up> | 109 | template <class _Tp, class _Up> |
| 70 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) { | 110 | constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) { |
| 71 | static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); | 111 | static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to lcm must be integer types"); |
| 72 | static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to lcm cannot be bool"); | 112 | static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to lcm cannot be bool"); |
| 73 | static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to lcm cannot be bool"); | 113 | static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to lcm cannot be bool"); |
| 74 | if (__m == 0 || __n == 0) | 114 | if (__m == 0 || __n == 0) |
| 75 | return 0; | 115 | return 0; |
| 76 | 116 | ||
| 77 | using _Rp = common_type_t<_Tp, _Up>; | 117 | using _Rp = common_type_t<_Tp, _Up>; |
| 78 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n); | 118 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n); |
| 79 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); | 119 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); |
| 80 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); | 120 | _Rp __res; |
| 81 | return __val1 * __val2; | 121 | [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, &__res); |
| 122 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm"); | ||
| 123 | return __res; | ||
| 82 | } | 124 | } |
| 83 | 125 | ||
| 84 | #endif // _LIBCPP_STD_VER | 126 | #endif // _LIBCPP_STD_VER >= 17 |
| 85 | 127 | ||
| 86 | _LIBCPP_END_NAMESPACE_STD | 128 | _LIBCPP_END_NAMESPACE_STD |
| 87 | 129 |
lib/libcxx/include/__numeric/midpoint.h+10-8| ... | @@ -67,14 +67,16 @@ template <class _Fp> | ... | @@ -67,14 +67,16 @@ template <class _Fp> |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_floating_point_v<_Fp>, _Fp> midpoint(_Fp __a, _Fp __b) noexcept { | 67 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_floating_point_v<_Fp>, _Fp> midpoint(_Fp __a, _Fp __b) noexcept { |
| 68 | constexpr _Fp __lo = numeric_limits<_Fp>::min() * 2; | 68 | constexpr _Fp __lo = numeric_limits<_Fp>::min() * 2; |
| 69 | constexpr _Fp __hi = numeric_limits<_Fp>::max() / 2; | 69 | constexpr _Fp __hi = numeric_limits<_Fp>::max() / 2; |
| 70 | return std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi | 70 | |
| 71 | ? // typical case: overflow is impossible | 71 | // typical case: overflow is impossible |
| 72 | (__a + __b) / 2 | 72 | if (std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi) |
| 73 | : // always correctly rounded | 73 | return (__a + __b) / 2; // always correctly rounded |
| 74 | std::__fp_abs(__a) < __lo ? __a + __b / 2 : // not safe to halve a | 74 | if (std::__fp_abs(__a) < __lo) |
| 75 | std::__fp_abs(__b) < __lo ? __a / 2 + __b | 75 | return __a + __b / 2; // not safe to halve a |
| 76 | : // not safe to halve b | 76 | if (std::__fp_abs(__b) < __lo) |
| 77 | __a / 2 + __b / 2; // otherwise correctly rounded | 77 | return __a / 2 + __b; // not safe to halve b |
| 78 | |||
| 79 | return __a / 2 + __b / 2; // otherwise correctly rounded | ||
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | #endif // _LIBCPP_STD_VER >= 20 | 82 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__numeric/pstl.h created+174| ... | @@ -0,0 +1,174 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___NUMERIC_PSTL_H | ||
| 10 | #define _LIBCPP___NUMERIC_PSTL_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_PUSH_MACROS | ||
| 19 | #include <__undef_macros> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 22 | |||
| 23 | # include <__functional/identity.h> | ||
| 24 | # include <__functional/operations.h> | ||
| 25 | # include <__iterator/cpp17_iterator_concepts.h> | ||
| 26 | # include <__iterator/iterator_traits.h> | ||
| 27 | # include <__pstl/backend.h> | ||
| 28 | # include <__pstl/dispatch.h> | ||
| 29 | # include <__pstl/handle_exception.h> | ||
| 30 | # include <__type_traits/enable_if.h> | ||
| 31 | # include <__type_traits/is_execution_policy.h> | ||
| 32 | # include <__type_traits/remove_cvref.h> | ||
| 33 | # include <__utility/forward.h> | ||
| 34 | # include <__utility/move.h> | ||
| 35 | |||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 37 | |||
| 38 | template <class _ExecutionPolicy, | ||
| 39 | class _ForwardIterator, | ||
| 40 | class _Tp, | ||
| 41 | class _BinaryOperation, | ||
| 42 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 43 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 44 | _LIBCPP_HIDE_FROM_ABI _Tp reduce( | ||
| 45 | _ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init, _BinaryOperation __op) { | ||
| 46 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators"); | ||
| 47 | using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>; | ||
| 48 | return __pstl::__handle_exception<_Implementation>( | ||
| 49 | std::forward<_ExecutionPolicy>(__policy), | ||
| 50 | std::move(__first), | ||
| 51 | std::move(__last), | ||
| 52 | std::move(__init), | ||
| 53 | std::move(__op)); | ||
| 54 | } | ||
| 55 | |||
| 56 | template <class _ExecutionPolicy, | ||
| 57 | class _ForwardIterator, | ||
| 58 | class _Tp, | ||
| 59 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 60 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 62 | reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init) { | ||
| 63 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators"); | ||
| 64 | using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>; | ||
| 65 | return __pstl::__handle_exception<_Implementation>( | ||
| 66 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__init), plus{}); | ||
| 67 | } | ||
| 68 | |||
| 69 | template <class _ExecutionPolicy, | ||
| 70 | class _ForwardIterator, | ||
| 71 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 72 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 73 | _LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> | ||
| 74 | reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { | ||
| 75 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators"); | ||
| 76 | using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>; | ||
| 77 | return __pstl::__handle_exception<_Implementation>( | ||
| 78 | std::forward<_ExecutionPolicy>(__policy), | ||
| 79 | std::move(__first), | ||
| 80 | std::move(__last), | ||
| 81 | __iter_value_type<_ForwardIterator>(), | ||
| 82 | plus{}); | ||
| 83 | } | ||
| 84 | |||
| 85 | template <class _ExecutionPolicy, | ||
| 86 | class _ForwardIterator1, | ||
| 87 | class _ForwardIterator2, | ||
| 88 | class _Tp, | ||
| 89 | class _BinaryOperation1, | ||
| 90 | class _BinaryOperation2, | ||
| 91 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 92 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 93 | _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( | ||
| 94 | _ExecutionPolicy&& __policy, | ||
| 95 | _ForwardIterator1 __first1, | ||
| 96 | _ForwardIterator1 __last1, | ||
| 97 | _ForwardIterator2 __first2, | ||
| 98 | _Tp __init, | ||
| 99 | _BinaryOperation1 __reduce, | ||
| 100 | _BinaryOperation2 __transform) { | ||
| 101 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform_reduce requires ForwardIterators"); | ||
| 102 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform_reduce requires ForwardIterators"); | ||
| 103 | using _Implementation = | ||
| 104 | __pstl::__dispatch<__pstl::__transform_reduce_binary, __pstl::__current_configuration, _RawPolicy>; | ||
| 105 | return __pstl::__handle_exception<_Implementation>( | ||
| 106 | std::forward<_ExecutionPolicy>(__policy), | ||
| 107 | std::move(__first1), | ||
| 108 | std::move(__last1), | ||
| 109 | std::move(__first2), | ||
| 110 | std::move(__init), | ||
| 111 | std::move(__reduce), | ||
| 112 | std::move(__transform)); | ||
| 113 | } | ||
| 114 | |||
| 115 | // This overload doesn't get a customization point because it's trivial to detect (through e.g. | ||
| 116 | // __desugars_to_v) when specializing the more general variant, which should always be preferred | ||
| 117 | template <class _ExecutionPolicy, | ||
| 118 | class _ForwardIterator1, | ||
| 119 | class _ForwardIterator2, | ||
| 120 | class _Tp, | ||
| 121 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 122 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 123 | _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( | ||
| 124 | _ExecutionPolicy&& __policy, | ||
| 125 | _ForwardIterator1 __first1, | ||
| 126 | _ForwardIterator1 __last1, | ||
| 127 | _ForwardIterator2 __first2, | ||
| 128 | _Tp __init) { | ||
| 129 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform_reduce requires ForwardIterators"); | ||
| 130 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform_reduce requires ForwardIterators"); | ||
| 131 | using _Implementation = | ||
| 132 | __pstl::__dispatch<__pstl::__transform_reduce_binary, __pstl::__current_configuration, _RawPolicy>; | ||
| 133 | return __pstl::__handle_exception<_Implementation>( | ||
| 134 | std::forward<_ExecutionPolicy>(__policy), | ||
| 135 | std::move(__first1), | ||
| 136 | std::move(__last1), | ||
| 137 | std::move(__first2), | ||
| 138 | std::move(__init), | ||
| 139 | plus{}, | ||
| 140 | multiplies{}); | ||
| 141 | } | ||
| 142 | |||
| 143 | template <class _ExecutionPolicy, | ||
| 144 | class _ForwardIterator, | ||
| 145 | class _Tp, | ||
| 146 | class _BinaryOperation, | ||
| 147 | class _UnaryOperation, | ||
| 148 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 149 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 150 | _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( | ||
| 151 | _ExecutionPolicy&& __policy, | ||
| 152 | _ForwardIterator __first, | ||
| 153 | _ForwardIterator __last, | ||
| 154 | _Tp __init, | ||
| 155 | _BinaryOperation __reduce, | ||
| 156 | _UnaryOperation __transform) { | ||
| 157 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "transform_reduce requires ForwardIterators"); | ||
| 158 | using _Implementation = __pstl::__dispatch<__pstl::__transform_reduce, __pstl::__current_configuration, _RawPolicy>; | ||
| 159 | return __pstl::__handle_exception<_Implementation>( | ||
| 160 | std::forward<_ExecutionPolicy>(__policy), | ||
| 161 | std::move(__first), | ||
| 162 | std::move(__last), | ||
| 163 | std::move(__init), | ||
| 164 | std::move(__reduce), | ||
| 165 | std::move(__transform)); | ||
| 166 | } | ||
| 167 | |||
| 168 | _LIBCPP_END_NAMESPACE_STD | ||
| 169 | |||
| 170 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 171 | |||
| 172 | _LIBCPP_POP_MACROS | ||
| 173 | |||
| 174 | #endif // _LIBCPP___NUMERIC_PSTL_H | ||
lib/libcxx/include/__numeric/pstl_reduce.h deleted-109| ... | @@ -1,109 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___NUMERIC_PSTL_REDUCE_H | ||
| 10 | #define _LIBCPP___NUMERIC_PSTL_REDUCE_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__functional/identity.h> | ||
| 15 | #include <__iterator/iterator_traits.h> | ||
| 16 | #include <__numeric/pstl_transform_reduce.h> | ||
| 17 | #include <__type_traits/is_execution_policy.h> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | _LIBCPP_PUSH_MACROS | ||
| 24 | #include <__undef_macros> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 27 | |||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 29 | |||
| 30 | template <class> | ||
| 31 | void __pstl_reduce(); | ||
| 32 | |||
| 33 | template <class _ExecutionPolicy, | ||
| 34 | class _ForwardIterator, | ||
| 35 | class _Tp, | ||
| 36 | class _BinaryOperation = plus<>, | ||
| 37 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 38 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_Tp> | ||
| 40 | __reduce(_ExecutionPolicy&& __policy, | ||
| 41 | _ForwardIterator&& __first, | ||
| 42 | _ForwardIterator&& __last, | ||
| 43 | _Tp&& __init, | ||
| 44 | _BinaryOperation&& __op = {}) noexcept { | ||
| 45 | return std::__pstl_frontend_dispatch( | ||
| 46 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), | ||
| 47 | [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Tp __g_init, _BinaryOperation __g_op) { | ||
| 48 | return std::__transform_reduce( | ||
| 49 | __policy, std::move(__g_first), std::move(__g_last), std::move(__g_init), std::move(__g_op), __identity{}); | ||
| 50 | }, | ||
| 51 | std::move(__first), | ||
| 52 | std::move(__last), | ||
| 53 | std::move(__init), | ||
| 54 | std::move(__op)); | ||
| 55 | } | ||
| 56 | |||
| 57 | template <class _ExecutionPolicy, | ||
| 58 | class _ForwardIterator, | ||
| 59 | class _Tp, | ||
| 60 | class _BinaryOperation = plus<>, | ||
| 61 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 62 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 63 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 64 | reduce(_ExecutionPolicy&& __policy, | ||
| 65 | _ForwardIterator __first, | ||
| 66 | _ForwardIterator __last, | ||
| 67 | _Tp __init, | ||
| 68 | _BinaryOperation __op = {}) { | ||
| 69 | auto __res = std::__reduce(__policy, std::move(__first), std::move(__last), std::move(__init), std::move(__op)); | ||
| 70 | if (!__res) | ||
| 71 | std::__throw_bad_alloc(); | ||
| 72 | return *std::move(__res); | ||
| 73 | } | ||
| 74 | |||
| 75 | template <class _ExecutionPolicy, | ||
| 76 | class _ForwardIterator, | ||
| 77 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 78 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_value_type<_ForwardIterator>> | ||
| 80 | __reduce(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last) noexcept { | ||
| 81 | return std::__pstl_frontend_dispatch( | ||
| 82 | _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), | ||
| 83 | [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last) { | ||
| 84 | return std::__reduce( | ||
| 85 | __policy, std::move(__g_first), std::move(__g_last), __iter_value_type<_ForwardIterator>()); | ||
| 86 | }, | ||
| 87 | std::move(__first), | ||
| 88 | std::move(__last)); | ||
| 89 | } | ||
| 90 | |||
| 91 | template <class _ExecutionPolicy, | ||
| 92 | class _ForwardIterator, | ||
| 93 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 94 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 95 | _LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> | ||
| 96 | reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { | ||
| 97 | auto __res = std::__reduce(__policy, std::move(__first), std::move(__last)); | ||
| 98 | if (!__res) | ||
| 99 | std::__throw_bad_alloc(); | ||
| 100 | return *std::move(__res); | ||
| 101 | } | ||
| 102 | |||
| 103 | _LIBCPP_END_NAMESPACE_STD | ||
| 104 | |||
| 105 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 106 | |||
| 107 | _LIBCPP_POP_MACROS | ||
| 108 | |||
| 109 | #endif // _LIBCPP___NUMERIC_PSTL_REDUCE_H | ||
lib/libcxx/include/__numeric/pstl_transform_reduce.h deleted-156| ... | @@ -1,156 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___NUMERIC_PSTL_TRANSFORM_REDUCE_H | ||
| 10 | #define _LIBCPP___NUMERIC_PSTL_TRANSFORM_REDUCE_H | ||
| 11 | |||
| 12 | #include <__algorithm/pstl_backend.h> | ||
| 13 | #include <__algorithm/pstl_frontend_dispatch.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__functional/operations.h> | ||
| 16 | #include <__numeric/transform_reduce.h> | ||
| 17 | #include <__type_traits/is_execution_policy.h> | ||
| 18 | #include <__utility/move.h> | ||
| 19 | #include <optional> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | #include <__undef_macros> | ||
| 27 | |||
| 28 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | template <class _ExecutionPolicy, | ||
| 33 | class _ForwardIterator1, | ||
| 34 | class _ForwardIterator2, | ||
| 35 | class _Tp, | ||
| 36 | class _BinaryOperation1, | ||
| 37 | class _BinaryOperation2, | ||
| 38 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 39 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 40 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> __transform_reduce( | ||
| 41 | _ExecutionPolicy&&, | ||
| 42 | _ForwardIterator1&& __first1, | ||
| 43 | _ForwardIterator1&& __last1, | ||
| 44 | _ForwardIterator2&& __first2, | ||
| 45 | _Tp&& __init, | ||
| 46 | _BinaryOperation1&& __reduce, | ||
| 47 | _BinaryOperation2&& __transform) noexcept { | ||
| 48 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 49 | return std::__pstl_transform_reduce<_RawPolicy>( | ||
| 50 | _Backend{}, | ||
| 51 | std::move(__first1), | ||
| 52 | std::move(__last1), | ||
| 53 | std::move(__first2), | ||
| 54 | std::move(__init), | ||
| 55 | std::move(__reduce), | ||
| 56 | std::move(__transform)); | ||
| 57 | } | ||
| 58 | |||
| 59 | template <class _ExecutionPolicy, | ||
| 60 | class _ForwardIterator1, | ||
| 61 | class _ForwardIterator2, | ||
| 62 | class _Tp, | ||
| 63 | class _BinaryOperation1, | ||
| 64 | class _BinaryOperation2, | ||
| 65 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 66 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 67 | _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( | ||
| 68 | _ExecutionPolicy&& __policy, | ||
| 69 | _ForwardIterator1 __first1, | ||
| 70 | _ForwardIterator1 __last1, | ||
| 71 | _ForwardIterator2 __first2, | ||
| 72 | _Tp __init, | ||
| 73 | _BinaryOperation1 __reduce, | ||
| 74 | _BinaryOperation2 __transform) { | ||
| 75 | auto __res = std::__transform_reduce( | ||
| 76 | __policy, | ||
| 77 | std::move(__first1), | ||
| 78 | std::move(__last1), | ||
| 79 | std::move(__first2), | ||
| 80 | std::move(__init), | ||
| 81 | std::move(__reduce), | ||
| 82 | std::move(__transform)); | ||
| 83 | |||
| 84 | if (!__res) | ||
| 85 | std::__throw_bad_alloc(); | ||
| 86 | return *std::move(__res); | ||
| 87 | } | ||
| 88 | |||
| 89 | // This overload doesn't get a customization point because it's trivial to detect (through e.g. | ||
| 90 | // __desugars_to) when specializing the more general variant, which should always be preferred | ||
| 91 | template <class _ExecutionPolicy, | ||
| 92 | class _ForwardIterator1, | ||
| 93 | class _ForwardIterator2, | ||
| 94 | class _Tp, | ||
| 95 | enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> | ||
| 96 | _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( | ||
| 97 | _ExecutionPolicy&& __policy, | ||
| 98 | _ForwardIterator1 __first1, | ||
| 99 | _ForwardIterator1 __last1, | ||
| 100 | _ForwardIterator2 __first2, | ||
| 101 | _Tp __init) { | ||
| 102 | return std::transform_reduce(__policy, __first1, __last1, __first2, __init, plus{}, multiplies{}); | ||
| 103 | } | ||
| 104 | |||
| 105 | template <class _ExecutionPolicy, | ||
| 106 | class _ForwardIterator, | ||
| 107 | class _Tp, | ||
| 108 | class _BinaryOperation, | ||
| 109 | class _UnaryOperation, | ||
| 110 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 111 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 112 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_Tp>> __transform_reduce( | ||
| 113 | _ExecutionPolicy&&, | ||
| 114 | _ForwardIterator&& __first, | ||
| 115 | _ForwardIterator&& __last, | ||
| 116 | _Tp&& __init, | ||
| 117 | _BinaryOperation&& __reduce, | ||
| 118 | _UnaryOperation&& __transform) noexcept { | ||
| 119 | using _Backend = typename __select_backend<_RawPolicy>::type; | ||
| 120 | return std::__pstl_transform_reduce<_RawPolicy>( | ||
| 121 | _Backend{}, | ||
| 122 | std::move(__first), | ||
| 123 | std::move(__last), | ||
| 124 | std::move(__init), | ||
| 125 | std::move(__reduce), | ||
| 126 | std::move(__transform)); | ||
| 127 | } | ||
| 128 | |||
| 129 | template <class _ExecutionPolicy, | ||
| 130 | class _ForwardIterator, | ||
| 131 | class _Tp, | ||
| 132 | class _BinaryOperation, | ||
| 133 | class _UnaryOperation, | ||
| 134 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | ||
| 135 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | ||
| 136 | _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( | ||
| 137 | _ExecutionPolicy&& __policy, | ||
| 138 | _ForwardIterator __first, | ||
| 139 | _ForwardIterator __last, | ||
| 140 | _Tp __init, | ||
| 141 | _BinaryOperation __reduce, | ||
| 142 | _UnaryOperation __transform) { | ||
| 143 | auto __res = std::__transform_reduce( | ||
| 144 | __policy, std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); | ||
| 145 | if (!__res) | ||
| 146 | std::__throw_bad_alloc(); | ||
| 147 | return *std::move(__res); | ||
| 148 | } | ||
| 149 | |||
| 150 | _LIBCPP_END_NAMESPACE_STD | ||
| 151 | |||
| 152 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | ||
| 153 | |||
| 154 | _LIBCPP_POP_MACROS | ||
| 155 | |||
| 156 | #endif // _LIBCPP___NUMERIC_PSTL_TRANSFORM_REDUCE_H | ||
lib/libcxx/include/__numeric/saturation_arithmetic.h+36-6| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H | 10 | #ifndef _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H |
| 11 | #define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H | 11 | #define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 13 | #include <__concepts/arithmetic.h> | 14 | #include <__concepts/arithmetic.h> |
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__utility/cmp.h> | 16 | #include <__utility/cmp.h> |
| ... | @@ -24,10 +25,10 @@ _LIBCPP_PUSH_MACROS | ... | @@ -24,10 +25,10 @@ _LIBCPP_PUSH_MACROS |
| 24 | 25 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | ||
| 27 | #if _LIBCPP_STD_VER >= 26 | 28 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 29 | ||
| 29 | template <__libcpp_integer _Tp> | 30 | template <__libcpp_integer _Tp> |
| 30 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { | 31 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { |
| 31 | if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum)) | 32 | if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum)) |
| 32 | return __sum; | 33 | return __sum; |
| 33 | // Handle overflow | 34 | // Handle overflow |
| ... | @@ -45,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -45,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | template <__libcpp_integer _Tp> | 48 | template <__libcpp_integer _Tp> |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { | 49 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { |
| 49 | if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub)) | 50 | if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub)) |
| 50 | return __sub; | 51 | return __sub; |
| 51 | // Handle overflow | 52 | // Handle overflow |
| ... | @@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { |
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | template <__libcpp_integer _Tp> | 67 | template <__libcpp_integer _Tp> |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { | 68 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept { |
| 68 | if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul)) | 69 | if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul)) |
| 69 | return __mul; | 70 | return __mul; |
| 70 | // Handle overflow | 71 | // Handle overflow |
| ... | @@ -80,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -80,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | template <__libcpp_integer _Tp> | 83 | template <__libcpp_integer _Tp> |
| 83 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { | 84 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept { |
| 84 | _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined"); | 85 | _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined"); |
| 85 | if constexpr (__libcpp_unsigned_integer<_Tp>) { | 86 | if constexpr (__libcpp_unsigned_integer<_Tp>) { |
| 86 | return __x / __y; | 87 | return __x / __y; |
| ... | @@ -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 | template <__libcpp_integer _Rp, __libcpp_integer _Tp> | 96 | template <__libcpp_integer _Rp, __libcpp_integer _Tp> |
| 96 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { | 97 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { |
| 97 | // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be | 98 | // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be |
| 98 | // optimized out by the compiler. | 99 | // optimized out by the compiler. |
| 99 | 100 | ||
| ... | @@ -106,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { | ... | @@ -106,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { |
| 106 | return static_cast<_Rp>(__x); | 107 | return static_cast<_Rp>(__x); |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 110 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 111 | |||
| 112 | #if _LIBCPP_STD_VER >= 26 | ||
| 113 | |||
| 114 | template <__libcpp_integer _Tp> | ||
| 115 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { | ||
| 116 | return std::__add_sat(__x, __y); | ||
| 117 | } | ||
| 118 | |||
| 119 | template <__libcpp_integer _Tp> | ||
| 120 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { | ||
| 121 | return std::__sub_sat(__x, __y); | ||
| 122 | } | ||
| 123 | |||
| 124 | template <__libcpp_integer _Tp> | ||
| 125 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { | ||
| 126 | return std::__mul_sat(__x, __y); | ||
| 127 | } | ||
| 128 | |||
| 129 | template <__libcpp_integer _Tp> | ||
| 130 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { | ||
| 131 | return std::__div_sat(__x, __y); | ||
| 132 | } | ||
| 133 | |||
| 134 | template <__libcpp_integer _Rp, __libcpp_integer _Tp> | ||
| 135 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { | ||
| 136 | return std::__saturate_cast<_Rp>(__x); | ||
| 137 | } | ||
| 138 | |||
| 109 | #endif // _LIBCPP_STD_VER >= 26 | 139 | #endif // _LIBCPP_STD_VER >= 26 |
| 110 | 140 | ||
| 111 | _LIBCPP_END_NAMESPACE_STD | 141 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__ostream/basic_ostream.h created+860| ... | @@ -0,0 +1,860 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___OSTREAM_BASIC_OSTREAM_H | ||
| 10 | #define _LIBCPP___OSTREAM_BASIC_OSTREAM_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__exception/operations.h> | ||
| 14 | #include <__memory/shared_ptr.h> | ||
| 15 | #include <__memory/unique_ptr.h> | ||
| 16 | #include <__system_error/error_code.h> | ||
| 17 | #include <__type_traits/conjunction.h> | ||
| 18 | #include <__type_traits/enable_if.h> | ||
| 19 | #include <__type_traits/is_base_of.h> | ||
| 20 | #include <__type_traits/void_t.h> | ||
| 21 | #include <__utility/declval.h> | ||
| 22 | #include <bitset> | ||
| 23 | #include <cstddef> | ||
| 24 | #include <ios> | ||
| 25 | #include <locale> | ||
| 26 | #include <new> // for __throw_bad_alloc | ||
| 27 | #include <streambuf> | ||
| 28 | #include <string_view> | ||
| 29 | |||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 31 | # pragma GCC system_header | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_PUSH_MACROS | ||
| 35 | #include <__undef_macros> | ||
| 36 | |||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 38 | |||
| 39 | template <class _CharT, class _Traits> | ||
| 40 | class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> { | ||
| 41 | public: | ||
| 42 | // types (inherited from basic_ios (27.5.4)): | ||
| 43 | typedef _CharT char_type; | ||
| 44 | typedef _Traits traits_type; | ||
| 45 | typedef typename traits_type::int_type int_type; | ||
| 46 | typedef typename traits_type::pos_type pos_type; | ||
| 47 | typedef typename traits_type::off_type off_type; | ||
| 48 | |||
| 49 | // 27.7.2.2 Constructor/destructor: | ||
| 50 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) { | ||
| 51 | this->init(__sb); | ||
| 52 | } | ||
| 53 | ~basic_ostream() override; | ||
| 54 | |||
| 55 | basic_ostream(const basic_ostream& __rhs) = delete; | ||
| 56 | basic_ostream& operator=(const basic_ostream& __rhs) = delete; | ||
| 57 | |||
| 58 | protected: | ||
| 59 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs); | ||
| 60 | |||
| 61 | // 27.7.2.3 Assign/swap | ||
| 62 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs); | ||
| 63 | |||
| 64 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_ostream& __rhs) { | ||
| 65 | basic_ios<char_type, traits_type>::swap(__rhs); | ||
| 66 | } | ||
| 67 | |||
| 68 | public: | ||
| 69 | // 27.7.2.4 Prefix/suffix: | ||
| 70 | class _LIBCPP_TEMPLATE_VIS sentry; | ||
| 71 | |||
| 72 | // 27.7.2.6 Formatted output: | ||
| 73 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) { | ||
| 74 | return __pf(*this); | ||
| 75 | } | ||
| 76 | |||
| 77 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& | ||
| 78 | operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) { | ||
| 79 | __pf(*this); | ||
| 80 | return *this; | ||
| 81 | } | ||
| 82 | |||
| 83 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) { | ||
| 84 | __pf(*this); | ||
| 85 | return *this; | ||
| 86 | } | ||
| 87 | |||
| 88 | basic_ostream& operator<<(bool __n); | ||
| 89 | basic_ostream& operator<<(short __n); | ||
| 90 | basic_ostream& operator<<(unsigned short __n); | ||
| 91 | basic_ostream& operator<<(int __n); | ||
| 92 | basic_ostream& operator<<(unsigned int __n); | ||
| 93 | basic_ostream& operator<<(long __n); | ||
| 94 | basic_ostream& operator<<(unsigned long __n); | ||
| 95 | basic_ostream& operator<<(long long __n); | ||
| 96 | basic_ostream& operator<<(unsigned long long __n); | ||
| 97 | basic_ostream& operator<<(float __f); | ||
| 98 | basic_ostream& operator<<(double __f); | ||
| 99 | basic_ostream& operator<<(long double __f); | ||
| 100 | basic_ostream& operator<<(const void* __p); | ||
| 101 | |||
| 102 | #if _LIBCPP_STD_VER >= 23 | ||
| 103 | _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) { | ||
| 104 | return operator<<(const_cast<const void*>(__p)); | ||
| 105 | } | ||
| 106 | #endif | ||
| 107 | |||
| 108 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); | ||
| 109 | |||
| 110 | #if _LIBCPP_STD_VER >= 17 | ||
| 111 | // LWG 2221 - nullptr. This is not backported to older standards modes. | ||
| 112 | // See https://reviews.llvm.org/D127033 for more info on the rationale. | ||
| 113 | _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; } | ||
| 114 | #endif | ||
| 115 | |||
| 116 | // 27.7.2.7 Unformatted output: | ||
| 117 | basic_ostream& put(char_type __c); | ||
| 118 | basic_ostream& write(const char_type* __s, streamsize __n); | ||
| 119 | basic_ostream& flush(); | ||
| 120 | |||
| 121 | // 27.7.2.5 seeks: | ||
| 122 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type tellp(); | ||
| 123 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(pos_type __pos); | ||
| 124 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir); | ||
| 125 | |||
| 126 | protected: | ||
| 127 | _LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize | ||
| 128 | }; | ||
| 129 | |||
| 130 | template <class _CharT, class _Traits> | ||
| 131 | class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry { | ||
| 132 | bool __ok_; | ||
| 133 | basic_ostream<_CharT, _Traits>& __os_; | ||
| 134 | |||
| 135 | public: | ||
| 136 | explicit sentry(basic_ostream<_CharT, _Traits>& __os); | ||
| 137 | ~sentry(); | ||
| 138 | sentry(const sentry&) = delete; | ||
| 139 | sentry& operator=(const sentry&) = delete; | ||
| 140 | |||
| 141 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; } | ||
| 142 | }; | ||
| 143 | |||
| 144 | template <class _CharT, class _Traits> | ||
| 145 | basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) { | ||
| 146 | if (__os.good()) { | ||
| 147 | if (__os.tie()) | ||
| 148 | __os.tie()->flush(); | ||
| 149 | __ok_ = true; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | template <class _CharT, class _Traits> | ||
| 154 | basic_ostream<_CharT, _Traits>::sentry::~sentry() { | ||
| 155 | if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && !uncaught_exception()) { | ||
| 156 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 157 | try { | ||
| 158 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 159 | if (__os_.rdbuf()->pubsync() == -1) | ||
| 160 | __os_.setstate(ios_base::badbit); | ||
| 161 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 162 | } catch (...) { | ||
| 163 | } | ||
| 164 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | template <class _CharT, class _Traits> | ||
| 169 | basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) { | ||
| 170 | this->move(__rhs); | ||
| 171 | } | ||
| 172 | |||
| 173 | template <class _CharT, class _Traits> | ||
| 174 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) { | ||
| 175 | swap(__rhs); | ||
| 176 | return *this; | ||
| 177 | } | ||
| 178 | |||
| 179 | template <class _CharT, class _Traits> | ||
| 180 | basic_ostream<_CharT, _Traits>::~basic_ostream() {} | ||
| 181 | |||
| 182 | template <class _CharT, class _Traits> | ||
| 183 | basic_ostream<_CharT, _Traits>& | ||
| 184 | basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) { | ||
| 185 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 186 | try { | ||
| 187 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 188 | sentry __s(*this); | ||
| 189 | if (__s) { | ||
| 190 | if (__sb) { | ||
| 191 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 192 | try { | ||
| 193 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 194 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 195 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; | ||
| 196 | _Ip __i(__sb); | ||
| 197 | _Ip __eof; | ||
| 198 | _Op __o(*this); | ||
| 199 | size_t __c = 0; | ||
| 200 | for (; __i != __eof; ++__i, ++__o, ++__c) { | ||
| 201 | *__o = *__i; | ||
| 202 | if (__o.failed()) | ||
| 203 | break; | ||
| 204 | } | ||
| 205 | if (__c == 0) | ||
| 206 | this->setstate(ios_base::failbit); | ||
| 207 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 208 | } catch (...) { | ||
| 209 | this->__set_failbit_and_consider_rethrow(); | ||
| 210 | } | ||
| 211 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 212 | } else | ||
| 213 | this->setstate(ios_base::badbit); | ||
| 214 | } | ||
| 215 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 216 | } catch (...) { | ||
| 217 | this->__set_badbit_and_consider_rethrow(); | ||
| 218 | } | ||
| 219 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 220 | return *this; | ||
| 221 | } | ||
| 222 | |||
| 223 | template <class _CharT, class _Traits> | ||
| 224 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) { | ||
| 225 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 226 | try { | ||
| 227 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 228 | sentry __s(*this); | ||
| 229 | if (__s) { | ||
| 230 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 231 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 232 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 233 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 234 | } | ||
| 235 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 236 | } catch (...) { | ||
| 237 | this->__set_badbit_and_consider_rethrow(); | ||
| 238 | } | ||
| 239 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 240 | return *this; | ||
| 241 | } | ||
| 242 | |||
| 243 | template <class _CharT, class _Traits> | ||
| 244 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) { | ||
| 245 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 246 | try { | ||
| 247 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 248 | sentry __s(*this); | ||
| 249 | if (__s) { | ||
| 250 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; | ||
| 251 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 252 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 253 | if (__f.put(*this, | ||
| 254 | *this, | ||
| 255 | this->fill(), | ||
| 256 | __flags == ios_base::oct || __flags == ios_base::hex | ||
| 257 | ? static_cast<long>(static_cast<unsigned short>(__n)) | ||
| 258 | : static_cast<long>(__n)) | ||
| 259 | .failed()) | ||
| 260 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 261 | } | ||
| 262 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 263 | } catch (...) { | ||
| 264 | this->__set_badbit_and_consider_rethrow(); | ||
| 265 | } | ||
| 266 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 267 | return *this; | ||
| 268 | } | ||
| 269 | |||
| 270 | template <class _CharT, class _Traits> | ||
| 271 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) { | ||
| 272 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 273 | try { | ||
| 274 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 275 | sentry __s(*this); | ||
| 276 | if (__s) { | ||
| 277 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 278 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 279 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) | ||
| 280 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 281 | } | ||
| 282 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 283 | } catch (...) { | ||
| 284 | this->__set_badbit_and_consider_rethrow(); | ||
| 285 | } | ||
| 286 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 287 | return *this; | ||
| 288 | } | ||
| 289 | |||
| 290 | template <class _CharT, class _Traits> | ||
| 291 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) { | ||
| 292 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 293 | try { | ||
| 294 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 295 | sentry __s(*this); | ||
| 296 | if (__s) { | ||
| 297 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; | ||
| 298 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 299 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 300 | if (__f.put(*this, | ||
| 301 | *this, | ||
| 302 | this->fill(), | ||
| 303 | __flags == ios_base::oct || __flags == ios_base::hex | ||
| 304 | ? static_cast<long>(static_cast<unsigned int>(__n)) | ||
| 305 | : static_cast<long>(__n)) | ||
| 306 | .failed()) | ||
| 307 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 308 | } | ||
| 309 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 310 | } catch (...) { | ||
| 311 | this->__set_badbit_and_consider_rethrow(); | ||
| 312 | } | ||
| 313 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 314 | return *this; | ||
| 315 | } | ||
| 316 | |||
| 317 | template <class _CharT, class _Traits> | ||
| 318 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) { | ||
| 319 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 320 | try { | ||
| 321 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 322 | sentry __s(*this); | ||
| 323 | if (__s) { | ||
| 324 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 325 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 326 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) | ||
| 327 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 328 | } | ||
| 329 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 330 | } catch (...) { | ||
| 331 | this->__set_badbit_and_consider_rethrow(); | ||
| 332 | } | ||
| 333 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 334 | return *this; | ||
| 335 | } | ||
| 336 | |||
| 337 | template <class _CharT, class _Traits> | ||
| 338 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) { | ||
| 339 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 340 | try { | ||
| 341 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 342 | sentry __s(*this); | ||
| 343 | if (__s) { | ||
| 344 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 345 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 346 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 347 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 348 | } | ||
| 349 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 350 | } catch (...) { | ||
| 351 | this->__set_badbit_and_consider_rethrow(); | ||
| 352 | } | ||
| 353 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 354 | return *this; | ||
| 355 | } | ||
| 356 | |||
| 357 | template <class _CharT, class _Traits> | ||
| 358 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) { | ||
| 359 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 360 | try { | ||
| 361 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 362 | sentry __s(*this); | ||
| 363 | if (__s) { | ||
| 364 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 365 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 366 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 367 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 368 | } | ||
| 369 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 370 | } catch (...) { | ||
| 371 | this->__set_badbit_and_consider_rethrow(); | ||
| 372 | } | ||
| 373 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 374 | return *this; | ||
| 375 | } | ||
| 376 | |||
| 377 | template <class _CharT, class _Traits> | ||
| 378 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) { | ||
| 379 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 380 | try { | ||
| 381 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 382 | sentry __s(*this); | ||
| 383 | if (__s) { | ||
| 384 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 385 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 386 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 387 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 388 | } | ||
| 389 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 390 | } catch (...) { | ||
| 391 | this->__set_badbit_and_consider_rethrow(); | ||
| 392 | } | ||
| 393 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 394 | return *this; | ||
| 395 | } | ||
| 396 | |||
| 397 | template <class _CharT, class _Traits> | ||
| 398 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) { | ||
| 399 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 400 | try { | ||
| 401 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 402 | sentry __s(*this); | ||
| 403 | if (__s) { | ||
| 404 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 405 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 406 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 407 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 408 | } | ||
| 409 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 410 | } catch (...) { | ||
| 411 | this->__set_badbit_and_consider_rethrow(); | ||
| 412 | } | ||
| 413 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 414 | return *this; | ||
| 415 | } | ||
| 416 | |||
| 417 | template <class _CharT, class _Traits> | ||
| 418 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) { | ||
| 419 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 420 | try { | ||
| 421 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 422 | sentry __s(*this); | ||
| 423 | if (__s) { | ||
| 424 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 425 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 426 | if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed()) | ||
| 427 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 428 | } | ||
| 429 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 430 | } catch (...) { | ||
| 431 | this->__set_badbit_and_consider_rethrow(); | ||
| 432 | } | ||
| 433 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 434 | return *this; | ||
| 435 | } | ||
| 436 | |||
| 437 | template <class _CharT, class _Traits> | ||
| 438 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) { | ||
| 439 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 440 | try { | ||
| 441 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 442 | sentry __s(*this); | ||
| 443 | if (__s) { | ||
| 444 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 445 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 446 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 447 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 448 | } | ||
| 449 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 450 | } catch (...) { | ||
| 451 | this->__set_badbit_and_consider_rethrow(); | ||
| 452 | } | ||
| 453 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 454 | return *this; | ||
| 455 | } | ||
| 456 | |||
| 457 | template <class _CharT, class _Traits> | ||
| 458 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) { | ||
| 459 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 460 | try { | ||
| 461 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 462 | sentry __s(*this); | ||
| 463 | if (__s) { | ||
| 464 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 465 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 466 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 467 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 468 | } | ||
| 469 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 470 | } catch (...) { | ||
| 471 | this->__set_badbit_and_consider_rethrow(); | ||
| 472 | } | ||
| 473 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 474 | return *this; | ||
| 475 | } | ||
| 476 | |||
| 477 | template <class _CharT, class _Traits> | ||
| 478 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) { | ||
| 479 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 480 | try { | ||
| 481 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 482 | sentry __s(*this); | ||
| 483 | if (__s) { | ||
| 484 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 485 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 486 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 487 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 488 | } | ||
| 489 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 490 | } catch (...) { | ||
| 491 | this->__set_badbit_and_consider_rethrow(); | ||
| 492 | } | ||
| 493 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 494 | return *this; | ||
| 495 | } | ||
| 496 | |||
| 497 | template <class _CharT, class _Traits> | ||
| 498 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 499 | __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) { | ||
| 500 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 501 | try { | ||
| 502 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 503 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | ||
| 504 | if (__s) { | ||
| 505 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 506 | if (std::__pad_and_output( | ||
| 507 | _Ip(__os), | ||
| 508 | __str, | ||
| 509 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str, | ||
| 510 | __str + __len, | ||
| 511 | __os, | ||
| 512 | __os.fill()) | ||
| 513 | .failed()) | ||
| 514 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 515 | } | ||
| 516 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 517 | } catch (...) { | ||
| 518 | __os.__set_badbit_and_consider_rethrow(); | ||
| 519 | } | ||
| 520 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 521 | return __os; | ||
| 522 | } | ||
| 523 | |||
| 524 | template <class _CharT, class _Traits> | ||
| 525 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) { | ||
| 526 | return std::__put_character_sequence(__os, &__c, 1); | ||
| 527 | } | ||
| 528 | |||
| 529 | template <class _CharT, class _Traits> | ||
| 530 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) { | ||
| 531 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 532 | try { | ||
| 533 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 534 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | ||
| 535 | if (__s) { | ||
| 536 | _CharT __c = __os.widen(__cn); | ||
| 537 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 538 | if (std::__pad_and_output( | ||
| 539 | _Ip(__os), | ||
| 540 | &__c, | ||
| 541 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c, | ||
| 542 | &__c + 1, | ||
| 543 | __os, | ||
| 544 | __os.fill()) | ||
| 545 | .failed()) | ||
| 546 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 547 | } | ||
| 548 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 549 | } catch (...) { | ||
| 550 | __os.__set_badbit_and_consider_rethrow(); | ||
| 551 | } | ||
| 552 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 553 | return __os; | ||
| 554 | } | ||
| 555 | |||
| 556 | template <class _Traits> | ||
| 557 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, char __c) { | ||
| 558 | return std::__put_character_sequence(__os, &__c, 1); | ||
| 559 | } | ||
| 560 | |||
| 561 | template <class _Traits> | ||
| 562 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, signed char __c) { | ||
| 563 | return std::__put_character_sequence(__os, (char*)&__c, 1); | ||
| 564 | } | ||
| 565 | |||
| 566 | template <class _Traits> | ||
| 567 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) { | ||
| 568 | return std::__put_character_sequence(__os, (char*)&__c, 1); | ||
| 569 | } | ||
| 570 | |||
| 571 | template <class _CharT, class _Traits> | ||
| 572 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 573 | operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) { | ||
| 574 | return std::__put_character_sequence(__os, __str, _Traits::length(__str)); | ||
| 575 | } | ||
| 576 | |||
| 577 | template <class _CharT, class _Traits> | ||
| 578 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 579 | operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { | ||
| 580 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 581 | try { | ||
| 582 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 583 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | ||
| 584 | if (__s) { | ||
| 585 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 586 | size_t __len = char_traits<char>::length(__strn); | ||
| 587 | const int __bs = 100; | ||
| 588 | _CharT __wbb[__bs]; | ||
| 589 | _CharT* __wb = __wbb; | ||
| 590 | unique_ptr<_CharT, void (*)(void*)> __h(0, free); | ||
| 591 | if (__len > __bs) { | ||
| 592 | __wb = (_CharT*)malloc(__len * sizeof(_CharT)); | ||
| 593 | if (__wb == 0) | ||
| 594 | __throw_bad_alloc(); | ||
| 595 | __h.reset(__wb); | ||
| 596 | } | ||
| 597 | for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p) | ||
| 598 | *__p = __os.widen(*__strn); | ||
| 599 | if (std::__pad_and_output( | ||
| 600 | _Ip(__os), | ||
| 601 | __wb, | ||
| 602 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __wb + __len : __wb, | ||
| 603 | __wb + __len, | ||
| 604 | __os, | ||
| 605 | __os.fill()) | ||
| 606 | .failed()) | ||
| 607 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 608 | } | ||
| 609 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 610 | } catch (...) { | ||
| 611 | __os.__set_badbit_and_consider_rethrow(); | ||
| 612 | } | ||
| 613 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 614 | return __os; | ||
| 615 | } | ||
| 616 | |||
| 617 | template <class _Traits> | ||
| 618 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, const char* __str) { | ||
| 619 | return std::__put_character_sequence(__os, __str, _Traits::length(__str)); | ||
| 620 | } | ||
| 621 | |||
| 622 | template <class _Traits> | ||
| 623 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& | ||
| 624 | operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) { | ||
| 625 | const char* __s = (const char*)__str; | ||
| 626 | return std::__put_character_sequence(__os, __s, _Traits::length(__s)); | ||
| 627 | } | ||
| 628 | |||
| 629 | template <class _Traits> | ||
| 630 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& | ||
| 631 | operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) { | ||
| 632 | const char* __s = (const char*)__str; | ||
| 633 | return std::__put_character_sequence(__os, __s, _Traits::length(__s)); | ||
| 634 | } | ||
| 635 | |||
| 636 | template <class _CharT, class _Traits> | ||
| 637 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) { | ||
| 638 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 639 | try { | ||
| 640 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 641 | sentry __s(*this); | ||
| 642 | if (__s) { | ||
| 643 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; | ||
| 644 | _Op __o(*this); | ||
| 645 | *__o = __c; | ||
| 646 | if (__o.failed()) | ||
| 647 | this->setstate(ios_base::badbit); | ||
| 648 | } | ||
| 649 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 650 | } catch (...) { | ||
| 651 | this->__set_badbit_and_consider_rethrow(); | ||
| 652 | } | ||
| 653 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 654 | return *this; | ||
| 655 | } | ||
| 656 | |||
| 657 | template <class _CharT, class _Traits> | ||
| 658 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) { | ||
| 659 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 660 | try { | ||
| 661 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 662 | sentry __sen(*this); | ||
| 663 | if (__sen && __n) { | ||
| 664 | if (this->rdbuf()->sputn(__s, __n) != __n) | ||
| 665 | this->setstate(ios_base::badbit); | ||
| 666 | } | ||
| 667 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 668 | } catch (...) { | ||
| 669 | this->__set_badbit_and_consider_rethrow(); | ||
| 670 | } | ||
| 671 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 672 | return *this; | ||
| 673 | } | ||
| 674 | |||
| 675 | template <class _CharT, class _Traits> | ||
| 676 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { | ||
| 677 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 678 | try { | ||
| 679 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 680 | if (this->rdbuf()) { | ||
| 681 | sentry __s(*this); | ||
| 682 | if (__s) { | ||
| 683 | if (this->rdbuf()->pubsync() == -1) | ||
| 684 | this->setstate(ios_base::badbit); | ||
| 685 | } | ||
| 686 | } | ||
| 687 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 688 | } catch (...) { | ||
| 689 | this->__set_badbit_and_consider_rethrow(); | ||
| 690 | } | ||
| 691 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 692 | return *this; | ||
| 693 | } | ||
| 694 | |||
| 695 | template <class _CharT, class _Traits> | ||
| 696 | typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() { | ||
| 697 | if (this->fail()) | ||
| 698 | return pos_type(-1); | ||
| 699 | return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); | ||
| 700 | } | ||
| 701 | |||
| 702 | template <class _CharT, class _Traits> | ||
| 703 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { | ||
| 704 | sentry __s(*this); | ||
| 705 | if (!this->fail()) { | ||
| 706 | if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) | ||
| 707 | this->setstate(ios_base::failbit); | ||
| 708 | } | ||
| 709 | return *this; | ||
| 710 | } | ||
| 711 | |||
| 712 | template <class _CharT, class _Traits> | ||
| 713 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { | ||
| 714 | sentry __s(*this); | ||
| 715 | if (!this->fail()) { | ||
| 716 | if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) | ||
| 717 | this->setstate(ios_base::failbit); | ||
| 718 | } | ||
| 719 | return *this; | ||
| 720 | } | ||
| 721 | |||
| 722 | template <class _CharT, class _Traits> | ||
| 723 | _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) { | ||
| 724 | __os.put(__os.widen('\n')); | ||
| 725 | __os.flush(); | ||
| 726 | return __os; | ||
| 727 | } | ||
| 728 | |||
| 729 | template <class _CharT, class _Traits> | ||
| 730 | _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) { | ||
| 731 | __os.put(_CharT()); | ||
| 732 | return __os; | ||
| 733 | } | ||
| 734 | |||
| 735 | template <class _CharT, class _Traits> | ||
| 736 | _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) { | ||
| 737 | __os.flush(); | ||
| 738 | return __os; | ||
| 739 | } | ||
| 740 | |||
| 741 | template <class _Stream, class _Tp, class = void> | ||
| 742 | struct __is_ostreamable : false_type {}; | ||
| 743 | |||
| 744 | template <class _Stream, class _Tp> | ||
| 745 | struct __is_ostreamable<_Stream, _Tp, decltype(std::declval<_Stream>() << std::declval<_Tp>(), void())> : true_type {}; | ||
| 746 | |||
| 747 | template <class _Stream, | ||
| 748 | class _Tp, | ||
| 749 | __enable_if_t<_And<is_base_of<ios_base, _Stream>, __is_ostreamable<_Stream&, const _Tp&> >::value, int> = 0> | ||
| 750 | _LIBCPP_HIDE_FROM_ABI _Stream&& operator<<(_Stream&& __os, const _Tp& __x) { | ||
| 751 | __os << __x; | ||
| 752 | return std::move(__os); | ||
| 753 | } | ||
| 754 | |||
| 755 | template <class _CharT, class _Traits, class _Allocator> | ||
| 756 | basic_ostream<_CharT, _Traits>& | ||
| 757 | operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str) { | ||
| 758 | return std::__put_character_sequence(__os, __str.data(), __str.size()); | ||
| 759 | } | ||
| 760 | |||
| 761 | template <class _CharT, class _Traits> | ||
| 762 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) { | ||
| 764 | return std::__put_character_sequence(__os, __sv.data(), __sv.size()); | ||
| 765 | } | ||
| 766 | |||
| 767 | template <class _CharT, class _Traits> | ||
| 768 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 769 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) { | ||
| 770 | return __os << __ec.category().name() << ':' << __ec.value(); | ||
| 771 | } | ||
| 772 | |||
| 773 | template <class _CharT, class _Traits, class _Yp> | ||
| 774 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 775 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) { | ||
| 776 | return __os << __p.get(); | ||
| 777 | } | ||
| 778 | |||
| 779 | template < | ||
| 780 | class _CharT, | ||
| 781 | class _Traits, | ||
| 782 | class _Yp, | ||
| 783 | class _Dp, | ||
| 784 | __enable_if_t<is_same<void, | ||
| 785 | __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() | ||
| 786 | << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value, | ||
| 787 | int> = 0> | ||
| 788 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 789 | operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) { | ||
| 790 | return __os << __p.get(); | ||
| 791 | } | ||
| 792 | |||
| 793 | template <class _CharT, class _Traits, size_t _Size> | ||
| 794 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 795 | operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) { | ||
| 796 | return __os << __x.template to_string<_CharT, _Traits>(std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'), | ||
| 797 | std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); | ||
| 798 | } | ||
| 799 | |||
| 800 | #if _LIBCPP_STD_VER >= 20 | ||
| 801 | |||
| 802 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 803 | template <class _Traits> | ||
| 804 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; | ||
| 805 | |||
| 806 | template <class _Traits> | ||
| 807 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete; | ||
| 808 | |||
| 809 | template <class _Traits> | ||
| 810 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete; | ||
| 811 | |||
| 812 | template <class _Traits> | ||
| 813 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete; | ||
| 814 | |||
| 815 | template <class _Traits> | ||
| 816 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete; | ||
| 817 | |||
| 818 | template <class _Traits> | ||
| 819 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; | ||
| 820 | |||
| 821 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 822 | |||
| 823 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | ||
| 824 | template <class _Traits> | ||
| 825 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; | ||
| 826 | |||
| 827 | template <class _Traits> | ||
| 828 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete; | ||
| 829 | |||
| 830 | template <class _Traits> | ||
| 831 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete; | ||
| 832 | |||
| 833 | template <class _Traits> | ||
| 834 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; | ||
| 835 | # endif | ||
| 836 | |||
| 837 | template <class _Traits> | ||
| 838 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; | ||
| 839 | |||
| 840 | template <class _Traits> | ||
| 841 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete; | ||
| 842 | |||
| 843 | template <class _Traits> | ||
| 844 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete; | ||
| 845 | |||
| 846 | template <class _Traits> | ||
| 847 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; | ||
| 848 | |||
| 849 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 850 | |||
| 851 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>; | ||
| 852 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 853 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>; | ||
| 854 | #endif | ||
| 855 | |||
| 856 | _LIBCPP_END_NAMESPACE_STD | ||
| 857 | |||
| 858 | _LIBCPP_POP_MACROS | ||
| 859 | |||
| 860 | #endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H | ||
lib/libcxx/include/__ostream/print.h created+179| ... | @@ -0,0 +1,179 @@ | ||
| 1 | //===---------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===---------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___OSTREAM_PRINT_H | ||
| 10 | #define _LIBCPP___OSTREAM_PRINT_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/ostream.h> | ||
| 14 | #include <__iterator/ostreambuf_iterator.h> | ||
| 15 | #include <__ostream/basic_ostream.h> | ||
| 16 | #include <format> | ||
| 17 | #include <ios> | ||
| 18 | #include <locale> | ||
| 19 | #include <print> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | #if _LIBCPP_STD_VER >= 23 | ||
| 28 | |||
| 29 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 30 | _LIBCPP_HIDE_FROM_ABI inline void | ||
| 31 | __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) { | ||
| 32 | // [ostream.formatted.print]/3 | ||
| 33 | // Effects: Behaves as a formatted output function | ||
| 34 | // ([ostream.formatted.reqmts]) of os, except that: | ||
| 35 | // - failure to generate output is reported as specified below, and | ||
| 36 | // - any exception thrown by the call to vformat is propagated without regard | ||
| 37 | // to the value of os.exceptions() and without turning on ios_base::badbit | ||
| 38 | // in the error state of os. | ||
| 39 | // After constructing a sentry object, the function initializes an automatic | ||
| 40 | // variable via | ||
| 41 | // string out = vformat(os.getloc(), fmt, args); | ||
| 42 | |||
| 43 | ostream::sentry __s(__os); | ||
| 44 | if (__s) { | ||
| 45 | string __o = std::vformat(__os.getloc(), __fmt, __args); | ||
| 46 | if (__write_nl) | ||
| 47 | __o += '\n'; | ||
| 48 | |||
| 49 | const char* __str = __o.data(); | ||
| 50 | size_t __len = __o.size(); | ||
| 51 | |||
| 52 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 53 | try { | ||
| 54 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 55 | typedef ostreambuf_iterator<char> _Ip; | ||
| 56 | if (std::__pad_and_output( | ||
| 57 | _Ip(__os), | ||
| 58 | __str, | ||
| 59 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str, | ||
| 60 | __str + __len, | ||
| 61 | __os, | ||
| 62 | __os.fill()) | ||
| 63 | .failed()) | ||
| 64 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 65 | |||
| 66 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 67 | } catch (...) { | ||
| 68 | __os.__set_badbit_and_consider_rethrow(); | ||
| 69 | } | ||
| 70 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 75 | _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args) { | ||
| 76 | std::__vprint_nonunicode(__os, __fmt, __args, false); | ||
| 77 | } | ||
| 78 | |||
| 79 | // Returns the FILE* associated with the __os. | ||
| 80 | // Returns a nullptr when no FILE* is associated with __os. | ||
| 81 | // This function is in the dylib since the type of the buffer associated | ||
| 82 | // with std::cout, std::cerr, and std::clog is only known in the dylib. | ||
| 83 | // | ||
| 84 | // This function implements part of the implementation-defined behavior | ||
| 85 | // of [ostream.formatted.print]/3 | ||
| 86 | // If the function is vprint_unicode and os is a stream that refers to | ||
| 87 | // a terminal capable of displaying Unicode which is determined in an | ||
| 88 | // implementation-defined manner, writes out to the terminal using the | ||
| 89 | // native Unicode API; | ||
| 90 | // Whether the returned FILE* is "a terminal capable of displaying Unicode" | ||
| 91 | // is determined in the same way as the print(FILE*, ...) overloads. | ||
| 92 | _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os); | ||
| 93 | |||
| 94 | # ifndef _LIBCPP_HAS_NO_UNICODE | ||
| 95 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 96 | _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) { | ||
| 97 | # if _LIBCPP_AVAILABILITY_HAS_PRINT == 0 | ||
| 98 | return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); | ||
| 99 | # else | ||
| 100 | FILE* __file = std::__get_ostream_file(__os); | ||
| 101 | if (!__file || !__print::__is_terminal(__file)) | ||
| 102 | return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); | ||
| 103 | |||
| 104 | // [ostream.formatted.print]/3 | ||
| 105 | // If the function is vprint_unicode and os is a stream that refers to a | ||
| 106 | // terminal capable of displaying Unicode which is determined in an | ||
| 107 | // implementation-defined manner, writes out to the terminal using the | ||
| 108 | // native Unicode API; if out contains invalid code units, the behavior is | ||
| 109 | // undefined and implementations are encouraged to diagnose it. If the | ||
| 110 | // native Unicode API is used, the function flushes os before writing out. | ||
| 111 | // | ||
| 112 | // This is the path for the native API, start with flushing. | ||
| 113 | __os.flush(); | ||
| 114 | |||
| 115 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 116 | try { | ||
| 117 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 118 | ostream::sentry __s(__os); | ||
| 119 | if (__s) { | ||
| 120 | # ifndef _LIBCPP_WIN32API | ||
| 121 | __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true); | ||
| 122 | # elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | ||
| 123 | __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true); | ||
| 124 | # else | ||
| 125 | # error "Windows builds with wchar_t disabled are not supported." | ||
| 126 | # endif | ||
| 127 | } | ||
| 128 | |||
| 129 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 130 | } catch (...) { | ||
| 131 | __os.__set_badbit_and_consider_rethrow(); | ||
| 132 | } | ||
| 133 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 134 | # endif // _LIBCPP_AVAILABILITY_HAS_PRINT | ||
| 135 | } | ||
| 136 | |||
| 137 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 138 | _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) { | ||
| 139 | std::__vprint_unicode(__os, __fmt, __args, false); | ||
| 140 | } | ||
| 141 | # endif // _LIBCPP_HAS_NO_UNICODE | ||
| 142 | |||
| 143 | template <class... _Args> | ||
| 144 | _LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { | ||
| 145 | # ifndef _LIBCPP_HAS_NO_UNICODE | ||
| 146 | if constexpr (__print::__use_unicode_execution_charset) | ||
| 147 | std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false); | ||
| 148 | else | ||
| 149 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); | ||
| 150 | # else // _LIBCPP_HAS_NO_UNICODE | ||
| 151 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); | ||
| 152 | # endif // _LIBCPP_HAS_NO_UNICODE | ||
| 153 | } | ||
| 154 | |||
| 155 | template <class... _Args> | ||
| 156 | _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { | ||
| 157 | # ifndef _LIBCPP_HAS_NO_UNICODE | ||
| 158 | // Note the wording in the Standard is inefficient. The output of | ||
| 159 | // std::format is a std::string which is then copied. This solution | ||
| 160 | // just appends a newline at the end of the output. | ||
| 161 | if constexpr (__print::__use_unicode_execution_charset) | ||
| 162 | std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true); | ||
| 163 | else | ||
| 164 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); | ||
| 165 | # else // _LIBCPP_HAS_NO_UNICODE | ||
| 166 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); | ||
| 167 | # endif // _LIBCPP_HAS_NO_UNICODE | ||
| 168 | } | ||
| 169 | |||
| 170 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 171 | _LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) { | ||
| 172 | std::print(__os, "\n"); | ||
| 173 | } | ||
| 174 | |||
| 175 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 176 | |||
| 177 | _LIBCPP_END_NAMESPACE_STD | ||
| 178 | |||
| 179 | #endif // _LIBCPP___OSTREAM_PRINT_H | ||
lib/libcxx/include/__pstl/backend.h created+35| ... | @@ -0,0 +1,35 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_BACKEND_H | ||
| 10 | #define _LIBCPP___PSTL_BACKEND_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__pstl/backend_fwd.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_PUSH_MACROS | ||
| 20 | #include <__undef_macros> | ||
| 21 | |||
| 22 | #if defined(_LIBCPP_PSTL_BACKEND_SERIAL) | ||
| 23 | # include <__pstl/backends/default.h> | ||
| 24 | # include <__pstl/backends/serial.h> | ||
| 25 | #elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) | ||
| 26 | # include <__pstl/backends/default.h> | ||
| 27 | # include <__pstl/backends/std_thread.h> | ||
| 28 | #elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) | ||
| 29 | # include <__pstl/backends/default.h> | ||
| 30 | # include <__pstl/backends/libdispatch.h> | ||
| 31 | #endif | ||
| 32 | |||
| 33 | _LIBCPP_POP_MACROS | ||
| 34 | |||
| 35 | #endif // _LIBCPP___PSTL_BACKEND_H | ||
lib/libcxx/include/__pstl/backend_fwd.h created+301| ... | @@ -0,0 +1,301 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_BACKEND_FWD_H | ||
| 10 | #define _LIBCPP___PSTL_BACKEND_FWD_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_PUSH_MACROS | ||
| 19 | #include <__undef_macros> | ||
| 20 | |||
| 21 | // | ||
| 22 | // This header declares available PSTL backends and the functions that must be implemented in order for the | ||
| 23 | // PSTL algorithms to be provided. | ||
| 24 | // | ||
| 25 | // Backends often do not implement the full set of functions themselves -- a configuration of the PSTL is | ||
| 26 | // usually a set of backends "stacked" together which each implement some algorithms under some execution | ||
| 27 | // policies. It is only necessary for the "stack" of backends to implement all algorithms under all execution | ||
| 28 | // policies, but a single backend is not required to implement everything on its own. | ||
| 29 | // | ||
| 30 | // The signatures used by each backend function are documented below. | ||
| 31 | // | ||
| 32 | // Exception handling | ||
| 33 | // ================== | ||
| 34 | // | ||
| 35 | // PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from | ||
| 36 | // their implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions | ||
| 37 | // are turned into a program termination at the front-end level. When a backend returns a disengaged `optional` to the | ||
| 38 | // frontend, the frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to | ||
| 39 | // the user. | ||
| 40 | // | ||
| 41 | |||
| 42 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 43 | namespace __pstl { | ||
| 44 | |||
| 45 | template <class... _Backends> | ||
| 46 | struct __backend_configuration; | ||
| 47 | |||
| 48 | struct __default_backend_tag; | ||
| 49 | struct __libdispatch_backend_tag; | ||
| 50 | struct __serial_backend_tag; | ||
| 51 | struct __std_thread_backend_tag; | ||
| 52 | |||
| 53 | #if defined(_LIBCPP_PSTL_BACKEND_SERIAL) | ||
| 54 | using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>; | ||
| 55 | #elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) | ||
| 56 | using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>; | ||
| 57 | #elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) | ||
| 58 | using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>; | ||
| 59 | #else | ||
| 60 | |||
| 61 | // ...New vendors can add parallel backends here... | ||
| 62 | |||
| 63 | # error "Invalid PSTL backend configuration" | ||
| 64 | #endif | ||
| 65 | |||
| 66 | template <class _Backend, class _ExecutionPolicy> | ||
| 67 | struct __find_if; | ||
| 68 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 69 | // optional<_ForwardIterator> | ||
| 70 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 71 | |||
| 72 | template <class _Backend, class _ExecutionPolicy> | ||
| 73 | struct __find_if_not; | ||
| 74 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 75 | // optional<_ForwardIterator> | ||
| 76 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 77 | |||
| 78 | template <class _Backend, class _ExecutionPolicy> | ||
| 79 | struct __find; | ||
| 80 | // template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 81 | // optional<_ForwardIterator> | ||
| 82 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept; | ||
| 83 | |||
| 84 | template <class _Backend, class _ExecutionPolicy> | ||
| 85 | struct __any_of; | ||
| 86 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 87 | // optional<bool> | ||
| 88 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 89 | |||
| 90 | template <class _Backend, class _ExecutionPolicy> | ||
| 91 | struct __all_of; | ||
| 92 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 93 | // optional<bool> | ||
| 94 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 95 | |||
| 96 | template <class _Backend, class _ExecutionPolicy> | ||
| 97 | struct __none_of; | ||
| 98 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 99 | // optional<bool> | ||
| 100 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 101 | |||
| 102 | template <class _Backend, class _ExecutionPolicy> | ||
| 103 | struct __is_partitioned; | ||
| 104 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 105 | // optional<bool> | ||
| 106 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 107 | |||
| 108 | template <class _Backend, class _ExecutionPolicy> | ||
| 109 | struct __for_each; | ||
| 110 | // template <class _Policy, class _ForwardIterator, class _Function> | ||
| 111 | // optional<__empty> | ||
| 112 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Function __func) const noexcept; | ||
| 113 | |||
| 114 | template <class _Backend, class _ExecutionPolicy> | ||
| 115 | struct __for_each_n; | ||
| 116 | // template <class _Policy, class _ForwardIterator, class _Size, class _Function> | ||
| 117 | // optional<__empty> | ||
| 118 | // operator()(_Policy&&, _ForwardIterator __first, _Size __size, _Function __func) const noexcept; | ||
| 119 | |||
| 120 | template <class _Backend, class _ExecutionPolicy> | ||
| 121 | struct __fill; | ||
| 122 | // template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 123 | // optional<__empty> | ||
| 124 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept; | ||
| 125 | |||
| 126 | template <class _Backend, class _ExecutionPolicy> | ||
| 127 | struct __fill_n; | ||
| 128 | // template <class _Policy, class _ForwardIterator, class _Size, class _Tp> | ||
| 129 | // optional<__empty> | ||
| 130 | // operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Tp const& __value) const noexcept; | ||
| 131 | |||
| 132 | template <class _Backend, class _ExecutionPolicy> | ||
| 133 | struct __replace; | ||
| 134 | // template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 135 | // optional<__empty> | ||
| 136 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 137 | // _Tp const& __old, _Tp const& __new) const noexcept; | ||
| 138 | |||
| 139 | template <class _Backend, class _ExecutionPolicy> | ||
| 140 | struct __replace_if; | ||
| 141 | // template <class _Policy, class _ForwardIterator, class _Predicate, class _Tp> | ||
| 142 | // optional<__empty> | ||
| 143 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 144 | // _Predicate __pred, _Tp const& __new_value) const noexcept; | ||
| 145 | |||
| 146 | template <class _Backend, class _ExecutionPolicy> | ||
| 147 | struct __generate; | ||
| 148 | // template <class _Policy, class _ForwardIterator, class _Generator> | ||
| 149 | // optional<__empty> | ||
| 150 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) const noexcept; | ||
| 151 | |||
| 152 | template <class _Backend, class _ExecutionPolicy> | ||
| 153 | struct __generate_n; | ||
| 154 | // template <class _Policy, class _ForwardIterator, class _Size, class _Generator> | ||
| 155 | // optional<__empty> | ||
| 156 | // operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Generator __gen) const noexcept; | ||
| 157 | |||
| 158 | template <class _Backend, class _ExecutionPolicy> | ||
| 159 | struct __merge; | ||
| 160 | // template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp> | ||
| 161 | // optional<_ForwardOutIterator> | ||
| 162 | // operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
| 163 | // _ForwardIterator2 __first2, _ForwardIterator2 __last2, | ||
| 164 | // _ForwardOutIterator __result, _Comp __comp) const noexcept; | ||
| 165 | |||
| 166 | template <class _Backend, class _ExecutionPolicy> | ||
| 167 | struct __stable_sort; | ||
| 168 | // template <class _Policy, class _RandomAccessIterator, class _Comp> | ||
| 169 | // optional<__empty> | ||
| 170 | // operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept; | ||
| 171 | |||
| 172 | template <class _Backend, class _ExecutionPolicy> | ||
| 173 | struct __sort; | ||
| 174 | // template <class _Policy, class _RandomAccessIterator, class _Comp> | ||
| 175 | // optional<__empty> | ||
| 176 | // operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept; | ||
| 177 | |||
| 178 | template <class _Backend, class _ExecutionPolicy> | ||
| 179 | struct __transform; | ||
| 180 | // template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation> | ||
| 181 | // optional<_ForwardOutIterator> | ||
| 182 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 183 | // _ForwardOutIterator __result, | ||
| 184 | // _UnaryOperation __op) const noexcept; | ||
| 185 | |||
| 186 | template <class _Backend, class _ExecutionPolicy> | ||
| 187 | struct __transform_binary; | ||
| 188 | // template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, | ||
| 189 | // class _ForwardOutIterator, | ||
| 190 | // class _BinaryOperation> | ||
| 191 | // optional<_ForwardOutIterator> | ||
| 192 | // operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
| 193 | // _ForwardIterator2 __first2, | ||
| 194 | // _ForwardOutIterator __result, | ||
| 195 | // _BinaryOperation __op) const noexcept; | ||
| 196 | |||
| 197 | template <class _Backend, class _ExecutionPolicy> | ||
| 198 | struct __replace_copy_if; | ||
| 199 | // template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Predicate, class _Tp> | ||
| 200 | // optional<__empty> | ||
| 201 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 202 | // _ForwardOutIterator __out_it, | ||
| 203 | // _Predicate __pred, | ||
| 204 | // _Tp const& __new_value) const noexcept; | ||
| 205 | |||
| 206 | template <class _Backend, class _ExecutionPolicy> | ||
| 207 | struct __replace_copy; | ||
| 208 | // template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Tp> | ||
| 209 | // optional<__empty> | ||
| 210 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 211 | // _ForwardOutIterator __out_it, | ||
| 212 | // _Tp const& __old_value, | ||
| 213 | // _Tp const& __new_value) const noexcept; | ||
| 214 | |||
| 215 | template <class _Backend, class _ExecutionPolicy> | ||
| 216 | struct __move; | ||
| 217 | // template <class _Policy, class _ForwardIterator, class _ForwardOutIterator> | ||
| 218 | // optional<_ForwardOutIterator> | ||
| 219 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 220 | // _ForwardOutIterator __out_it) const noexcept; | ||
| 221 | |||
| 222 | template <class _Backend, class _ExecutionPolicy> | ||
| 223 | struct __copy; | ||
| 224 | // template <class _Policy, class _ForwardIterator, class _ForwardOutIterator> | ||
| 225 | // optional<_ForwardOutIterator> | ||
| 226 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 227 | // _ForwardOutIterator __out_it) const noexcept; | ||
| 228 | |||
| 229 | template <class _Backend, class _ExecutionPolicy> | ||
| 230 | struct __copy_n; | ||
| 231 | // template <class _Policy, class _ForwardIterator, class _Size, class _ForwardOutIterator> | ||
| 232 | // optional<_ForwardOutIterator> | ||
| 233 | // operator()(_Policy&&, _ForwardIterator __first, _Size __n, _ForwardOutIterator __out_it) const noexcept; | ||
| 234 | |||
| 235 | template <class _Backend, class _ExecutionPolicy> | ||
| 236 | struct __rotate_copy; | ||
| 237 | // template <class _Policy, class _ForwardIterator, class _ForwardOutIterator> | ||
| 238 | // optional<_ForwardOutIterator> | ||
| 239 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, | ||
| 240 | // _ForwardOutIterator __out_it) const noexcept; | ||
| 241 | |||
| 242 | template <class _Backend, class _ExecutionPolicy> | ||
| 243 | struct __transform_reduce; | ||
| 244 | // template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> | ||
| 245 | // optional<_Tp> | ||
| 246 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 247 | // _Tp __init, | ||
| 248 | // _BinaryOperation __reduce, | ||
| 249 | // _UnaryOperation __transform) const noexcept; | ||
| 250 | |||
| 251 | template <class _Backend, class _ExecutionPolicy> | ||
| 252 | struct __transform_reduce_binary; | ||
| 253 | // template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, | ||
| 254 | // class _Tp, class _BinaryOperation1, class _BinaryOperation2> | ||
| 255 | // optional<_Tp> operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
| 256 | // _ForwardIterator2 __first2, | ||
| 257 | // _Tp __init, | ||
| 258 | // _BinaryOperation1 __reduce, | ||
| 259 | // _BinaryOperation2 __transform) const noexcept; | ||
| 260 | |||
| 261 | template <class _Backend, class _ExecutionPolicy> | ||
| 262 | struct __count_if; | ||
| 263 | // template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 264 | // optional<__iter_diff_t<_ForwardIterator>> | ||
| 265 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept; | ||
| 266 | |||
| 267 | template <class _Backend, class _ExecutionPolicy> | ||
| 268 | struct __count; | ||
| 269 | // template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 270 | // optional<__iter_diff_t<_ForwardIterator>> | ||
| 271 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept; | ||
| 272 | |||
| 273 | template <class _Backend, class _ExecutionPolicy> | ||
| 274 | struct __equal_3leg; | ||
| 275 | // template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate> | ||
| 276 | // optional<bool> | ||
| 277 | // operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
| 278 | // _ForwardIterator2 __first2, | ||
| 279 | // _Predicate __pred) const noexcept; | ||
| 280 | |||
| 281 | template <class _Backend, class _ExecutionPolicy> | ||
| 282 | struct __equal; | ||
| 283 | // template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate> | ||
| 284 | // optional<bool> | ||
| 285 | // operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
| 286 | // _ForwardIterator2 __first2, _ForwardIterator2 __last2, | ||
| 287 | // _Predicate __pred) const noexcept; | ||
| 288 | |||
| 289 | template <class _Backend, class _ExecutionPolicy> | ||
| 290 | struct __reduce; | ||
| 291 | // template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation> | ||
| 292 | // optional<_Tp> | ||
| 293 | // operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, | ||
| 294 | // _Tp __init, _BinaryOperation __op) const noexcept; | ||
| 295 | |||
| 296 | } // namespace __pstl | ||
| 297 | _LIBCPP_END_NAMESPACE_STD | ||
| 298 | |||
| 299 | _LIBCPP_POP_MACROS | ||
| 300 | |||
| 301 | #endif // _LIBCPP___PSTL_BACKEND_FWD_H | ||
lib/libcxx/include/__pstl/backends/default.h created+503| ... | @@ -0,0 +1,503 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_BACKENDS_DEFAULT_H | ||
| 10 | #define _LIBCPP___PSTL_BACKENDS_DEFAULT_H | ||
| 11 | |||
| 12 | #include <__algorithm/copy_n.h> | ||
| 13 | #include <__algorithm/equal.h> | ||
| 14 | #include <__algorithm/fill_n.h> | ||
| 15 | #include <__algorithm/for_each_n.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__functional/identity.h> | ||
| 18 | #include <__functional/not_fn.h> | ||
| 19 | #include <__functional/operations.h> | ||
| 20 | #include <__iterator/concepts.h> | ||
| 21 | #include <__iterator/iterator_traits.h> | ||
| 22 | #include <__pstl/backend_fwd.h> | ||
| 23 | #include <__pstl/dispatch.h> | ||
| 24 | #include <__utility/empty.h> | ||
| 25 | #include <__utility/forward.h> | ||
| 26 | #include <__utility/move.h> | ||
| 27 | #include <optional> | ||
| 28 | |||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 30 | # pragma GCC system_header | ||
| 31 | #endif | ||
| 32 | |||
| 33 | _LIBCPP_PUSH_MACROS | ||
| 34 | #include <__undef_macros> | ||
| 35 | |||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 37 | namespace __pstl { | ||
| 38 | |||
| 39 | // | ||
| 40 | // This file provides an incomplete PSTL backend that implements all of the PSTL algorithms | ||
| 41 | // based on a smaller set of basis operations. | ||
| 42 | // | ||
| 43 | // It is intended as a building block for other PSTL backends that implement some operations more | ||
| 44 | // efficiently but may not want to define the full set of PSTL algorithms. | ||
| 45 | // | ||
| 46 | // This backend implements all the PSTL algorithms based on the following basis operations: | ||
| 47 | // | ||
| 48 | // find_if family | ||
| 49 | // -------------- | ||
| 50 | // - find | ||
| 51 | // - find_if_not | ||
| 52 | // - any_of | ||
| 53 | // - all_of | ||
| 54 | // - none_of | ||
| 55 | // - is_partitioned | ||
| 56 | // | ||
| 57 | // for_each family | ||
| 58 | // --------------- | ||
| 59 | // - for_each_n | ||
| 60 | // - fill | ||
| 61 | // - fill_n | ||
| 62 | // - replace | ||
| 63 | // - replace_if | ||
| 64 | // - generate | ||
| 65 | // - generate_n | ||
| 66 | // | ||
| 67 | // merge family | ||
| 68 | // ------------ | ||
| 69 | // No other algorithms based on merge | ||
| 70 | // | ||
| 71 | // stable_sort family | ||
| 72 | // ------------------ | ||
| 73 | // - sort | ||
| 74 | // | ||
| 75 | // transform_reduce and transform_reduce_binary family | ||
| 76 | // --------------------------------------------------- | ||
| 77 | // - count_if | ||
| 78 | // - count | ||
| 79 | // - equal(3 legs) | ||
| 80 | // - equal | ||
| 81 | // - reduce | ||
| 82 | // | ||
| 83 | // transform and transform_binary family | ||
| 84 | // ------------------------------------- | ||
| 85 | // - replace_copy_if | ||
| 86 | // - replace_copy | ||
| 87 | // - move | ||
| 88 | // - copy | ||
| 89 | // - copy_n | ||
| 90 | // - rotate_copy | ||
| 91 | // | ||
| 92 | |||
| 93 | ////////////////////////////////////////////////////////////// | ||
| 94 | // find_if family | ||
| 95 | ////////////////////////////////////////////////////////////// | ||
| 96 | template <class _ExecutionPolicy> | ||
| 97 | struct __find<__default_backend_tag, _ExecutionPolicy> { | ||
| 98 | template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 99 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator> | ||
| 100 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept { | ||
| 101 | using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>; | ||
| 102 | return _FindIf()( | ||
| 103 | __policy, std::move(__first), std::move(__last), [&](__iter_reference<_ForwardIterator> __element) { | ||
| 104 | return __element == __value; | ||
| 105 | }); | ||
| 106 | } | ||
| 107 | }; | ||
| 108 | |||
| 109 | template <class _ExecutionPolicy> | ||
| 110 | struct __find_if_not<__default_backend_tag, _ExecutionPolicy> { | ||
| 111 | template <class _Policy, class _ForwardIterator, class _Pred> | ||
| 112 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator> | ||
| 113 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | ||
| 114 | using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>; | ||
| 115 | return _FindIf()(__policy, __first, __last, std::not_fn(std::forward<_Pred>(__pred))); | ||
| 116 | } | ||
| 117 | }; | ||
| 118 | |||
| 119 | template <class _ExecutionPolicy> | ||
| 120 | struct __any_of<__default_backend_tag, _ExecutionPolicy> { | ||
| 121 | template <class _Policy, class _ForwardIterator, class _Pred> | ||
| 122 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 123 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | ||
| 124 | using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>; | ||
| 125 | auto __res = _FindIf()(__policy, __first, __last, std::forward<_Pred>(__pred)); | ||
| 126 | if (!__res) | ||
| 127 | return nullopt; | ||
| 128 | return *__res != __last; | ||
| 129 | } | ||
| 130 | }; | ||
| 131 | |||
| 132 | template <class _ExecutionPolicy> | ||
| 133 | struct __all_of<__default_backend_tag, _ExecutionPolicy> { | ||
| 134 | template <class _Policy, class _ForwardIterator, class _Pred> | ||
| 135 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 136 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | ||
| 137 | using _AnyOf = __dispatch<__any_of, __current_configuration, _ExecutionPolicy>; | ||
| 138 | auto __res = _AnyOf()(__policy, __first, __last, [&](__iter_reference<_ForwardIterator> __value) { | ||
| 139 | return !__pred(__value); | ||
| 140 | }); | ||
| 141 | if (!__res) | ||
| 142 | return nullopt; | ||
| 143 | return !*__res; | ||
| 144 | } | ||
| 145 | }; | ||
| 146 | |||
| 147 | template <class _ExecutionPolicy> | ||
| 148 | struct __none_of<__default_backend_tag, _ExecutionPolicy> { | ||
| 149 | template <class _Policy, class _ForwardIterator, class _Pred> | ||
| 150 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 151 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | ||
| 152 | using _AnyOf = __dispatch<__any_of, __current_configuration, _ExecutionPolicy>; | ||
| 153 | auto __res = _AnyOf()(__policy, __first, __last, std::forward<_Pred>(__pred)); | ||
| 154 | if (!__res) | ||
| 155 | return nullopt; | ||
| 156 | return !*__res; | ||
| 157 | } | ||
| 158 | }; | ||
| 159 | |||
| 160 | template <class _ExecutionPolicy> | ||
| 161 | struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> { | ||
| 162 | template <class _Policy, class _ForwardIterator, class _Pred> | ||
| 163 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 164 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | ||
| 165 | using _FindIfNot = __dispatch<__find_if_not, __current_configuration, _ExecutionPolicy>; | ||
| 166 | auto __maybe_first = _FindIfNot()(__policy, std::move(__first), std::move(__last), __pred); | ||
| 167 | if (__maybe_first == nullopt) | ||
| 168 | return nullopt; | ||
| 169 | |||
| 170 | __first = *__maybe_first; | ||
| 171 | if (__first == __last) | ||
| 172 | return true; | ||
| 173 | ++__first; | ||
| 174 | using _NoneOf = __dispatch<__none_of, __current_configuration, _ExecutionPolicy>; | ||
| 175 | return _NoneOf()(__policy, std::move(__first), std::move(__last), __pred); | ||
| 176 | } | ||
| 177 | }; | ||
| 178 | |||
| 179 | ////////////////////////////////////////////////////////////// | ||
| 180 | // for_each family | ||
| 181 | ////////////////////////////////////////////////////////////// | ||
| 182 | template <class _ExecutionPolicy> | ||
| 183 | struct __for_each_n<__default_backend_tag, _ExecutionPolicy> { | ||
| 184 | template <class _Policy, class _ForwardIterator, class _Size, class _Function> | ||
| 185 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 186 | operator()(_Policy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) const noexcept { | ||
| 187 | if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 188 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | ||
| 189 | _ForwardIterator __last = __first + __size; | ||
| 190 | return _ForEach()(__policy, std::move(__first), std::move(__last), std::move(__func)); | ||
| 191 | } else { | ||
| 192 | // Otherwise, use the serial algorithm to avoid doing two passes over the input | ||
| 193 | std::for_each_n(std::move(__first), __size, std::move(__func)); | ||
| 194 | return __empty{}; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | }; | ||
| 198 | |||
| 199 | template <class _ExecutionPolicy> | ||
| 200 | struct __fill<__default_backend_tag, _ExecutionPolicy> { | ||
| 201 | template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 202 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 203 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept { | ||
| 204 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | ||
| 205 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 206 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __value; }); | ||
| 207 | } | ||
| 208 | }; | ||
| 209 | |||
| 210 | template <class _ExecutionPolicy> | ||
| 211 | struct __fill_n<__default_backend_tag, _ExecutionPolicy> { | ||
| 212 | template <class _Policy, class _ForwardIterator, class _Size, class _Tp> | ||
| 213 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 214 | operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _Tp const& __value) const noexcept { | ||
| 215 | if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 216 | using _Fill = __dispatch<__fill, __current_configuration, _ExecutionPolicy>; | ||
| 217 | _ForwardIterator __last = __first + __n; | ||
| 218 | return _Fill()(__policy, std::move(__first), std::move(__last), __value); | ||
| 219 | } else { | ||
| 220 | // Otherwise, use the serial algorithm to avoid doing two passes over the input | ||
| 221 | std::fill_n(std::move(__first), __n, __value); | ||
| 222 | return optional<__empty>{__empty{}}; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | }; | ||
| 226 | |||
| 227 | template <class _ExecutionPolicy> | ||
| 228 | struct __replace<__default_backend_tag, _ExecutionPolicy> { | ||
| 229 | template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 230 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 231 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __old, _Tp const& __new) | ||
| 232 | const noexcept { | ||
| 233 | using _ReplaceIf = __dispatch<__replace_if, __current_configuration, _ExecutionPolicy>; | ||
| 234 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 235 | return _ReplaceIf()( | ||
| 236 | __policy, std::move(__first), std::move(__last), [&](_Ref __element) { return __element == __old; }, __new); | ||
| 237 | } | ||
| 238 | }; | ||
| 239 | |||
| 240 | template <class _ExecutionPolicy> | ||
| 241 | struct __replace_if<__default_backend_tag, _ExecutionPolicy> { | ||
| 242 | template <class _Policy, class _ForwardIterator, class _Pred, class _Tp> | ||
| 243 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> operator()( | ||
| 244 | _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred, _Tp const& __new_value) | ||
| 245 | const noexcept { | ||
| 246 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | ||
| 247 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 248 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { | ||
| 249 | if (__pred(__element)) | ||
| 250 | __element = __new_value; | ||
| 251 | }); | ||
| 252 | } | ||
| 253 | }; | ||
| 254 | |||
| 255 | template <class _ExecutionPolicy> | ||
| 256 | struct __generate<__default_backend_tag, _ExecutionPolicy> { | ||
| 257 | template <class _Policy, class _ForwardIterator, class _Generator> | ||
| 258 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 259 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator&& __gen) const noexcept { | ||
| 260 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | ||
| 261 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 262 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __gen(); }); | ||
| 263 | } | ||
| 264 | }; | ||
| 265 | |||
| 266 | template <class _ExecutionPolicy> | ||
| 267 | struct __generate_n<__default_backend_tag, _ExecutionPolicy> { | ||
| 268 | template <class _Policy, class _ForwardIterator, class _Size, class _Generator> | ||
| 269 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 270 | operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _Generator&& __gen) const noexcept { | ||
| 271 | using _ForEachN = __dispatch<__for_each_n, __current_configuration, _ExecutionPolicy>; | ||
| 272 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 273 | return _ForEachN()(__policy, std::move(__first), __n, [&](_Ref __element) { __element = __gen(); }); | ||
| 274 | } | ||
| 275 | }; | ||
| 276 | |||
| 277 | ////////////////////////////////////////////////////////////// | ||
| 278 | // stable_sort family | ||
| 279 | ////////////////////////////////////////////////////////////// | ||
| 280 | template <class _ExecutionPolicy> | ||
| 281 | struct __sort<__default_backend_tag, _ExecutionPolicy> { | ||
| 282 | template <class _Policy, class _RandomAccessIterator, class _Comp> | ||
| 283 | _LIBCPP_HIDE_FROM_ABI optional<__empty> operator()( | ||
| 284 | _Policy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp&& __comp) const noexcept { | ||
| 285 | using _StableSort = __dispatch<__stable_sort, __current_configuration, _ExecutionPolicy>; | ||
| 286 | return _StableSort()(__policy, std::move(__first), std::move(__last), std::forward<_Comp>(__comp)); | ||
| 287 | } | ||
| 288 | }; | ||
| 289 | |||
| 290 | ////////////////////////////////////////////////////////////// | ||
| 291 | // transform_reduce family | ||
| 292 | ////////////////////////////////////////////////////////////// | ||
| 293 | template <class _ExecutionPolicy> | ||
| 294 | struct __count_if<__default_backend_tag, _ExecutionPolicy> { | ||
| 295 | template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 296 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> operator()( | ||
| 297 | _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred) const noexcept { | ||
| 298 | using _TransformReduce = __dispatch<__transform_reduce, __current_configuration, _ExecutionPolicy>; | ||
| 299 | using _DiffT = __iter_diff_t<_ForwardIterator>; | ||
| 300 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 301 | return _TransformReduce()( | ||
| 302 | __policy, std::move(__first), std::move(__last), _DiffT{}, std::plus{}, [&](_Ref __element) -> _DiffT { | ||
| 303 | return __pred(__element) ? _DiffT(1) : _DiffT(0); | ||
| 304 | }); | ||
| 305 | } | ||
| 306 | }; | ||
| 307 | |||
| 308 | template <class _ExecutionPolicy> | ||
| 309 | struct __count<__default_backend_tag, _ExecutionPolicy> { | ||
| 310 | template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 311 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> | ||
| 312 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept { | ||
| 313 | using _CountIf = __dispatch<__count_if, __current_configuration, _ExecutionPolicy>; | ||
| 314 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 315 | return _CountIf()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) -> bool { | ||
| 316 | return __element == __value; | ||
| 317 | }); | ||
| 318 | } | ||
| 319 | }; | ||
| 320 | |||
| 321 | template <class _ExecutionPolicy> | ||
| 322 | struct __equal_3leg<__default_backend_tag, _ExecutionPolicy> { | ||
| 323 | template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate> | ||
| 324 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 325 | operator()(_Policy&& __policy, | ||
| 326 | _ForwardIterator1 __first1, | ||
| 327 | _ForwardIterator1 __last1, | ||
| 328 | _ForwardIterator2 __first2, | ||
| 329 | _Predicate&& __pred) const noexcept { | ||
| 330 | using _TransformReduce = __dispatch<__transform_reduce_binary, __current_configuration, _ExecutionPolicy>; | ||
| 331 | return _TransformReduce()( | ||
| 332 | __policy, | ||
| 333 | std::move(__first1), | ||
| 334 | std::move(__last1), | ||
| 335 | std::move(__first2), | ||
| 336 | true, | ||
| 337 | std::logical_and{}, | ||
| 338 | std::forward<_Predicate>(__pred)); | ||
| 339 | } | ||
| 340 | }; | ||
| 341 | |||
| 342 | template <class _ExecutionPolicy> | ||
| 343 | struct __equal<__default_backend_tag, _ExecutionPolicy> { | ||
| 344 | template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate> | ||
| 345 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 346 | operator()(_Policy&& __policy, | ||
| 347 | _ForwardIterator1 __first1, | ||
| 348 | _ForwardIterator1 __last1, | ||
| 349 | _ForwardIterator2 __first2, | ||
| 350 | _ForwardIterator2 __last2, | ||
| 351 | _Predicate&& __pred) const noexcept { | ||
| 352 | if constexpr (__has_random_access_iterator_category<_ForwardIterator1>::value && | ||
| 353 | __has_random_access_iterator_category<_ForwardIterator2>::value) { | ||
| 354 | if (__last1 - __first1 != __last2 - __first2) | ||
| 355 | return false; | ||
| 356 | // Fall back to the 3 legged algorithm | ||
| 357 | using _Equal3Leg = __dispatch<__equal_3leg, __current_configuration, _ExecutionPolicy>; | ||
| 358 | return _Equal3Leg()( | ||
| 359 | __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::forward<_Predicate>(__pred)); | ||
| 360 | } else { | ||
| 361 | // If we don't have random access, fall back to the serial algorithm cause we can't do much | ||
| 362 | return std::equal( | ||
| 363 | std::move(__first1), | ||
| 364 | std::move(__last1), | ||
| 365 | std::move(__first2), | ||
| 366 | std::move(__last2), | ||
| 367 | std::forward<_Predicate>(__pred)); | ||
| 368 | } | ||
| 369 | } | ||
| 370 | }; | ||
| 371 | |||
| 372 | template <class _ExecutionPolicy> | ||
| 373 | struct __reduce<__default_backend_tag, _ExecutionPolicy> { | ||
| 374 | template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation> | ||
| 375 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_Tp> | ||
| 376 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init, _BinaryOperation&& __op) | ||
| 377 | const noexcept { | ||
| 378 | using _TransformReduce = __dispatch<__transform_reduce, __current_configuration, _ExecutionPolicy>; | ||
| 379 | return _TransformReduce()( | ||
| 380 | __policy, | ||
| 381 | std::move(__first), | ||
| 382 | std::move(__last), | ||
| 383 | std::move(__init), | ||
| 384 | std::forward<_BinaryOperation>(__op), | ||
| 385 | __identity{}); | ||
| 386 | } | ||
| 387 | }; | ||
| 388 | |||
| 389 | ////////////////////////////////////////////////////////////// | ||
| 390 | // transform family | ||
| 391 | ////////////////////////////////////////////////////////////// | ||
| 392 | template <class _ExecutionPolicy> | ||
| 393 | struct __replace_copy_if<__default_backend_tag, _ExecutionPolicy> { | ||
| 394 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Pred, class _Tp> | ||
| 395 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 396 | operator()(_Policy&& __policy, | ||
| 397 | _ForwardIterator __first, | ||
| 398 | _ForwardIterator __last, | ||
| 399 | _ForwardOutIterator __out_it, | ||
| 400 | _Pred&& __pred, | ||
| 401 | _Tp const& __new_value) const noexcept { | ||
| 402 | using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>; | ||
| 403 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 404 | auto __res = | ||
| 405 | _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), [&](_Ref __element) { | ||
| 406 | return __pred(__element) ? __new_value : __element; | ||
| 407 | }); | ||
| 408 | if (__res == nullopt) | ||
| 409 | return nullopt; | ||
| 410 | return __empty{}; | ||
| 411 | } | ||
| 412 | }; | ||
| 413 | |||
| 414 | template <class _ExecutionPolicy> | ||
| 415 | struct __replace_copy<__default_backend_tag, _ExecutionPolicy> { | ||
| 416 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Tp> | ||
| 417 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 418 | operator()(_Policy&& __policy, | ||
| 419 | _ForwardIterator __first, | ||
| 420 | _ForwardIterator __last, | ||
| 421 | _ForwardOutIterator __out_it, | ||
| 422 | _Tp const& __old_value, | ||
| 423 | _Tp const& __new_value) const noexcept { | ||
| 424 | using _ReplaceCopyIf = __dispatch<__replace_copy_if, __current_configuration, _ExecutionPolicy>; | ||
| 425 | using _Ref = __iter_reference<_ForwardIterator>; | ||
| 426 | return _ReplaceCopyIf()( | ||
| 427 | __policy, | ||
| 428 | std::move(__first), | ||
| 429 | std::move(__last), | ||
| 430 | std::move(__out_it), | ||
| 431 | [&](_Ref __element) { return __element == __old_value; }, | ||
| 432 | __new_value); | ||
| 433 | } | ||
| 434 | }; | ||
| 435 | |||
| 436 | // TODO: Use the std::copy/move shenanigans to forward to std::memmove | ||
| 437 | // Investigate whether we want to still forward to std::transform(policy) | ||
| 438 | // in that case for the execution::par part, or whether we actually want | ||
| 439 | // to run everything serially in that case. | ||
| 440 | template <class _ExecutionPolicy> | ||
| 441 | struct __move<__default_backend_tag, _ExecutionPolicy> { | ||
| 442 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator> | ||
| 443 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 444 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __out_it) | ||
| 445 | const noexcept { | ||
| 446 | using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>; | ||
| 447 | return _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), [&](auto&& __element) { | ||
| 448 | return std::move(__element); | ||
| 449 | }); | ||
| 450 | } | ||
| 451 | }; | ||
| 452 | |||
| 453 | // TODO: Use the std::copy/move shenanigans to forward to std::memmove | ||
| 454 | template <class _ExecutionPolicy> | ||
| 455 | struct __copy<__default_backend_tag, _ExecutionPolicy> { | ||
| 456 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator> | ||
| 457 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 458 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __out_it) | ||
| 459 | const noexcept { | ||
| 460 | using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>; | ||
| 461 | return _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), __identity()); | ||
| 462 | } | ||
| 463 | }; | ||
| 464 | |||
| 465 | template <class _ExecutionPolicy> | ||
| 466 | struct __copy_n<__default_backend_tag, _ExecutionPolicy> { | ||
| 467 | template <class _Policy, class _ForwardIterator, class _Size, class _ForwardOutIterator> | ||
| 468 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 469 | operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __out_it) const noexcept { | ||
| 470 | if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 471 | using _Copy = __dispatch<__copy, __current_configuration, _ExecutionPolicy>; | ||
| 472 | _ForwardIterator __last = __first + __n; | ||
| 473 | return _Copy()(__policy, std::move(__first), std::move(__last), std::move(__out_it)); | ||
| 474 | } else { | ||
| 475 | // Otherwise, use the serial algorithm to avoid doing two passes over the input | ||
| 476 | return std::copy_n(std::move(__first), __n, std::move(__out_it)); | ||
| 477 | } | ||
| 478 | } | ||
| 479 | }; | ||
| 480 | |||
| 481 | template <class _ExecutionPolicy> | ||
| 482 | struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> { | ||
| 483 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator> | ||
| 484 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 485 | operator()(_Policy&& __policy, | ||
| 486 | _ForwardIterator __first, | ||
| 487 | _ForwardIterator __middle, | ||
| 488 | _ForwardIterator __last, | ||
| 489 | _ForwardOutIterator __out_it) const noexcept { | ||
| 490 | using _Copy = __dispatch<__copy, __current_configuration, _ExecutionPolicy>; | ||
| 491 | auto __result_mid = _Copy()(__policy, __middle, std::move(__last), std::move(__out_it)); | ||
| 492 | if (__result_mid == nullopt) | ||
| 493 | return nullopt; | ||
| 494 | return _Copy()(__policy, std::move(__first), std::move(__middle), *std::move(__result_mid)); | ||
| 495 | } | ||
| 496 | }; | ||
| 497 | |||
| 498 | } // namespace __pstl | ||
| 499 | _LIBCPP_END_NAMESPACE_STD | ||
| 500 | |||
| 501 | _LIBCPP_POP_MACROS | ||
| 502 | |||
| 503 | #endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H | ||
lib/libcxx/include/__pstl/backends/libdispatch.h created+397| ... | @@ -0,0 +1,397 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H | ||
| 10 | #define _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H | ||
| 11 | |||
| 12 | #include <__algorithm/inplace_merge.h> | ||
| 13 | #include <__algorithm/lower_bound.h> | ||
| 14 | #include <__algorithm/max.h> | ||
| 15 | #include <__algorithm/merge.h> | ||
| 16 | #include <__algorithm/upper_bound.h> | ||
| 17 | #include <__atomic/atomic.h> | ||
| 18 | #include <__config> | ||
| 19 | #include <__exception/terminate.h> | ||
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__iterator/move_iterator.h> | ||
| 22 | #include <__memory/allocator.h> | ||
| 23 | #include <__memory/construct_at.h> | ||
| 24 | #include <__memory/unique_ptr.h> | ||
| 25 | #include <__numeric/reduce.h> | ||
| 26 | #include <__pstl/backend_fwd.h> | ||
| 27 | #include <__pstl/cpu_algos/any_of.h> | ||
| 28 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 29 | #include <__pstl/cpu_algos/fill.h> | ||
| 30 | #include <__pstl/cpu_algos/find_if.h> | ||
| 31 | #include <__pstl/cpu_algos/for_each.h> | ||
| 32 | #include <__pstl/cpu_algos/merge.h> | ||
| 33 | #include <__pstl/cpu_algos/stable_sort.h> | ||
| 34 | #include <__pstl/cpu_algos/transform.h> | ||
| 35 | #include <__pstl/cpu_algos/transform_reduce.h> | ||
| 36 | #include <__utility/empty.h> | ||
| 37 | #include <__utility/exception_guard.h> | ||
| 38 | #include <__utility/move.h> | ||
| 39 | #include <__utility/pair.h> | ||
| 40 | #include <cstddef> | ||
| 41 | #include <new> | ||
| 42 | #include <optional> | ||
| 43 | |||
| 44 | _LIBCPP_PUSH_MACROS | ||
| 45 | #include <__undef_macros> | ||
| 46 | |||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 48 | namespace __pstl { | ||
| 49 | |||
| 50 | namespace __libdispatch { | ||
| 51 | // ::dispatch_apply is marked as __attribute__((nothrow)) because it doesn't let exceptions propagate, and neither do | ||
| 52 | // we. | ||
| 53 | // TODO: Do we want to add [[_Clang::__callback__(__func, __context, __)]]? | ||
| 54 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 55 | __dispatch_apply(size_t __chunk_count, void* __context, void (*__func)(void* __context, size_t __chunk)) noexcept; | ||
| 56 | |||
| 57 | template <class _Func> | ||
| 58 | _LIBCPP_HIDE_FROM_ABI void __dispatch_apply(size_t __chunk_count, _Func __func) noexcept { | ||
| 59 | __libdispatch::__dispatch_apply(__chunk_count, &__func, [](void* __context, size_t __chunk) { | ||
| 60 | (*static_cast<_Func*>(__context))(__chunk); | ||
| 61 | }); | ||
| 62 | } | ||
| 63 | |||
| 64 | struct __chunk_partitions { | ||
| 65 | ptrdiff_t __chunk_count_; // includes the first chunk | ||
| 66 | ptrdiff_t __chunk_size_; | ||
| 67 | ptrdiff_t __first_chunk_size_; | ||
| 68 | }; | ||
| 69 | |||
| 70 | [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept; | ||
| 71 | |||
| 72 | template <class _RandomAccessIterator, class _Functor> | ||
| 73 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 74 | __dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) { | ||
| 75 | // Perform the chunked execution. | ||
| 76 | __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) { | ||
| 77 | auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_; | ||
| 78 | auto __index = | ||
| 79 | __chunk == 0 | ||
| 80 | ? 0 | ||
| 81 | : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_); | ||
| 82 | __func(__first + __index, __first + __index + __this_chunk_size); | ||
| 83 | }); | ||
| 84 | |||
| 85 | return __empty{}; | ||
| 86 | } | ||
| 87 | } // namespace __libdispatch | ||
| 88 | |||
| 89 | template <> | ||
| 90 | struct __cpu_traits<__libdispatch_backend_tag> { | ||
| 91 | template <class _RandomAccessIterator, class _Functor> | ||
| 92 | _LIBCPP_HIDE_FROM_ABI static optional<__empty> | ||
| 93 | __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) { | ||
| 94 | return __libdispatch::__dispatch_parallel_for( | ||
| 95 | __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func)); | ||
| 96 | } | ||
| 97 | |||
| 98 | template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _RandomAccessIteratorOut> | ||
| 99 | struct __merge_range { | ||
| 100 | __merge_range(_RandomAccessIterator1 __mid1, _RandomAccessIterator2 __mid2, _RandomAccessIteratorOut __result) | ||
| 101 | : __mid1_(__mid1), __mid2_(__mid2), __result_(__result) {} | ||
| 102 | |||
| 103 | _RandomAccessIterator1 __mid1_; | ||
| 104 | _RandomAccessIterator2 __mid2_; | ||
| 105 | _RandomAccessIteratorOut __result_; | ||
| 106 | }; | ||
| 107 | |||
| 108 | template <typename _RandomAccessIterator1, | ||
| 109 | typename _RandomAccessIterator2, | ||
| 110 | typename _RandomAccessIterator3, | ||
| 111 | typename _Compare, | ||
| 112 | typename _LeafMerge> | ||
| 113 | _LIBCPP_HIDE_FROM_ABI static optional<__empty> | ||
| 114 | __merge(_RandomAccessIterator1 __first1, | ||
| 115 | _RandomAccessIterator1 __last1, | ||
| 116 | _RandomAccessIterator2 __first2, | ||
| 117 | _RandomAccessIterator2 __last2, | ||
| 118 | _RandomAccessIterator3 __result, | ||
| 119 | _Compare __comp, | ||
| 120 | _LeafMerge __leaf_merge) noexcept { | ||
| 121 | __libdispatch::__chunk_partitions __partitions = | ||
| 122 | __libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2)); | ||
| 123 | |||
| 124 | if (__partitions.__chunk_count_ == 0) | ||
| 125 | return __empty{}; | ||
| 126 | |||
| 127 | if (__partitions.__chunk_count_ == 1) { | ||
| 128 | __leaf_merge(__first1, __last1, __first2, __last2, __result, __comp); | ||
| 129 | return __empty{}; | ||
| 130 | } | ||
| 131 | |||
| 132 | using __merge_range_t = __merge_range<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator3>; | ||
| 133 | auto const __n_ranges = __partitions.__chunk_count_ + 1; | ||
| 134 | |||
| 135 | // TODO: use __uninitialized_buffer | ||
| 136 | auto __destroy = [=](__merge_range_t* __ptr) { | ||
| 137 | std::destroy_n(__ptr, __n_ranges); | ||
| 138 | std::allocator<__merge_range_t>().deallocate(__ptr, __n_ranges); | ||
| 139 | }; | ||
| 140 | |||
| 141 | unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges( | ||
| 142 | [&]() -> __merge_range_t* { | ||
| 143 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 144 | try { | ||
| 145 | #endif | ||
| 146 | return std::allocator<__merge_range_t>().allocate(__n_ranges); | ||
| 147 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 148 | } catch (const std::bad_alloc&) { | ||
| 149 | return nullptr; | ||
| 150 | } | ||
| 151 | #endif | ||
| 152 | }(), | ||
| 153 | __destroy); | ||
| 154 | |||
| 155 | if (!__ranges) | ||
| 156 | return nullopt; | ||
| 157 | |||
| 158 | // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case | ||
| 159 | __merge_range_t* __r = __ranges.get(); | ||
| 160 | std::__construct_at(__r++, __first1, __first2, __result); | ||
| 161 | |||
| 162 | bool __iterate_first_range = __last1 - __first1 > __last2 - __first2; | ||
| 163 | |||
| 164 | auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t { | ||
| 165 | auto [__mid1, __mid2] = [&] { | ||
| 166 | if (__iterate_first_range) { | ||
| 167 | auto __m1 = __first1 + __chunk_size; | ||
| 168 | auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp); | ||
| 169 | return std::make_pair(__m1, __m2); | ||
| 170 | } else { | ||
| 171 | auto __m2 = __first2 + __chunk_size; | ||
| 172 | auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp); | ||
| 173 | return std::make_pair(__m1, __m2); | ||
| 174 | } | ||
| 175 | }(); | ||
| 176 | |||
| 177 | __result += (__mid1 - __first1) + (__mid2 - __first2); | ||
| 178 | __first1 = __mid1; | ||
| 179 | __first2 = __mid2; | ||
| 180 | return {std::move(__mid1), std::move(__mid2), __result}; | ||
| 181 | }; | ||
| 182 | |||
| 183 | // handle first chunk | ||
| 184 | std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_)); | ||
| 185 | |||
| 186 | // handle 2 -> N - 1 chunks | ||
| 187 | for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i) | ||
| 188 | std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_)); | ||
| 189 | |||
| 190 | // handle last chunk | ||
| 191 | std::__construct_at(__r, __last1, __last2, __result); | ||
| 192 | |||
| 193 | __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) { | ||
| 194 | auto __first_iters = __ranges[__index]; | ||
| 195 | auto __last_iters = __ranges[__index + 1]; | ||
| 196 | __leaf_merge( | ||
| 197 | __first_iters.__mid1_, | ||
| 198 | __last_iters.__mid1_, | ||
| 199 | __first_iters.__mid2_, | ||
| 200 | __last_iters.__mid2_, | ||
| 201 | __first_iters.__result_, | ||
| 202 | __comp); | ||
| 203 | }); | ||
| 204 | |||
| 205 | return __empty{}; | ||
| 206 | } | ||
| 207 | |||
| 208 | template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction> | ||
| 209 | _LIBCPP_HIDE_FROM_ABI static optional<_Value> __transform_reduce( | ||
| 210 | _RandomAccessIterator __first, | ||
| 211 | _RandomAccessIterator __last, | ||
| 212 | _Transform __transform, | ||
| 213 | _Value __init, | ||
| 214 | _Combiner __combiner, | ||
| 215 | _Reduction __reduction) { | ||
| 216 | if (__first == __last) | ||
| 217 | return __init; | ||
| 218 | |||
| 219 | auto __partitions = __libdispatch::__partition_chunks(__last - __first); | ||
| 220 | |||
| 221 | auto __destroy = [__count = __partitions.__chunk_count_](_Value* __ptr) { | ||
| 222 | std::destroy_n(__ptr, __count); | ||
| 223 | std::allocator<_Value>().deallocate(__ptr, __count); | ||
| 224 | }; | ||
| 225 | |||
| 226 | // TODO: use __uninitialized_buffer | ||
| 227 | // TODO: allocate one element per worker instead of one element per chunk | ||
| 228 | unique_ptr<_Value[], decltype(__destroy)> __values( | ||
| 229 | std::allocator<_Value>().allocate(__partitions.__chunk_count_), __destroy); | ||
| 230 | |||
| 231 | // __dispatch_apply is noexcept | ||
| 232 | __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) { | ||
| 233 | auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_; | ||
| 234 | auto __index = __chunk == 0 ? 0 | ||
| 235 | : (__chunk * __partitions.__chunk_size_) + | ||
| 236 | (__partitions.__first_chunk_size_ - __partitions.__chunk_size_); | ||
| 237 | if (__this_chunk_size != 1) { | ||
| 238 | std::__construct_at( | ||
| 239 | __values.get() + __chunk, | ||
| 240 | __reduction(__first + __index + 2, | ||
| 241 | __first + __index + __this_chunk_size, | ||
| 242 | __combiner(__transform(__first + __index), __transform(__first + __index + 1)))); | ||
| 243 | } else { | ||
| 244 | std::__construct_at(__values.get() + __chunk, __transform(__first + __index)); | ||
| 245 | } | ||
| 246 | }); | ||
| 247 | |||
| 248 | return std::reduce( | ||
| 249 | std::make_move_iterator(__values.get()), | ||
| 250 | std::make_move_iterator(__values.get() + __partitions.__chunk_count_), | ||
| 251 | std::move(__init), | ||
| 252 | __combiner); | ||
| 253 | } | ||
| 254 | |||
| 255 | template <class _RandomAccessIterator, class _Comp, class _LeafSort> | ||
| 256 | _LIBCPP_HIDE_FROM_ABI static optional<__empty> | ||
| 257 | __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) { | ||
| 258 | const auto __size = __last - __first; | ||
| 259 | auto __partitions = __libdispatch::__partition_chunks(__size); | ||
| 260 | |||
| 261 | if (__partitions.__chunk_count_ == 0) | ||
| 262 | return __empty{}; | ||
| 263 | |||
| 264 | if (__partitions.__chunk_count_ == 1) { | ||
| 265 | __leaf_sort(__first, __last, __comp); | ||
| 266 | return __empty{}; | ||
| 267 | } | ||
| 268 | |||
| 269 | using _Value = __iter_value_type<_RandomAccessIterator>; | ||
| 270 | |||
| 271 | auto __destroy = [__size](_Value* __ptr) { | ||
| 272 | std::destroy_n(__ptr, __size); | ||
| 273 | std::allocator<_Value>().deallocate(__ptr, __size); | ||
| 274 | }; | ||
| 275 | |||
| 276 | // TODO: use __uninitialized_buffer | ||
| 277 | unique_ptr<_Value[], decltype(__destroy)> __values(std::allocator<_Value>().allocate(__size), __destroy); | ||
| 278 | |||
| 279 | // Initialize all elements to a moved-from state | ||
| 280 | // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928 | ||
| 281 | std::__construct_at(__values.get(), std::move(*__first)); | ||
| 282 | for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) { | ||
| 283 | std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1])); | ||
| 284 | } | ||
| 285 | *__first = std::move(__values.get()[__size - 1]); | ||
| 286 | |||
| 287 | __libdispatch::__dispatch_parallel_for( | ||
| 288 | __partitions, | ||
| 289 | __first, | ||
| 290 | [&__leaf_sort, &__comp](_RandomAccessIterator __chunk_first, _RandomAccessIterator __chunk_last) { | ||
| 291 | __leaf_sort(std::move(__chunk_first), std::move(__chunk_last), __comp); | ||
| 292 | }); | ||
| 293 | |||
| 294 | bool __objects_are_in_buffer = false; | ||
| 295 | do { | ||
| 296 | const auto __old_chunk_size = __partitions.__chunk_size_; | ||
| 297 | if (__partitions.__chunk_count_ % 2 == 1) { | ||
| 298 | auto __inplace_merge_chunks = [&__comp, &__partitions](auto __first_chunk_begin) { | ||
| 299 | std::inplace_merge( | ||
| 300 | __first_chunk_begin, | ||
| 301 | __first_chunk_begin + __partitions.__first_chunk_size_, | ||
| 302 | __first_chunk_begin + __partitions.__first_chunk_size_ + __partitions.__chunk_size_, | ||
| 303 | __comp); | ||
| 304 | }; | ||
| 305 | if (__objects_are_in_buffer) | ||
| 306 | __inplace_merge_chunks(__values.get()); | ||
| 307 | else | ||
| 308 | __inplace_merge_chunks(__first); | ||
| 309 | __partitions.__first_chunk_size_ += 2 * __partitions.__chunk_size_; | ||
| 310 | } else { | ||
| 311 | __partitions.__first_chunk_size_ += __partitions.__chunk_size_; | ||
| 312 | } | ||
| 313 | |||
| 314 | __partitions.__chunk_size_ *= 2; | ||
| 315 | __partitions.__chunk_count_ /= 2; | ||
| 316 | |||
| 317 | auto __merge_chunks = [__partitions, __old_chunk_size, &__comp](auto __from_first, auto __to_first) { | ||
| 318 | __libdispatch::__dispatch_parallel_for( | ||
| 319 | __partitions, | ||
| 320 | __from_first, | ||
| 321 | [__old_chunk_size, &__from_first, &__to_first, &__comp](auto __chunk_first, auto __chunk_last) { | ||
| 322 | std::merge(std::make_move_iterator(__chunk_first), | ||
| 323 | std::make_move_iterator(__chunk_last - __old_chunk_size), | ||
| 324 | std::make_move_iterator(__chunk_last - __old_chunk_size), | ||
| 325 | std::make_move_iterator(__chunk_last), | ||
| 326 | __to_first + (__chunk_first - __from_first), | ||
| 327 | __comp); | ||
| 328 | }); | ||
| 329 | }; | ||
| 330 | |||
| 331 | if (__objects_are_in_buffer) | ||
| 332 | __merge_chunks(__values.get(), __first); | ||
| 333 | else | ||
| 334 | __merge_chunks(__first, __values.get()); | ||
| 335 | __objects_are_in_buffer = !__objects_are_in_buffer; | ||
| 336 | } while (__partitions.__chunk_count_ > 1); | ||
| 337 | |||
| 338 | if (__objects_are_in_buffer) { | ||
| 339 | std::move(__values.get(), __values.get() + __size, __first); | ||
| 340 | } | ||
| 341 | |||
| 342 | return __empty{}; | ||
| 343 | } | ||
| 344 | |||
| 345 | _LIBCPP_HIDE_FROM_ABI static void __cancel_execution() {} | ||
| 346 | |||
| 347 | static constexpr size_t __lane_size = 64; | ||
| 348 | }; | ||
| 349 | |||
| 350 | // Mandatory implementations of the computational basis | ||
| 351 | template <class _ExecutionPolicy> | ||
| 352 | struct __find_if<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 353 | : __cpu_parallel_find_if<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 354 | |||
| 355 | template <class _ExecutionPolicy> | ||
| 356 | struct __for_each<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 357 | : __cpu_parallel_for_each<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 358 | |||
| 359 | template <class _ExecutionPolicy> | ||
| 360 | struct __merge<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 361 | : __cpu_parallel_merge<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 362 | |||
| 363 | template <class _ExecutionPolicy> | ||
| 364 | struct __stable_sort<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 365 | : __cpu_parallel_stable_sort<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 366 | |||
| 367 | template <class _ExecutionPolicy> | ||
| 368 | struct __transform<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 369 | : __cpu_parallel_transform<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 370 | |||
| 371 | template <class _ExecutionPolicy> | ||
| 372 | struct __transform_binary<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 373 | : __cpu_parallel_transform_binary<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 374 | |||
| 375 | template <class _ExecutionPolicy> | ||
| 376 | struct __transform_reduce<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 377 | : __cpu_parallel_transform_reduce<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 378 | |||
| 379 | template <class _ExecutionPolicy> | ||
| 380 | struct __transform_reduce_binary<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 381 | : __cpu_parallel_transform_reduce_binary<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 382 | |||
| 383 | // Not mandatory, but better optimized | ||
| 384 | template <class _ExecutionPolicy> | ||
| 385 | struct __any_of<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 386 | : __cpu_parallel_any_of<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 387 | |||
| 388 | template <class _ExecutionPolicy> | ||
| 389 | struct __fill<__libdispatch_backend_tag, _ExecutionPolicy> | ||
| 390 | : __cpu_parallel_fill<__libdispatch_backend_tag, _ExecutionPolicy> {}; | ||
| 391 | |||
| 392 | } // namespace __pstl | ||
| 393 | _LIBCPP_END_NAMESPACE_STD | ||
| 394 | |||
| 395 | _LIBCPP_POP_MACROS | ||
| 396 | |||
| 397 | #endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H | ||
lib/libcxx/include/__pstl/backends/serial.h created+181| ... | @@ -0,0 +1,181 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___PSTL_BACKENDS_SERIAL_H | ||
| 11 | #define _LIBCPP___PSTL_BACKENDS_SERIAL_H | ||
| 12 | |||
| 13 | #include <__algorithm/find_if.h> | ||
| 14 | #include <__algorithm/for_each.h> | ||
| 15 | #include <__algorithm/merge.h> | ||
| 16 | #include <__algorithm/stable_sort.h> | ||
| 17 | #include <__algorithm/transform.h> | ||
| 18 | #include <__config> | ||
| 19 | #include <__numeric/transform_reduce.h> | ||
| 20 | #include <__pstl/backend_fwd.h> | ||
| 21 | #include <__utility/empty.h> | ||
| 22 | #include <__utility/forward.h> | ||
| 23 | #include <__utility/move.h> | ||
| 24 | #include <optional> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_PUSH_MACROS | ||
| 31 | #include <__undef_macros> | ||
| 32 | |||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 34 | namespace __pstl { | ||
| 35 | |||
| 36 | // | ||
| 37 | // This partial PSTL backend runs everything serially. | ||
| 38 | // | ||
| 39 | // TODO: Right now, the serial backend must be used with another backend | ||
| 40 | // like the "default backend" because it doesn't implement all the | ||
| 41 | // necessary PSTL operations. It would be better to dispatch all | ||
| 42 | // algorithms to their serial counterpart directly, since this can | ||
| 43 | // often be more efficient than the "default backend"'s implementation | ||
| 44 | // if we end up running serially anyways. | ||
| 45 | // | ||
| 46 | |||
| 47 | template <class _ExecutionPolicy> | ||
| 48 | struct __find_if<__serial_backend_tag, _ExecutionPolicy> { | ||
| 49 | template <class _Policy, class _ForwardIterator, class _Pred> | ||
| 50 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator> | ||
| 51 | operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | ||
| 52 | return std::find_if(std::move(__first), std::move(__last), std::forward<_Pred>(__pred)); | ||
| 53 | } | ||
| 54 | }; | ||
| 55 | |||
| 56 | template <class _ExecutionPolicy> | ||
| 57 | struct __for_each<__serial_backend_tag, _ExecutionPolicy> { | ||
| 58 | template <class _Policy, class _ForwardIterator, class _Function> | ||
| 59 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 60 | operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Function&& __func) const noexcept { | ||
| 61 | std::for_each(std::move(__first), std::move(__last), std::forward<_Function>(__func)); | ||
| 62 | return __empty{}; | ||
| 63 | } | ||
| 64 | }; | ||
| 65 | |||
| 66 | template <class _ExecutionPolicy> | ||
| 67 | struct __merge<__serial_backend_tag, _ExecutionPolicy> { | ||
| 68 | template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp> | ||
| 69 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> operator()( | ||
| 70 | _Policy&&, | ||
| 71 | _ForwardIterator1 __first1, | ||
| 72 | _ForwardIterator1 __last1, | ||
| 73 | _ForwardIterator2 __first2, | ||
| 74 | _ForwardIterator2 __last2, | ||
| 75 | _ForwardOutIterator __outit, | ||
| 76 | _Comp&& __comp) const noexcept { | ||
| 77 | return std::merge( | ||
| 78 | std::move(__first1), | ||
| 79 | std::move(__last1), | ||
| 80 | std::move(__first2), | ||
| 81 | std::move(__last2), | ||
| 82 | std::move(__outit), | ||
| 83 | std::forward<_Comp>(__comp)); | ||
| 84 | } | ||
| 85 | }; | ||
| 86 | |||
| 87 | template <class _ExecutionPolicy> | ||
| 88 | struct __stable_sort<__serial_backend_tag, _ExecutionPolicy> { | ||
| 89 | template <class _Policy, class _RandomAccessIterator, class _Comp> | ||
| 90 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 91 | operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp&& __comp) const noexcept { | ||
| 92 | std::stable_sort(std::move(__first), std::move(__last), std::forward<_Comp>(__comp)); | ||
| 93 | return __empty{}; | ||
| 94 | } | ||
| 95 | }; | ||
| 96 | |||
| 97 | template <class _ExecutionPolicy> | ||
| 98 | struct __transform<__serial_backend_tag, _ExecutionPolicy> { | ||
| 99 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation> | ||
| 100 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> operator()( | ||
| 101 | _Policy&&, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __outit, _UnaryOperation&& __op) | ||
| 102 | const noexcept { | ||
| 103 | return std::transform( | ||
| 104 | std::move(__first), std::move(__last), std::move(__outit), std::forward<_UnaryOperation>(__op)); | ||
| 105 | } | ||
| 106 | }; | ||
| 107 | |||
| 108 | template <class _ExecutionPolicy> | ||
| 109 | struct __transform_binary<__serial_backend_tag, _ExecutionPolicy> { | ||
| 110 | template <class _Policy, | ||
| 111 | class _ForwardIterator1, | ||
| 112 | class _ForwardIterator2, | ||
| 113 | class _ForwardOutIterator, | ||
| 114 | class _BinaryOperation> | ||
| 115 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 116 | operator()(_Policy&&, | ||
| 117 | _ForwardIterator1 __first1, | ||
| 118 | _ForwardIterator1 __last1, | ||
| 119 | _ForwardIterator2 __first2, | ||
| 120 | _ForwardOutIterator __outit, | ||
| 121 | _BinaryOperation&& __op) const noexcept { | ||
| 122 | return std::transform( | ||
| 123 | std::move(__first1), | ||
| 124 | std::move(__last1), | ||
| 125 | std::move(__first2), | ||
| 126 | std::move(__outit), | ||
| 127 | std::forward<_BinaryOperation>(__op)); | ||
| 128 | } | ||
| 129 | }; | ||
| 130 | |||
| 131 | template <class _ExecutionPolicy> | ||
| 132 | struct __transform_reduce<__serial_backend_tag, _ExecutionPolicy> { | ||
| 133 | template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> | ||
| 134 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> | ||
| 135 | operator()(_Policy&&, | ||
| 136 | _ForwardIterator __first, | ||
| 137 | _ForwardIterator __last, | ||
| 138 | _Tp __init, | ||
| 139 | _BinaryOperation&& __reduce, | ||
| 140 | _UnaryOperation&& __transform) const noexcept { | ||
| 141 | return std::transform_reduce( | ||
| 142 | std::move(__first), | ||
| 143 | std::move(__last), | ||
| 144 | std::move(__init), | ||
| 145 | std::forward<_BinaryOperation>(__reduce), | ||
| 146 | std::forward<_UnaryOperation>(__transform)); | ||
| 147 | } | ||
| 148 | }; | ||
| 149 | |||
| 150 | template <class _ExecutionPolicy> | ||
| 151 | struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> { | ||
| 152 | template <class _Policy, | ||
| 153 | class _ForwardIterator1, | ||
| 154 | class _ForwardIterator2, | ||
| 155 | class _Tp, | ||
| 156 | class _BinaryOperation1, | ||
| 157 | class _BinaryOperation2> | ||
| 158 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> operator()( | ||
| 159 | _Policy&&, | ||
| 160 | _ForwardIterator1 __first1, | ||
| 161 | _ForwardIterator1 __last1, | ||
| 162 | _ForwardIterator2 __first2, | ||
| 163 | _Tp __init, | ||
| 164 | _BinaryOperation1&& __reduce, | ||
| 165 | _BinaryOperation2&& __transform) const noexcept { | ||
| 166 | return std::transform_reduce( | ||
| 167 | std::move(__first1), | ||
| 168 | std::move(__last1), | ||
| 169 | std::move(__first2), | ||
| 170 | std::move(__init), | ||
| 171 | std::forward<_BinaryOperation1>(__reduce), | ||
| 172 | std::forward<_BinaryOperation2>(__transform)); | ||
| 173 | } | ||
| 174 | }; | ||
| 175 | |||
| 176 | } // namespace __pstl | ||
| 177 | _LIBCPP_END_NAMESPACE_STD | ||
| 178 | |||
| 179 | _LIBCPP_POP_MACROS | ||
| 180 | |||
| 181 | #endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H | ||
lib/libcxx/include/__pstl/backends/std_thread.h created+136| ... | @@ -0,0 +1,136 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_BACKENDS_STD_THREAD_H | ||
| 10 | #define _LIBCPP___PSTL_BACKENDS_STD_THREAD_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__pstl/backend_fwd.h> | ||
| 14 | #include <__pstl/cpu_algos/any_of.h> | ||
| 15 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 16 | #include <__pstl/cpu_algos/fill.h> | ||
| 17 | #include <__pstl/cpu_algos/find_if.h> | ||
| 18 | #include <__pstl/cpu_algos/for_each.h> | ||
| 19 | #include <__pstl/cpu_algos/merge.h> | ||
| 20 | #include <__pstl/cpu_algos/stable_sort.h> | ||
| 21 | #include <__pstl/cpu_algos/transform.h> | ||
| 22 | #include <__pstl/cpu_algos/transform_reduce.h> | ||
| 23 | #include <__utility/empty.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | #include <cstddef> | ||
| 26 | #include <optional> | ||
| 27 | |||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 29 | # pragma GCC system_header | ||
| 30 | #endif | ||
| 31 | |||
| 32 | _LIBCPP_PUSH_MACROS | ||
| 33 | #include <__undef_macros> | ||
| 34 | |||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 36 | namespace __pstl { | ||
| 37 | |||
| 38 | // | ||
| 39 | // This partial backend implementation is for testing purposes only and not meant for production use. This will be | ||
| 40 | // replaced by a proper implementation once the PSTL implementation is somewhat stable. | ||
| 41 | // | ||
| 42 | // This is intended to be used on top of the "default backend". | ||
| 43 | // | ||
| 44 | |||
| 45 | template <> | ||
| 46 | struct __cpu_traits<__std_thread_backend_tag> { | ||
| 47 | template <class _RandomAccessIterator, class _Fp> | ||
| 48 | _LIBCPP_HIDE_FROM_ABI static optional<__empty> | ||
| 49 | __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { | ||
| 50 | __f(__first, __last); | ||
| 51 | return __empty{}; | ||
| 52 | } | ||
| 53 | |||
| 54 | template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI static optional<_Tp> | ||
| 56 | __transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) { | ||
| 57 | return __reduce(std::move(__first), std::move(__last), std::move(__init)); | ||
| 58 | } | ||
| 59 | |||
| 60 | template <class _RandomAccessIterator, class _Compare, class _LeafSort> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI static optional<__empty> | ||
| 62 | __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) { | ||
| 63 | __leaf_sort(__first, __last, __comp); | ||
| 64 | return __empty{}; | ||
| 65 | } | ||
| 66 | |||
| 67 | _LIBCPP_HIDE_FROM_ABI static void __cancel_execution() {} | ||
| 68 | |||
| 69 | template <class _RandomAccessIterator1, | ||
| 70 | class _RandomAccessIterator2, | ||
| 71 | class _RandomAccessIterator3, | ||
| 72 | class _Compare, | ||
| 73 | class _LeafMerge> | ||
| 74 | _LIBCPP_HIDE_FROM_ABI static optional<__empty> | ||
| 75 | __merge(_RandomAccessIterator1 __first1, | ||
| 76 | _RandomAccessIterator1 __last1, | ||
| 77 | _RandomAccessIterator2 __first2, | ||
| 78 | _RandomAccessIterator2 __last2, | ||
| 79 | _RandomAccessIterator3 __outit, | ||
| 80 | _Compare __comp, | ||
| 81 | _LeafMerge __leaf_merge) { | ||
| 82 | __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp); | ||
| 83 | return __empty{}; | ||
| 84 | } | ||
| 85 | |||
| 86 | static constexpr size_t __lane_size = 64; | ||
| 87 | }; | ||
| 88 | |||
| 89 | // Mandatory implementations of the computational basis | ||
| 90 | template <class _ExecutionPolicy> | ||
| 91 | struct __find_if<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 92 | : __cpu_parallel_find_if<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 93 | |||
| 94 | template <class _ExecutionPolicy> | ||
| 95 | struct __for_each<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 96 | : __cpu_parallel_for_each<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 97 | |||
| 98 | template <class _ExecutionPolicy> | ||
| 99 | struct __merge<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 100 | : __cpu_parallel_merge<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 101 | |||
| 102 | template <class _ExecutionPolicy> | ||
| 103 | struct __stable_sort<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 104 | : __cpu_parallel_stable_sort<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 105 | |||
| 106 | template <class _ExecutionPolicy> | ||
| 107 | struct __transform<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 108 | : __cpu_parallel_transform<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 109 | |||
| 110 | template <class _ExecutionPolicy> | ||
| 111 | struct __transform_binary<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 112 | : __cpu_parallel_transform_binary<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 113 | |||
| 114 | template <class _ExecutionPolicy> | ||
| 115 | struct __transform_reduce<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 116 | : __cpu_parallel_transform_reduce<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 117 | |||
| 118 | template <class _ExecutionPolicy> | ||
| 119 | struct __transform_reduce_binary<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 120 | : __cpu_parallel_transform_reduce_binary<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 121 | |||
| 122 | // Not mandatory, but better optimized | ||
| 123 | template <class _ExecutionPolicy> | ||
| 124 | struct __any_of<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 125 | : __cpu_parallel_any_of<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 126 | |||
| 127 | template <class _ExecutionPolicy> | ||
| 128 | struct __fill<__std_thread_backend_tag, _ExecutionPolicy> | ||
| 129 | : __cpu_parallel_fill<__std_thread_backend_tag, _ExecutionPolicy> {}; | ||
| 130 | |||
| 131 | } // namespace __pstl | ||
| 132 | _LIBCPP_END_NAMESPACE_STD | ||
| 133 | |||
| 134 | _LIBCPP_POP_MACROS | ||
| 135 | |||
| 136 | #endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H | ||
lib/libcxx/include/__pstl/cpu_algos/any_of.h created+99| ... | @@ -0,0 +1,99 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H | ||
| 11 | |||
| 12 | #include <__algorithm/any_of.h> | ||
| 13 | #include <__assert> | ||
| 14 | #include <__atomic/atomic.h> | ||
| 15 | #include <__atomic/memory_order.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__pstl/backend_fwd.h> | ||
| 19 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 20 | #include <__type_traits/is_execution_policy.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | #include <__utility/pair.h> | ||
| 23 | #include <cstdint> | ||
| 24 | #include <optional> | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | #include <__undef_macros> | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | namespace __pstl { | ||
| 31 | |||
| 32 | template <class _Backend, class _Index, class _Brick> | ||
| 33 | _LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) { | ||
| 34 | std::atomic<bool> __found(false); | ||
| 35 | auto __ret = __cpu_traits<_Backend>::__for_each(__first, __last, [__f, &__found](_Index __i, _Index __j) { | ||
| 36 | if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) { | ||
| 37 | __found.store(true, std::memory_order_relaxed); | ||
| 38 | __cpu_traits<_Backend>::__cancel_execution(); | ||
| 39 | } | ||
| 40 | }); | ||
| 41 | if (!__ret) | ||
| 42 | return nullopt; | ||
| 43 | return static_cast<bool>(__found); | ||
| 44 | } | ||
| 45 | |||
| 46 | // TODO: check whether __simd_first() can be used here | ||
| 47 | template <class _Index, class _DifferenceType, class _Pred> | ||
| 48 | _LIBCPP_HIDE_FROM_ABI bool __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept { | ||
| 49 | _DifferenceType __block_size = 4 < __n ? 4 : __n; | ||
| 50 | const _Index __last = __first + __n; | ||
| 51 | while (__last != __first) { | ||
| 52 | int32_t __flag = 1; | ||
| 53 | _PSTL_PRAGMA_SIMD_REDUCTION(& : __flag) | ||
| 54 | for (_DifferenceType __i = 0; __i < __block_size; ++__i) | ||
| 55 | if (__pred(*(__first + __i))) | ||
| 56 | __flag = 0; | ||
| 57 | if (!__flag) | ||
| 58 | return true; | ||
| 59 | |||
| 60 | __first += __block_size; | ||
| 61 | if (__last - __first >= __block_size << 1) { | ||
| 62 | // Double the block _Size. Any unnecessary iterations can be amortized against work done so far. | ||
| 63 | __block_size <<= 1; | ||
| 64 | } else { | ||
| 65 | __block_size = __last - __first; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | return false; | ||
| 69 | } | ||
| 70 | |||
| 71 | template <class _Backend, class _RawExecutionPolicy> | ||
| 72 | struct __cpu_parallel_any_of { | ||
| 73 | template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 74 | _LIBCPP_HIDE_FROM_ABI optional<bool> | ||
| 75 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept { | ||
| 76 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 77 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 78 | return __pstl::__parallel_or<_Backend>( | ||
| 79 | __first, __last, [&__policy, &__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 80 | using _AnyOfUnseq = __pstl::__any_of<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 81 | auto __res = _AnyOfUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __pred); | ||
| 82 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 83 | return *std::move(__res); | ||
| 84 | }); | ||
| 85 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 86 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 87 | return __pstl::__simd_or(__first, __last - __first, __pred); | ||
| 88 | } else { | ||
| 89 | return std::any_of(__first, __last, __pred); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | |||
| 94 | } // namespace __pstl | ||
| 95 | _LIBCPP_END_NAMESPACE_STD | ||
| 96 | |||
| 97 | _LIBCPP_POP_MACROS | ||
| 98 | |||
| 99 | #endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H | ||
lib/libcxx/include/__pstl/cpu_algos/cpu_traits.h created+86| ... | @@ -0,0 +1,86 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <cstddef> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_PUSH_MACROS | ||
| 20 | #include <__undef_macros> | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | namespace __pstl { | ||
| 24 | |||
| 25 | // __cpu_traits | ||
| 26 | // | ||
| 27 | // This traits class encapsulates the basis operations for a CPU-based implementation of the PSTL. | ||
| 28 | // All the operations in the PSTL can be implemented from these basis operations, so a pure CPU backend | ||
| 29 | // only needs to customize these traits in order to get an implementation of the whole PSTL. | ||
| 30 | // | ||
| 31 | // Basis operations | ||
| 32 | // ================ | ||
| 33 | // | ||
| 34 | // template <class _RandomAccessIterator, class _Functor> | ||
| 35 | // optional<__empty> __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func); | ||
| 36 | // - __func must take a subrange of [__first, __last) that should be executed in serial | ||
| 37 | // | ||
| 38 | // template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction> | ||
| 39 | // optional<_Tp> __transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction); | ||
| 40 | // | ||
| 41 | // template <class _RandomAccessIterator1, | ||
| 42 | // class _RandomAccessIterator2, | ||
| 43 | // class _RandomAccessIterator3, | ||
| 44 | // class _Compare, | ||
| 45 | // class _LeafMerge> | ||
| 46 | // optional<_RandomAccessIterator3> __merge(_RandomAccessIterator1 __first1, | ||
| 47 | // _RandomAccessIterator1 __last1, | ||
| 48 | // _RandomAccessIterator2 __first2, | ||
| 49 | // _RandomAccessIterator2 __last2, | ||
| 50 | // _RandomAccessIterator3 __outit, | ||
| 51 | // _Compare __comp, | ||
| 52 | // _LeafMerge __leaf_merge); | ||
| 53 | // | ||
| 54 | // template <class _RandomAccessIterator, class _Comp, class _LeafSort> | ||
| 55 | // optional<__empty> __stable_sort(_RandomAccessIterator __first, | ||
| 56 | // _RandomAccessIterator __last, | ||
| 57 | // _Comp __comp, | ||
| 58 | // _LeafSort __leaf_sort); | ||
| 59 | // | ||
| 60 | // void __cancel_execution(); | ||
| 61 | // Cancel the execution of other jobs - they aren't needed anymore. This is not a binding request, | ||
| 62 | // some backends may not actually be able to cancel jobs. | ||
| 63 | // | ||
| 64 | // constexpr size_t __lane_size; | ||
| 65 | // Size of SIMD lanes. | ||
| 66 | // TODO: Merge this with __native_vector_size from __algorithm/simd_utils.h | ||
| 67 | // | ||
| 68 | // | ||
| 69 | // Exception handling | ||
| 70 | // ================== | ||
| 71 | // | ||
| 72 | // CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their | ||
| 73 | // implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are | ||
| 74 | // turned into a program termination at the front-end level. When a backend returns a disengaged `optional` to the | ||
| 75 | // frontend, the frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to | ||
| 76 | // the user. | ||
| 77 | |||
| 78 | template <class _Backend> | ||
| 79 | struct __cpu_traits; | ||
| 80 | |||
| 81 | } // namespace __pstl | ||
| 82 | _LIBCPP_END_NAMESPACE_STD | ||
| 83 | |||
| 84 | _LIBCPP_POP_MACROS | ||
| 85 | |||
| 86 | #endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H | ||
lib/libcxx/include/__pstl/cpu_algos/fill.h created+66| ... | @@ -0,0 +1,66 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_FILL_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_FILL_H | ||
| 11 | |||
| 12 | #include <__algorithm/fill.h> | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__pstl/backend_fwd.h> | ||
| 17 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 18 | #include <__type_traits/is_execution_policy.h> | ||
| 19 | #include <__utility/empty.h> | ||
| 20 | #include <optional> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | namespace __pstl { | ||
| 28 | |||
| 29 | template <class _Index, class _DifferenceType, class _Tp> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI _Index __simd_fill_n(_Index __first, _DifferenceType __n, const _Tp& __value) noexcept { | ||
| 31 | _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED | ||
| 32 | _PSTL_PRAGMA_SIMD | ||
| 33 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 34 | __first[__i] = __value; | ||
| 35 | return __first + __n; | ||
| 36 | } | ||
| 37 | |||
| 38 | template <class _Backend, class _RawExecutionPolicy> | ||
| 39 | struct __cpu_parallel_fill { | ||
| 40 | template <class _Policy, class _ForwardIterator, class _Tp> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 42 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept { | ||
| 43 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 44 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 45 | return __cpu_traits<_Backend>::__for_each( | ||
| 46 | __first, __last, [&__policy, &__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 47 | using _FillUnseq = __pstl::__fill<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 48 | [[maybe_unused]] auto __res = | ||
| 49 | _FillUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __value); | ||
| 50 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 51 | }); | ||
| 52 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 53 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 54 | __pstl::__simd_fill_n(__first, __last - __first, __value); | ||
| 55 | return __empty{}; | ||
| 56 | } else { | ||
| 57 | std::fill(__first, __last, __value); | ||
| 58 | return __empty{}; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | }; | ||
| 62 | |||
| 63 | } // namespace __pstl | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | ||
| 65 | |||
| 66 | #endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H | ||
lib/libcxx/include/__pstl/cpu_algos/find_if.h created+137| ... | @@ -0,0 +1,137 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H | ||
| 11 | |||
| 12 | #include <__algorithm/find_if.h> | ||
| 13 | #include <__assert> | ||
| 14 | #include <__atomic/atomic.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__functional/operations.h> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__iterator/iterator_traits.h> | ||
| 19 | #include <__pstl/backend_fwd.h> | ||
| 20 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 21 | #include <__type_traits/is_execution_policy.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | #include <__utility/pair.h> | ||
| 24 | #include <cstddef> | ||
| 25 | #include <optional> | ||
| 26 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | #include <__undef_macros> | ||
| 33 | |||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 35 | namespace __pstl { | ||
| 36 | |||
| 37 | template <class _Backend, class _Index, class _Brick, class _Compare> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI optional<_Index> | ||
| 39 | __parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool __b_first) { | ||
| 40 | typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType; | ||
| 41 | const _DifferenceType __n = __last - __first; | ||
| 42 | _DifferenceType __initial_dist = __b_first ? __n : -1; | ||
| 43 | std::atomic<_DifferenceType> __extremum(__initial_dist); | ||
| 44 | // TODO: find out what is better here: parallel_for or parallel_reduce | ||
| 45 | auto __res = | ||
| 46 | __cpu_traits<_Backend>::__for_each(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) { | ||
| 47 | // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of | ||
| 48 | // why using a shared variable scales fairly well in this situation. | ||
| 49 | if (__comp(__i - __first, __extremum)) { | ||
| 50 | _Index __result = __f(__i, __j); | ||
| 51 | // If not '__last' returned then we found what we want so put this to extremum | ||
| 52 | if (__result != __j) { | ||
| 53 | const _DifferenceType __k = __result - __first; | ||
| 54 | for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) { | ||
| 55 | __extremum.compare_exchange_weak(__old, __k); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | }); | ||
| 60 | if (!__res) | ||
| 61 | return nullopt; | ||
| 62 | return __extremum.load() != __initial_dist ? __first + __extremum.load() : __last; | ||
| 63 | } | ||
| 64 | |||
| 65 | template <class _Backend, class _Index, class _DifferenceType, class _Compare> | ||
| 66 | _LIBCPP_HIDE_FROM_ABI _Index | ||
| 67 | __simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp) noexcept { | ||
| 68 | // Experiments show good block sizes like this | ||
| 69 | const _DifferenceType __block_size = 8; | ||
| 70 | alignas(__cpu_traits<_Backend>::__lane_size) _DifferenceType __lane[__block_size] = {0}; | ||
| 71 | while (__end - __begin >= __block_size) { | ||
| 72 | _DifferenceType __found = 0; | ||
| 73 | _PSTL_PRAGMA_SIMD_REDUCTION(| : __found) for (_DifferenceType __i = __begin; __i < __begin + __block_size; ++__i) { | ||
| 74 | const _DifferenceType __t = __comp(__first, __i); | ||
| 75 | __lane[__i - __begin] = __t; | ||
| 76 | __found |= __t; | ||
| 77 | } | ||
| 78 | if (__found) { | ||
| 79 | _DifferenceType __i; | ||
| 80 | // This will vectorize | ||
| 81 | for (__i = 0; __i < __block_size; ++__i) { | ||
| 82 | if (__lane[__i]) { | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | return __first + __begin + __i; | ||
| 87 | } | ||
| 88 | __begin += __block_size; | ||
| 89 | } | ||
| 90 | |||
| 91 | // Keep remainder scalar | ||
| 92 | while (__begin != __end) { | ||
| 93 | if (__comp(__first, __begin)) { | ||
| 94 | return __first + __begin; | ||
| 95 | } | ||
| 96 | ++__begin; | ||
| 97 | } | ||
| 98 | return __first + __end; | ||
| 99 | } | ||
| 100 | |||
| 101 | template <class _Backend, class _RawExecutionPolicy> | ||
| 102 | struct __cpu_parallel_find_if { | ||
| 103 | template <class _Policy, class _ForwardIterator, class _Predicate> | ||
| 104 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator> | ||
| 105 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept { | ||
| 106 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 107 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 108 | return __pstl::__parallel_find<_Backend>( | ||
| 109 | __first, | ||
| 110 | __last, | ||
| 111 | [&__policy, &__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 112 | using _FindIfUnseq = __pstl::__find_if<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 113 | auto __res = _FindIfUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __pred); | ||
| 114 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 115 | return *std::move(__res); | ||
| 116 | }, | ||
| 117 | less<>{}, | ||
| 118 | true); | ||
| 119 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 120 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 121 | using __diff_t = __iter_diff_t<_ForwardIterator>; | ||
| 122 | return __pstl::__simd_first<_Backend>( | ||
| 123 | __first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) { | ||
| 124 | return __pred(__iter[__i]); | ||
| 125 | }); | ||
| 126 | } else { | ||
| 127 | return std::find_if(__first, __last, __pred); | ||
| 128 | } | ||
| 129 | } | ||
| 130 | }; | ||
| 131 | |||
| 132 | } // namespace __pstl | ||
| 133 | _LIBCPP_END_NAMESPACE_STD | ||
| 134 | |||
| 135 | _LIBCPP_POP_MACROS | ||
| 136 | |||
| 137 | #endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H | ||
lib/libcxx/include/__pstl/cpu_algos/for_each.h created+66| ... | @@ -0,0 +1,66 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H | ||
| 11 | |||
| 12 | #include <__algorithm/for_each.h> | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__pstl/backend_fwd.h> | ||
| 17 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 18 | #include <__type_traits/is_execution_policy.h> | ||
| 19 | #include <__utility/empty.h> | ||
| 20 | #include <optional> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | namespace __pstl { | ||
| 28 | |||
| 29 | template <class _Iterator, class _DifferenceType, class _Function> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI _Iterator __simd_for_each(_Iterator __first, _DifferenceType __n, _Function __f) noexcept { | ||
| 31 | _PSTL_PRAGMA_SIMD | ||
| 32 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 33 | __f(__first[__i]); | ||
| 34 | |||
| 35 | return __first + __n; | ||
| 36 | } | ||
| 37 | |||
| 38 | template <class _Backend, class _RawExecutionPolicy> | ||
| 39 | struct __cpu_parallel_for_each { | ||
| 40 | template <class _Policy, class _ForwardIterator, class _Function> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 42 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) const noexcept { | ||
| 43 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 44 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 45 | return __cpu_traits<_Backend>::__for_each( | ||
| 46 | __first, __last, [&__policy, __func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 47 | using _ForEachUnseq = __pstl::__for_each<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 48 | [[maybe_unused]] auto __res = | ||
| 49 | _ForEachUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __func); | ||
| 50 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 51 | }); | ||
| 52 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 53 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 54 | __pstl::__simd_for_each(__first, __last - __first, __func); | ||
| 55 | return __empty{}; | ||
| 56 | } else { | ||
| 57 | std::for_each(__first, __last, __func); | ||
| 58 | return __empty{}; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | }; | ||
| 62 | |||
| 63 | } // namespace __pstl | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | ||
| 65 | |||
| 66 | #endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H | ||
lib/libcxx/include/__pstl/cpu_algos/merge.h created+85| ... | @@ -0,0 +1,85 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_MERGE_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_MERGE_H | ||
| 11 | |||
| 12 | #include <__algorithm/merge.h> | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__pstl/backend_fwd.h> | ||
| 17 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 18 | #include <__type_traits/is_execution_policy.h> | ||
| 19 | #include <__utility/move.h> | ||
| 20 | #include <optional> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | #include <__undef_macros> | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | namespace __pstl { | ||
| 31 | |||
| 32 | template <class _Backend, class _RawExecutionPolicy> | ||
| 33 | struct __cpu_parallel_merge { | ||
| 34 | template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp> | ||
| 35 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> operator()( | ||
| 36 | _Policy&& __policy, | ||
| 37 | _ForwardIterator1 __first1, | ||
| 38 | _ForwardIterator1 __last1, | ||
| 39 | _ForwardIterator2 __first2, | ||
| 40 | _ForwardIterator2 __last2, | ||
| 41 | _ForwardOutIterator __result, | ||
| 42 | _Comp __comp) const noexcept { | ||
| 43 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 44 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 45 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && | ||
| 46 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 47 | auto __res = __cpu_traits<_Backend>::__merge( | ||
| 48 | __first1, | ||
| 49 | __last1, | ||
| 50 | __first2, | ||
| 51 | __last2, | ||
| 52 | __result, | ||
| 53 | __comp, | ||
| 54 | [&__policy](_ForwardIterator1 __g_first1, | ||
| 55 | _ForwardIterator1 __g_last1, | ||
| 56 | _ForwardIterator2 __g_first2, | ||
| 57 | _ForwardIterator2 __g_last2, | ||
| 58 | _ForwardOutIterator __g_result, | ||
| 59 | _Comp __g_comp) { | ||
| 60 | using _MergeUnseq = __pstl::__merge<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 61 | [[maybe_unused]] auto __g_res = _MergeUnseq()( | ||
| 62 | std::__remove_parallel_policy(__policy), | ||
| 63 | std::move(__g_first1), | ||
| 64 | std::move(__g_last1), | ||
| 65 | std::move(__g_first2), | ||
| 66 | std::move(__g_last2), | ||
| 67 | std::move(__g_result), | ||
| 68 | std::move(__g_comp)); | ||
| 69 | _LIBCPP_ASSERT_INTERNAL(__g_res, "unsed/sed should never try to allocate!"); | ||
| 70 | }); | ||
| 71 | if (!__res) | ||
| 72 | return nullopt; | ||
| 73 | return __result + (__last1 - __first1) + (__last2 - __first2); | ||
| 74 | } else { | ||
| 75 | return std::merge(__first1, __last1, __first2, __last2, __result, __comp); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | }; | ||
| 79 | |||
| 80 | } // namespace __pstl | ||
| 81 | _LIBCPP_END_NAMESPACE_STD | ||
| 82 | |||
| 83 | _LIBCPP_POP_MACROS | ||
| 84 | |||
| 85 | #endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H | ||
lib/libcxx/include/__pstl/cpu_algos/stable_sort.h created+47| ... | @@ -0,0 +1,47 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H | ||
| 11 | |||
| 12 | #include <__algorithm/stable_sort.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__pstl/backend_fwd.h> | ||
| 15 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 16 | #include <__type_traits/is_execution_policy.h> | ||
| 17 | #include <__utility/empty.h> | ||
| 18 | #include <optional> | ||
| 19 | |||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 25 | namespace __pstl { | ||
| 26 | |||
| 27 | template <class _Backend, class _RawExecutionPolicy> | ||
| 28 | struct __cpu_parallel_stable_sort { | ||
| 29 | template <class _Policy, class _RandomAccessIterator, class _Comp> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI optional<__empty> | ||
| 31 | operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept { | ||
| 32 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy>) { | ||
| 33 | return __cpu_traits<_Backend>::__stable_sort( | ||
| 34 | __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) { | ||
| 35 | std::stable_sort(__g_first, __g_last, __g_comp); | ||
| 36 | }); | ||
| 37 | } else { | ||
| 38 | std::stable_sort(__first, __last, __comp); | ||
| 39 | return __empty{}; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | }; | ||
| 43 | |||
| 44 | } // namespace __pstl | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | ||
| 46 | |||
| 47 | #endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H | ||
lib/libcxx/include/__pstl/cpu_algos/transform.h created+153| ... | @@ -0,0 +1,153 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H | ||
| 11 | |||
| 12 | #include <__algorithm/transform.h> | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | ||
| 17 | #include <__pstl/backend_fwd.h> | ||
| 18 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 19 | #include <__type_traits/is_execution_policy.h> | ||
| 20 | #include <__utility/move.h> | ||
| 21 | #include <optional> | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 24 | # pragma GCC system_header | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_PUSH_MACROS | ||
| 28 | #include <__undef_macros> | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | namespace __pstl { | ||
| 32 | |||
| 33 | template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Function> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI _Iterator2 | ||
| 35 | __simd_transform(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept { | ||
| 36 | _PSTL_PRAGMA_SIMD | ||
| 37 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 38 | __f(__first1[__i], __first2[__i]); | ||
| 39 | return __first2 + __n; | ||
| 40 | } | ||
| 41 | |||
| 42 | template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Iterator3, class _Function> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_transform( | ||
| 44 | _Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3, _Function __f) noexcept { | ||
| 45 | _PSTL_PRAGMA_SIMD | ||
| 46 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 47 | __f(__first1[__i], __first2[__i], __first3[__i]); | ||
| 48 | return __first3 + __n; | ||
| 49 | } | ||
| 50 | |||
| 51 | template <class _Backend, class _RawExecutionPolicy> | ||
| 52 | struct __cpu_parallel_transform { | ||
| 53 | template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation> | ||
| 54 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 55 | operator()(_Policy&& __policy, | ||
| 56 | _ForwardIterator __first, | ||
| 57 | _ForwardIterator __last, | ||
| 58 | _ForwardOutIterator __result, | ||
| 59 | _UnaryOperation __op) const noexcept { | ||
| 60 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 61 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && | ||
| 62 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 63 | __cpu_traits<_Backend>::__for_each( | ||
| 64 | __first, | ||
| 65 | __last, | ||
| 66 | [&__policy, __op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { | ||
| 67 | using _TransformUnseq = __pstl::__transform<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 68 | auto __res = _TransformUnseq()( | ||
| 69 | std::__remove_parallel_policy(__policy), | ||
| 70 | __brick_first, | ||
| 71 | __brick_last, | ||
| 72 | __result + (__brick_first - __first), | ||
| 73 | __op); | ||
| 74 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 75 | return *std::move(__res); | ||
| 76 | }); | ||
| 77 | return __result + (__last - __first); | ||
| 78 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 79 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && | ||
| 80 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 81 | return __pstl::__simd_transform( | ||
| 82 | __first, | ||
| 83 | __last - __first, | ||
| 84 | __result, | ||
| 85 | [&](__iter_reference<_ForwardIterator> __in_value, __iter_reference<_ForwardOutIterator> __out_value) { | ||
| 86 | __out_value = __op(__in_value); | ||
| 87 | }); | ||
| 88 | } else { | ||
| 89 | return std::transform(__first, __last, __result, __op); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | |||
| 94 | template <class _Backend, class _RawExecutionPolicy> | ||
| 95 | struct __cpu_parallel_transform_binary { | ||
| 96 | template <class _Policy, | ||
| 97 | class _ForwardIterator1, | ||
| 98 | class _ForwardIterator2, | ||
| 99 | class _ForwardOutIterator, | ||
| 100 | class _BinaryOperation> | ||
| 101 | _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> | ||
| 102 | operator()(_Policy&& __policy, | ||
| 103 | _ForwardIterator1 __first1, | ||
| 104 | _ForwardIterator1 __last1, | ||
| 105 | _ForwardIterator2 __first2, | ||
| 106 | _ForwardOutIterator __result, | ||
| 107 | _BinaryOperation __op) const noexcept { | ||
| 108 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 109 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 110 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && | ||
| 111 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 112 | auto __res = __cpu_traits<_Backend>::__for_each( | ||
| 113 | __first1, | ||
| 114 | __last1, | ||
| 115 | [&__policy, __op, __first1, __first2, __result]( | ||
| 116 | _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) { | ||
| 117 | using _TransformBinaryUnseq = | ||
| 118 | __pstl::__transform_binary<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 119 | return _TransformBinaryUnseq()( | ||
| 120 | std::__remove_parallel_policy(__policy), | ||
| 121 | __brick_first, | ||
| 122 | __brick_last, | ||
| 123 | __first2 + (__brick_first - __first1), | ||
| 124 | __result + (__brick_first - __first1), | ||
| 125 | __op); | ||
| 126 | }); | ||
| 127 | if (!__res) | ||
| 128 | return nullopt; | ||
| 129 | return __result + (__last1 - __first1); | ||
| 130 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 131 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 132 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && | ||
| 133 | __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { | ||
| 134 | return __pstl::__simd_transform( | ||
| 135 | __first1, | ||
| 136 | __last1 - __first1, | ||
| 137 | __first2, | ||
| 138 | __result, | ||
| 139 | [&](__iter_reference<_ForwardIterator1> __in1, | ||
| 140 | __iter_reference<_ForwardIterator2> __in2, | ||
| 141 | __iter_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in1, __in2); }); | ||
| 142 | } else { | ||
| 143 | return std::transform(__first1, __last1, __first2, __result, __op); | ||
| 144 | } | ||
| 145 | } | ||
| 146 | }; | ||
| 147 | |||
| 148 | } // namespace __pstl | ||
| 149 | _LIBCPP_END_NAMESPACE_STD | ||
| 150 | |||
| 151 | _LIBCPP_POP_MACROS | ||
| 152 | |||
| 153 | #endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H | ||
lib/libcxx/include/__pstl/cpu_algos/transform_reduce.h created+216| ... | @@ -0,0 +1,216 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H | ||
| 10 | #define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H | ||
| 11 | |||
| 12 | #include <__assert> | ||
| 13 | #include <__config> | ||
| 14 | #include <__iterator/concepts.h> | ||
| 15 | #include <__iterator/iterator_traits.h> | ||
| 16 | #include <__numeric/transform_reduce.h> | ||
| 17 | #include <__pstl/backend_fwd.h> | ||
| 18 | #include <__pstl/cpu_algos/cpu_traits.h> | ||
| 19 | #include <__type_traits/desugars_to.h> | ||
| 20 | #include <__type_traits/is_arithmetic.h> | ||
| 21 | #include <__type_traits/is_execution_policy.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | #include <cstddef> | ||
| 24 | #include <new> | ||
| 25 | #include <optional> | ||
| 26 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | #include <__undef_macros> | ||
| 33 | |||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 35 | namespace __pstl { | ||
| 36 | |||
| 37 | template <typename _Backend, | ||
| 38 | typename _DifferenceType, | ||
| 39 | typename _Tp, | ||
| 40 | typename _BinaryOperation, | ||
| 41 | typename _UnaryOperation, | ||
| 42 | typename _UnaryResult = invoke_result_t<_UnaryOperation, _DifferenceType>, | ||
| 43 | __enable_if_t<__desugars_to_v<__plus_tag, _BinaryOperation, _Tp, _UnaryResult> && is_arithmetic_v<_Tp> && | ||
| 44 | is_arithmetic_v<_UnaryResult>, | ||
| 45 | int> = 0> | ||
| 46 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 47 | __simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _UnaryOperation __f) noexcept { | ||
| 48 | _PSTL_PRAGMA_SIMD_REDUCTION(+ : __init) | ||
| 49 | for (_DifferenceType __i = 0; __i < __n; ++__i) | ||
| 50 | __init += __f(__i); | ||
| 51 | return __init; | ||
| 52 | } | ||
| 53 | |||
| 54 | template <typename _Backend, | ||
| 55 | typename _Size, | ||
| 56 | typename _Tp, | ||
| 57 | typename _BinaryOperation, | ||
| 58 | typename _UnaryOperation, | ||
| 59 | typename _UnaryResult = invoke_result_t<_UnaryOperation, _Size>, | ||
| 60 | __enable_if_t<!(__desugars_to_v<__plus_tag, _BinaryOperation, _Tp, _UnaryResult> && is_arithmetic_v<_Tp> && | ||
| 61 | is_arithmetic_v<_UnaryResult>), | ||
| 62 | int> = 0> | ||
| 63 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 64 | __simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _UnaryOperation __f) noexcept { | ||
| 65 | constexpr size_t __lane_size = __cpu_traits<_Backend>::__lane_size; | ||
| 66 | const _Size __block_size = __lane_size / sizeof(_Tp); | ||
| 67 | if (__n > 2 * __block_size && __block_size > 1) { | ||
| 68 | alignas(__lane_size) char __lane_buffer[__lane_size]; | ||
| 69 | _Tp* __lane = reinterpret_cast<_Tp*>(__lane_buffer); | ||
| 70 | |||
| 71 | // initializer | ||
| 72 | _PSTL_PRAGMA_SIMD | ||
| 73 | for (_Size __i = 0; __i < __block_size; ++__i) { | ||
| 74 | ::new (__lane + __i) _Tp(__binary_op(__f(__i), __f(__block_size + __i))); | ||
| 75 | } | ||
| 76 | // main loop | ||
| 77 | _Size __i = 2 * __block_size; | ||
| 78 | const _Size __last_iteration = __block_size * (__n / __block_size); | ||
| 79 | for (; __i < __last_iteration; __i += __block_size) { | ||
| 80 | _PSTL_PRAGMA_SIMD | ||
| 81 | for (_Size __j = 0; __j < __block_size; ++__j) { | ||
| 82 | __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__i + __j)); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | // remainder | ||
| 86 | _PSTL_PRAGMA_SIMD | ||
| 87 | for (_Size __j = 0; __j < __n - __last_iteration; ++__j) { | ||
| 88 | __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__last_iteration + __j)); | ||
| 89 | } | ||
| 90 | // combiner | ||
| 91 | for (_Size __j = 0; __j < __block_size; ++__j) { | ||
| 92 | __init = __binary_op(std::move(__init), std::move(__lane[__j])); | ||
| 93 | } | ||
| 94 | // destroyer | ||
| 95 | _PSTL_PRAGMA_SIMD | ||
| 96 | for (_Size __j = 0; __j < __block_size; ++__j) { | ||
| 97 | __lane[__j].~_Tp(); | ||
| 98 | } | ||
| 99 | } else { | ||
| 100 | for (_Size __i = 0; __i < __n; ++__i) { | ||
| 101 | __init = __binary_op(std::move(__init), __f(__i)); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | return __init; | ||
| 105 | } | ||
| 106 | |||
| 107 | template <class _Backend, class _RawExecutionPolicy> | ||
| 108 | struct __cpu_parallel_transform_reduce_binary { | ||
| 109 | template <class _Policy, | ||
| 110 | class _ForwardIterator1, | ||
| 111 | class _ForwardIterator2, | ||
| 112 | class _Tp, | ||
| 113 | class _BinaryOperation1, | ||
| 114 | class _BinaryOperation2> | ||
| 115 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> operator()( | ||
| 116 | _Policy&& __policy, | ||
| 117 | _ForwardIterator1 __first1, | ||
| 118 | _ForwardIterator1 __last1, | ||
| 119 | _ForwardIterator2 __first2, | ||
| 120 | _Tp __init, | ||
| 121 | _BinaryOperation1 __reduce, | ||
| 122 | _BinaryOperation2 __transform) const noexcept { | ||
| 123 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 124 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 125 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { | ||
| 126 | return __cpu_traits<_Backend>::__transform_reduce( | ||
| 127 | __first1, | ||
| 128 | std::move(__last1), | ||
| 129 | [__first1, __first2, __transform](_ForwardIterator1 __iter) { | ||
| 130 | return __transform(*__iter, *(__first2 + (__iter - __first1))); | ||
| 131 | }, | ||
| 132 | std::move(__init), | ||
| 133 | std::move(__reduce), | ||
| 134 | [&__policy, __first1, __first2, __reduce, __transform]( | ||
| 135 | _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) { | ||
| 136 | using _TransformReduceBinaryUnseq = | ||
| 137 | __pstl::__transform_reduce_binary<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 138 | return *_TransformReduceBinaryUnseq()( | ||
| 139 | std::__remove_parallel_policy(__policy), | ||
| 140 | __brick_first, | ||
| 141 | std::move(__brick_last), | ||
| 142 | __first2 + (__brick_first - __first1), | ||
| 143 | std::move(__brick_init), | ||
| 144 | std::move(__reduce), | ||
| 145 | std::move(__transform)); | ||
| 146 | }); | ||
| 147 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 148 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | ||
| 149 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { | ||
| 150 | return __pstl::__simd_transform_reduce<_Backend>( | ||
| 151 | __last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) { | ||
| 152 | return __transform(__first1[__i], __first2[__i]); | ||
| 153 | }); | ||
| 154 | } else { | ||
| 155 | return std::transform_reduce( | ||
| 156 | std::move(__first1), | ||
| 157 | std::move(__last1), | ||
| 158 | std::move(__first2), | ||
| 159 | std::move(__init), | ||
| 160 | std::move(__reduce), | ||
| 161 | std::move(__transform)); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | }; | ||
| 165 | |||
| 166 | template <class _Backend, class _RawExecutionPolicy> | ||
| 167 | struct __cpu_parallel_transform_reduce { | ||
| 168 | template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> | ||
| 169 | _LIBCPP_HIDE_FROM_ABI optional<_Tp> | ||
| 170 | operator()(_Policy&& __policy, | ||
| 171 | _ForwardIterator __first, | ||
| 172 | _ForwardIterator __last, | ||
| 173 | _Tp __init, | ||
| 174 | _BinaryOperation __reduce, | ||
| 175 | _UnaryOperation __transform) const noexcept { | ||
| 176 | if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> && | ||
| 177 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 178 | return __cpu_traits<_Backend>::__transform_reduce( | ||
| 179 | std::move(__first), | ||
| 180 | std::move(__last), | ||
| 181 | [__transform](_ForwardIterator __iter) { return __transform(*__iter); }, | ||
| 182 | std::move(__init), | ||
| 183 | __reduce, | ||
| 184 | [&__policy, __transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) { | ||
| 185 | using _TransformReduceUnseq = | ||
| 186 | __pstl::__transform_reduce<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>; | ||
| 187 | auto __res = _TransformReduceUnseq()( | ||
| 188 | std::__remove_parallel_policy(__policy), | ||
| 189 | std::move(__brick_first), | ||
| 190 | std::move(__brick_last), | ||
| 191 | std::move(__brick_init), | ||
| 192 | std::move(__reduce), | ||
| 193 | std::move(__transform)); | ||
| 194 | _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); | ||
| 195 | return *std::move(__res); | ||
| 196 | }); | ||
| 197 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | ||
| 198 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | ||
| 199 | return __pstl::__simd_transform_reduce<_Backend>( | ||
| 200 | __last - __first, | ||
| 201 | std::move(__init), | ||
| 202 | std::move(__reduce), | ||
| 203 | [=, &__transform](__iter_diff_t<_ForwardIterator> __i) { return __transform(__first[__i]); }); | ||
| 204 | } else { | ||
| 205 | return std::transform_reduce( | ||
| 206 | std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | }; | ||
| 210 | |||
| 211 | } // namespace __pstl | ||
| 212 | _LIBCPP_END_NAMESPACE_STD | ||
| 213 | |||
| 214 | _LIBCPP_POP_MACROS | ||
| 215 | |||
| 216 | #endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H | ||
lib/libcxx/include/__pstl/dispatch.h created+66| ... | @@ -0,0 +1,66 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_DISPATCH_H | ||
| 10 | #define _LIBCPP___PSTL_DISPATCH_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__pstl/backend_fwd.h> | ||
| 14 | #include <__type_traits/conditional.h> | ||
| 15 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__type_traits/integral_constant.h> | ||
| 17 | #include <__type_traits/type_identity.h> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | _LIBCPP_PUSH_MACROS | ||
| 24 | #include <__undef_macros> | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | namespace __pstl { | ||
| 28 | |||
| 29 | template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy, class = void> | ||
| 30 | constexpr bool __is_implemented_v = false; | ||
| 31 | |||
| 32 | template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy> | ||
| 33 | constexpr bool __is_implemented_v<_Algorithm, | ||
| 34 | _Backend, | ||
| 35 | _ExecutionPolicy, | ||
| 36 | __enable_if_t<sizeof(_Algorithm<_Backend, _ExecutionPolicy>)>> = true; | ||
| 37 | |||
| 38 | // Helpful to provide better error messages. This will show the algorithm and the execution policy | ||
| 39 | // in the compiler diagnostic. | ||
| 40 | template <template <class, class> class _Algorithm, class _ExecutionPolicy> | ||
| 41 | constexpr bool __cant_find_backend_for = false; | ||
| 42 | |||
| 43 | template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy> | ||
| 44 | struct __find_first_implemented; | ||
| 45 | |||
| 46 | template <template <class, class> class _Algorithm, class _ExecutionPolicy> | ||
| 47 | struct __find_first_implemented<_Algorithm, __backend_configuration<>, _ExecutionPolicy> { | ||
| 48 | static_assert(__cant_find_backend_for<_Algorithm, _ExecutionPolicy>, | ||
| 49 | "Could not find a PSTL backend for the given algorithm and execution policy"); | ||
| 50 | }; | ||
| 51 | |||
| 52 | template <template <class, class> class _Algorithm, class _B1, class... _Bn, class _ExecutionPolicy> | ||
| 53 | struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>, _ExecutionPolicy> | ||
| 54 | : _If<__is_implemented_v<_Algorithm, _B1, _ExecutionPolicy>, | ||
| 55 | __type_identity<_Algorithm<_B1, _ExecutionPolicy>>, | ||
| 56 | __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {}; | ||
| 57 | |||
| 58 | template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy> | ||
| 59 | using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type; | ||
| 60 | |||
| 61 | } // namespace __pstl | ||
| 62 | _LIBCPP_END_NAMESPACE_STD | ||
| 63 | |||
| 64 | _LIBCPP_POP_MACROS | ||
| 65 | |||
| 66 | #endif // _LIBCPP___PSTL_DISPATCH_H | ||
lib/libcxx/include/__pstl/handle_exception.h created+57| ... | @@ -0,0 +1,57 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___PSTL_HANDLE_EXCEPTION_H | ||
| 10 | #define _LIBCPP___PSTL_HANDLE_EXCEPTION_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__utility/forward.h> | ||
| 14 | #include <__utility/move.h> | ||
| 15 | #include <new> // __throw_bad_alloc | ||
| 16 | #include <optional> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_PUSH_MACROS | ||
| 23 | #include <__undef_macros> | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | namespace __pstl { | ||
| 27 | |||
| 28 | template <class _BackendFunction, class... _Args> | ||
| 29 | _LIBCPP_HIDE_FROM_ABI auto __handle_exception_impl(_Args&&... __args) noexcept { | ||
| 30 | return _BackendFunction{}(std::forward<_Args>(__args)...); | ||
| 31 | } | ||
| 32 | |||
| 33 | // This function is used to call a backend PSTL algorithm from a frontend algorithm. | ||
| 34 | // | ||
| 35 | // All PSTL backend algorithms return an optional denoting whether there was an | ||
| 36 | // "infrastructure"-level failure (aka failure to allocate). This function takes | ||
| 37 | // care of unwrapping that and throwing `bad_alloc()` in case there was a problem | ||
| 38 | // in the underlying implementation. | ||
| 39 | // | ||
| 40 | // We must also be careful not to call any user code that could throw an exception | ||
| 41 | // (such as moving or copying iterators) in here since that should terminate the | ||
| 42 | // program, which is why we delegate to a noexcept helper below. | ||
| 43 | template <class _BackendFunction, class... _Args> | ||
| 44 | _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) { | ||
| 45 | auto __result = __pstl::__handle_exception_impl<_BackendFunction>(std::forward<_Args>(__args)...); | ||
| 46 | if (__result == nullopt) | ||
| 47 | std::__throw_bad_alloc(); | ||
| 48 | else | ||
| 49 | return std::move(*__result); | ||
| 50 | } | ||
| 51 | |||
| 52 | } // namespace __pstl | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | ||
| 54 | |||
| 55 | _LIBCPP_POP_MACROS | ||
| 56 | |||
| 57 | #endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H | ||
lib/libcxx/include/__random/discard_block_engine.h+2-2| ... | @@ -50,8 +50,8 @@ public: | ... | @@ -50,8 +50,8 @@ public: |
| 50 | static const result_type _Min = _Engine::_Min; | 50 | static const result_type _Min = _Engine::_Min; |
| 51 | static const result_type _Max = _Engine::_Max; | 51 | static const result_type _Max = _Engine::_Max; |
| 52 | #else | 52 | #else |
| 53 | static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); | 53 | static constexpr result_type _Min = _Engine::min(); |
| 54 | static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); | 54 | static constexpr result_type _Max = _Engine::max(); |
| 55 | #endif | 55 | #endif |
| 56 | 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); } | 57 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); } |
lib/libcxx/include/__random/linear_congruential_engine.h+82-21| ... | @@ -26,32 +26,60 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,32 +26,60 @@ _LIBCPP_PUSH_MACROS |
| 26 | 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | enum __lce_alg_type { | ||
| 30 | _LCE_Full, | ||
| 31 | _LCE_Part, | ||
| 32 | _LCE_Schrage, | ||
| 33 | _LCE_Promote, | ||
| 34 | }; | ||
| 35 | |||
| 29 | template <unsigned long long __a, | 36 | template <unsigned long long __a, |
| 30 | unsigned long long __c, | 37 | unsigned long long __c, |
| 31 | unsigned long long __m, | 38 | unsigned long long __m, |
| 32 | unsigned long long _Mp, | 39 | unsigned long long _Mp, |
| 33 | bool _MightOverflow = (__a != 0 && __m != 0 && __m - 1 > (_Mp - __c) / __a), | 40 | bool _HasOverflow = (__a != 0ull && (__m & (__m - 1ull)) != 0ull), // a != 0, m != 0, m != 2^n |
| 34 | bool _OverflowOK = ((__m | (__m - 1)) > __m), // m = 2^n | 41 | bool _Full = (!_HasOverflow || __m - 1ull <= (_Mp - __c) / __a), // (a * x + c) % m works |
| 35 | bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q | 42 | bool _Part = (!_HasOverflow || __m - 1ull <= _Mp / __a), // (a * x) % m works |
| 43 | bool _Schrage = (_HasOverflow && __m % __a <= __m / __a)> // r <= q | ||
| 36 | struct __lce_alg_picker { | 44 | struct __lce_alg_picker { |
| 37 | static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK, | 45 | static _LIBCPP_CONSTEXPR const __lce_alg_type __mode = |
| 38 | "The current values of a, c, and m cannot generate a number " | 46 | _Full ? _LCE_Full |
| 39 | "within bounds of linear_congruential_engine."); | 47 | : _Part ? _LCE_Part |
| 40 | 48 | : _Schrage ? _LCE_Schrage | |
| 41 | static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow && !_OverflowOK && _SchrageOK; | 49 | : _LCE_Promote; |
| 50 | |||
| 51 | #ifdef _LIBCPP_HAS_NO_INT128 | ||
| 52 | static_assert(_Mp != (unsigned long long)(-1) || _Full || _Part || _Schrage, | ||
| 53 | "The current values for a, c, and m are not currently supported on platforms without __int128"); | ||
| 54 | #endif | ||
| 42 | }; | 55 | }; |
| 43 | 56 | ||
| 44 | template <unsigned long long __a, | 57 | template <unsigned long long __a, |
| 45 | unsigned long long __c, | 58 | unsigned long long __c, |
| 46 | unsigned long long __m, | 59 | unsigned long long __m, |
| 47 | unsigned long long _Mp, | 60 | unsigned long long _Mp, |
| 48 | bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage> | 61 | __lce_alg_type _Mode = __lce_alg_picker<__a, __c, __m, _Mp>::__mode> |
| 49 | struct __lce_ta; | 62 | struct __lce_ta; |
| 50 | 63 | ||
| 51 | // 64 | 64 | // 64 |
| 52 | 65 | ||
| 66 | #ifndef _LIBCPP_HAS_NO_INT128 | ||
| 67 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | ||
| 68 | struct __lce_ta<_Ap, _Cp, _Mp, (unsigned long long)(-1), _LCE_Promote> { | ||
| 69 | typedef unsigned long long result_type; | ||
| 70 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __xp) { | ||
| 71 | __extension__ using __calc_type = unsigned __int128; | ||
| 72 | const __calc_type __a = static_cast<__calc_type>(_Ap); | ||
| 73 | const __calc_type __c = static_cast<__calc_type>(_Cp); | ||
| 74 | const __calc_type __m = static_cast<__calc_type>(_Mp); | ||
| 75 | const __calc_type __x = static_cast<__calc_type>(__xp); | ||
| 76 | return static_cast<result_type>((__a * __x + __c) % __m); | ||
| 77 | } | ||
| 78 | }; | ||
| 79 | #endif | ||
| 80 | |||
| 53 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | 81 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> |
| 54 | struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> { | 82 | struct __lce_ta<__a, __c, __m, (unsigned long long)(-1), _LCE_Schrage> { |
| 55 | typedef unsigned long long result_type; | 83 | typedef unsigned long long result_type; |
| 56 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 84 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 57 | // Schrage's algorithm | 85 | // Schrage's algorithm |
| ... | @@ -66,7 +94,7 @@ struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> { | ... | @@ -66,7 +94,7 @@ struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> { |
| 66 | }; | 94 | }; |
| 67 | 95 | ||
| 68 | template <unsigned long long __a, unsigned long long __m> | 96 | template <unsigned long long __a, unsigned long long __m> |
| 69 | struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> { | 97 | struct __lce_ta<__a, 0ull, __m, (unsigned long long)(-1), _LCE_Schrage> { |
| 70 | typedef unsigned long long result_type; | 98 | typedef unsigned long long result_type; |
| 71 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 99 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 72 | // Schrage's algorithm | 100 | // Schrage's algorithm |
| ... | @@ -80,21 +108,40 @@ struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> { | ... | @@ -80,21 +108,40 @@ struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> { |
| 80 | }; | 108 | }; |
| 81 | 109 | ||
| 82 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | 110 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> |
| 83 | struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false> { | 111 | struct __lce_ta<__a, __c, __m, (unsigned long long)(-1), _LCE_Part> { |
| 112 | typedef unsigned long long result_type; | ||
| 113 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | ||
| 114 | // Use (((a*x) % m) + c) % m | ||
| 115 | __x = (__a * __x) % __m; | ||
| 116 | __x += __c - (__x >= __m - __c) * __m; | ||
| 117 | return __x; | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | ||
| 122 | struct __lce_ta<__a, __c, __m, (unsigned long long)(-1), _LCE_Full> { | ||
| 84 | typedef unsigned long long result_type; | 123 | typedef unsigned long long result_type; |
| 85 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { return (__a * __x + __c) % __m; } | 124 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { return (__a * __x + __c) % __m; } |
| 86 | }; | 125 | }; |
| 87 | 126 | ||
| 88 | template <unsigned long long __a, unsigned long long __c> | 127 | template <unsigned long long __a, unsigned long long __c> |
| 89 | struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false> { | 128 | struct __lce_ta<__a, __c, 0ull, (unsigned long long)(-1), _LCE_Full> { |
| 90 | typedef unsigned long long result_type; | 129 | typedef unsigned long long result_type; |
| 91 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { return __a * __x + __c; } | 130 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { return __a * __x + __c; } |
| 92 | }; | 131 | }; |
| 93 | 132 | ||
| 94 | // 32 | 133 | // 32 |
| 95 | 134 | ||
| 135 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | ||
| 136 | struct __lce_ta<__a, __c, __m, unsigned(-1), _LCE_Promote> { | ||
| 137 | typedef unsigned result_type; | ||
| 138 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | ||
| 139 | return static_cast<result_type>(__lce_ta<__a, __c, __m, (unsigned long long)(-1)>::next(__x)); | ||
| 140 | } | ||
| 141 | }; | ||
| 142 | |||
| 96 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | 143 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> |
| 97 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> { | 144 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(-1), _LCE_Schrage> { |
| 98 | typedef unsigned result_type; | 145 | typedef unsigned result_type; |
| 99 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 146 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 100 | const result_type __a = static_cast<result_type>(_Ap); | 147 | const result_type __a = static_cast<result_type>(_Ap); |
| ... | @@ -112,7 +159,7 @@ struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> { | ... | @@ -112,7 +159,7 @@ struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> { |
| 112 | }; | 159 | }; |
| 113 | 160 | ||
| 114 | template <unsigned long long _Ap, unsigned long long _Mp> | 161 | template <unsigned long long _Ap, unsigned long long _Mp> |
| 115 | struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> { | 162 | struct __lce_ta<_Ap, 0ull, _Mp, unsigned(-1), _LCE_Schrage> { |
| 116 | typedef unsigned result_type; | 163 | typedef unsigned result_type; |
| 117 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 164 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 118 | const result_type __a = static_cast<result_type>(_Ap); | 165 | const result_type __a = static_cast<result_type>(_Ap); |
| ... | @@ -128,7 +175,21 @@ struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> { | ... | @@ -128,7 +175,21 @@ struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> { |
| 128 | }; | 175 | }; |
| 129 | 176 | ||
| 130 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | 177 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> |
| 131 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> { | 178 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(-1), _LCE_Part> { |
| 179 | typedef unsigned result_type; | ||
| 180 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | ||
| 181 | const result_type __a = static_cast<result_type>(_Ap); | ||
| 182 | const result_type __c = static_cast<result_type>(_Cp); | ||
| 183 | const result_type __m = static_cast<result_type>(_Mp); | ||
| 184 | // Use (((a*x) % m) + c) % m | ||
| 185 | __x = (__a * __x) % __m; | ||
| 186 | __x += __c - (__x >= __m - __c) * __m; | ||
| 187 | return __x; | ||
| 188 | } | ||
| 189 | }; | ||
| 190 | |||
| 191 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | ||
| 192 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(-1), _LCE_Full> { | ||
| 132 | typedef unsigned result_type; | 193 | typedef unsigned result_type; |
| 133 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 194 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 134 | const result_type __a = static_cast<result_type>(_Ap); | 195 | const result_type __a = static_cast<result_type>(_Ap); |
| ... | @@ -139,7 +200,7 @@ struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> { | ... | @@ -139,7 +200,7 @@ struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> { |
| 139 | }; | 200 | }; |
| 140 | 201 | ||
| 141 | template <unsigned long long _Ap, unsigned long long _Cp> | 202 | template <unsigned long long _Ap, unsigned long long _Cp> |
| 142 | struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> { | 203 | struct __lce_ta<_Ap, _Cp, 0ull, unsigned(-1), _LCE_Full> { |
| 143 | typedef unsigned result_type; | 204 | typedef unsigned result_type; |
| 144 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 205 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 145 | const result_type __a = static_cast<result_type>(_Ap); | 206 | const result_type __a = static_cast<result_type>(_Ap); |
| ... | @@ -150,11 +211,11 @@ struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> { | ... | @@ -150,11 +211,11 @@ struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> { |
| 150 | 211 | ||
| 151 | // 16 | 212 | // 16 |
| 152 | 213 | ||
| 153 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m, bool __b> | 214 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m, __lce_alg_type __mode> |
| 154 | struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> { | 215 | struct __lce_ta<__a, __c, __m, (unsigned short)(-1), __mode> { |
| 155 | typedef unsigned short result_type; | 216 | typedef unsigned short result_type; |
| 156 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { | 217 | _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { |
| 157 | return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x)); | 218 | return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(-1)>::next(__x)); |
| 158 | } | 219 | } |
| 159 | }; | 220 | }; |
| 160 | 221 | ||
| ... | @@ -178,7 +239,7 @@ public: | ... | @@ -178,7 +239,7 @@ public: |
| 178 | private: | 239 | private: |
| 179 | result_type __x_; | 240 | result_type __x_; |
| 180 | 241 | ||
| 181 | static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0); | 242 | static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(-1); |
| 182 | 243 | ||
| 183 | static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters"); | 244 | static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters"); |
| 184 | static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters"); | 245 | static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters"); |
lib/libcxx/include/__random/negative_binomial_distribution.h+1| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H | 9 | #ifndef _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H |
| 10 | #define _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H | 10 | #define _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H |
| 11 | 11 | ||
| 12 | #include <__assert> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 13 | #include <__random/bernoulli_distribution.h> | 14 | #include <__random/bernoulli_distribution.h> |
| 14 | #include <__random/gamma_distribution.h> | 15 | #include <__random/gamma_distribution.h> |
lib/libcxx/include/__random/seed_seq.h+7-1| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | #include <__algorithm/max.h> | 14 | #include <__algorithm/max.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__type_traits/is_unsigned.h> | ||
| 17 | #include <cstdint> | 18 | #include <cstdint> |
| 18 | #include <initializer_list> | 19 | #include <initializer_list> |
| 19 | #include <vector> | 20 | #include <vector> |
| ... | @@ -35,7 +36,7 @@ public: | ... | @@ -35,7 +36,7 @@ public: |
| 35 | // constructors | 36 | // constructors |
| 36 | _LIBCPP_HIDE_FROM_ABI seed_seq() _NOEXCEPT {} | 37 | _LIBCPP_HIDE_FROM_ABI seed_seq() _NOEXCEPT {} |
| 37 | #ifndef _LIBCPP_CXX03_LANG | 38 | #ifndef _LIBCPP_CXX03_LANG |
| 38 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value>* = nullptr> | 39 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> |
| 39 | _LIBCPP_HIDE_FROM_ABI seed_seq(initializer_list<_Tp> __il) { | 40 | _LIBCPP_HIDE_FROM_ABI seed_seq(initializer_list<_Tp> __il) { |
| 40 | __init(__il.begin(), __il.end()); | 41 | __init(__il.begin(), __il.end()); |
| 41 | } | 42 | } |
| ... | @@ -79,6 +80,11 @@ void seed_seq::__init(_InputIterator __first, _InputIterator __last) { | ... | @@ -79,6 +80,11 @@ void seed_seq::__init(_InputIterator __first, _InputIterator __last) { |
| 79 | 80 | ||
| 80 | template <class _RandomAccessIterator> | 81 | template <class _RandomAccessIterator> |
| 81 | void seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) { | 82 | void seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) { |
| 83 | using _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type; | ||
| 84 | static_assert(is_unsigned<_ValueType>::value && sizeof(_ValueType) >= sizeof(uint32_t), | ||
| 85 | "[rand.util.seedseq]/7 requires the value_type of the iterator to be an unsigned " | ||
| 86 | "integer capable of accommodating 32-bit quantities."); | ||
| 87 | |||
| 82 | if (__first != __last) { | 88 | if (__first != __last) { |
| 83 | std::fill(__first, __last, 0x8b8b8b8b); | 89 | std::fill(__first, __last, 0x8b8b8b8b); |
| 84 | const size_t __n = static_cast<size_t>(__last - __first); | 90 | const size_t __n = static_cast<size_t>(__last - __first); |
lib/libcxx/include/__ranges/access.h+6-9| ... | @@ -41,12 +41,11 @@ concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remov | ... | @@ -41,12 +41,11 @@ concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remov |
| 41 | namespace ranges { | 41 | namespace ranges { |
| 42 | namespace __begin { | 42 | namespace __begin { |
| 43 | template <class _Tp> | 43 | template <class _Tp> |
| 44 | concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { | 44 | concept __member_begin = __can_borrow<_Tp> && requires(_Tp&& __t) { |
| 45 | { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; | 45 | { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | void begin(auto&) = delete; | 48 | void begin() = delete; |
| 49 | void begin(const auto&) = delete; | ||
| 50 | 49 | ||
| 51 | template <class _Tp> | 50 | template <class _Tp> |
| 52 | concept __unqualified_begin = | 51 | concept __unqualified_begin = |
| ... | @@ -104,13 +103,12 @@ using iterator_t = decltype(ranges::begin(std::declval<_Tp&>())); | ... | @@ -104,13 +103,12 @@ using iterator_t = decltype(ranges::begin(std::declval<_Tp&>())); |
| 104 | namespace ranges { | 103 | namespace ranges { |
| 105 | namespace __end { | 104 | namespace __end { |
| 106 | template <class _Tp> | 105 | template <class _Tp> |
| 107 | concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { | 106 | concept __member_end = __can_borrow<_Tp> && requires(_Tp&& __t) { |
| 108 | typename iterator_t<_Tp>; | 107 | typename iterator_t<_Tp>; |
| 109 | { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>; | 108 | { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>; |
| 110 | }; | 109 | }; |
| 111 | 110 | ||
| 112 | void end(auto&) = delete; | 111 | void end() = delete; |
| 113 | void end(const auto&) = delete; | ||
| 114 | 112 | ||
| 115 | template <class _Tp> | 113 | template <class _Tp> |
| 116 | concept __unqualified_end = | 114 | concept __unqualified_end = |
| ... | @@ -193,9 +191,8 @@ struct __fn { | ... | @@ -193,9 +191,8 @@ struct __fn { |
| 193 | 191 | ||
| 194 | template <class _Tp> | 192 | template <class _Tp> |
| 195 | requires is_rvalue_reference_v<_Tp&&> | 193 | requires is_rvalue_reference_v<_Tp&&> |
| 196 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | 194 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept( |
| 197 | noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) | 195 | noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) { |
| 198 | -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) { | ||
| 199 | return ranges::end(static_cast<const _Tp&&>(__t)); | 196 | return ranges::end(static_cast<const _Tp&&>(__t)); |
| 200 | } | 197 | } |
| 201 | }; | 198 | }; |
lib/libcxx/include/__ranges/all.h+2-3| ... | @@ -39,9 +39,8 @@ namespace __all { | ... | @@ -39,9 +39,8 @@ namespace __all { |
| 39 | struct __fn : __range_adaptor_closure<__fn> { | 39 | struct __fn : __range_adaptor_closure<__fn> { |
| 40 | template <class _Tp> | 40 | template <class _Tp> |
| 41 | requires ranges::view<decay_t<_Tp>> | 41 | requires ranges::view<decay_t<_Tp>> |
| 42 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | 42 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept( |
| 43 | noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))) | 43 | noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))) -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) { |
| 44 | -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) { | ||
| 45 | return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)); | 44 | return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)); |
| 46 | } | 45 | } |
| 47 | 46 |
lib/libcxx/include/__ranges/as_rvalue_view.h+8-8| ... | @@ -111,18 +111,18 @@ namespace views { | ... | @@ -111,18 +111,18 @@ namespace views { |
| 111 | namespace __as_rvalue { | 111 | namespace __as_rvalue { |
| 112 | struct __fn : __range_adaptor_closure<__fn> { | 112 | struct __fn : __range_adaptor_closure<__fn> { |
| 113 | template <class _Range> | 113 | template <class _Range> |
| 114 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const | 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto |
| 115 | noexcept(noexcept(/**/ as_rvalue_view(std::forward<_Range>(__range)))) | 115 | operator()(_Range&& __range) noexcept(noexcept(as_rvalue_view(std::forward<_Range>(__range)))) |
| 116 | -> decltype(/*--*/ as_rvalue_view(std::forward<_Range>(__range))) { | 116 | -> decltype(/*--------------------------*/ as_rvalue_view(std::forward<_Range>(__range))) { |
| 117 | return /*-------------*/ as_rvalue_view(std::forward<_Range>(__range)); | 117 | return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range)); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | template <class _Range> | 120 | template <class _Range> |
| 121 | requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>> | 121 | requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>> |
| 122 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const | 122 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto |
| 123 | noexcept(noexcept(/**/ views::all(std::forward<_Range>(__range)))) | 123 | operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range)))) |
| 124 | -> decltype(/*--*/ views::all(std::forward<_Range>(__range))) { | 124 | -> decltype(/*--------------------------*/ views::all(std::forward<_Range>(__range))) { |
| 125 | return /*-------------*/ views::all(std::forward<_Range>(__range)); | 125 | return /*---------------------------------*/ views::all(std::forward<_Range>(__range)); |
| 126 | } | 126 | } |
| 127 | }; | 127 | }; |
| 128 | } // namespace __as_rvalue | 128 | } // namespace __as_rvalue |
lib/libcxx/include/__ranges/chunk_by_view.h+2-2| ... | @@ -205,7 +205,7 @@ namespace views { | ... | @@ -205,7 +205,7 @@ namespace views { |
| 205 | namespace __chunk_by { | 205 | namespace __chunk_by { |
| 206 | struct __fn { | 206 | struct __fn { |
| 207 | template <class _Range, class _Pred> | 207 | template <class _Range, class _Pred> |
| 208 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const | 208 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const |
| 209 | noexcept(noexcept(/**/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))) | 209 | noexcept(noexcept(/**/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))) |
| 210 | -> decltype(/*--*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) { | 210 | -> decltype(/*--*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) { |
| 211 | return /*-------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); | 211 | return /*-------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); |
| ... | @@ -213,7 +213,7 @@ struct __fn { | ... | @@ -213,7 +213,7 @@ struct __fn { |
| 213 | 213 | ||
| 214 | template <class _Pred> | 214 | template <class _Pred> |
| 215 | requires constructible_from<decay_t<_Pred>, _Pred> | 215 | requires constructible_from<decay_t<_Pred>, _Pred> |
| 216 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const | 216 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const |
| 217 | noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { | 217 | noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { |
| 218 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); | 218 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); |
| 219 | } | 219 | } |
lib/libcxx/include/__ranges/common_view.h+4-6| ... | @@ -114,16 +114,14 @@ namespace __common { | ... | @@ -114,16 +114,14 @@ namespace __common { |
| 114 | struct __fn : __range_adaptor_closure<__fn> { | 114 | struct __fn : __range_adaptor_closure<__fn> { |
| 115 | template <class _Range> | 115 | template <class _Range> |
| 116 | requires common_range<_Range> | 116 | requires common_range<_Range> |
| 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const | 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const noexcept( |
| 118 | noexcept(noexcept(views::all(std::forward<_Range>(__range)))) | 118 | noexcept(views::all(std::forward<_Range>(__range)))) -> decltype(views::all(std::forward<_Range>(__range))) { |
| 119 | -> decltype(views::all(std::forward<_Range>(__range))) { | ||
| 120 | return views::all(std::forward<_Range>(__range)); | 119 | return views::all(std::forward<_Range>(__range)); |
| 121 | } | 120 | } |
| 122 | 121 | ||
| 123 | template <class _Range> | 122 | template <class _Range> |
| 124 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const | 123 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const noexcept(noexcept(common_view{ |
| 125 | noexcept(noexcept(common_view{std::forward<_Range>(__range)})) | 124 | std::forward<_Range>(__range)})) -> decltype(common_view{std::forward<_Range>(__range)}) { |
| 126 | -> decltype(common_view{std::forward<_Range>(__range)}) { | ||
| 127 | return common_view{std::forward<_Range>(__range)}; | 125 | return common_view{std::forward<_Range>(__range)}; |
| 128 | } | 126 | } |
| 129 | }; | 127 | }; |
lib/libcxx/include/__ranges/counted.h+2-3| ... | @@ -51,9 +51,8 @@ struct __fn { | ... | @@ -51,9 +51,8 @@ struct __fn { |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | template <random_access_iterator _It> | 53 | template <random_access_iterator _It> |
| 54 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | 54 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_It __it, iter_difference_t<_It> __count) noexcept( |
| 55 | __go(_It __it, iter_difference_t<_It> __count) noexcept(noexcept(subrange(__it, __it + __count))) | 55 | noexcept(subrange(__it, __it + __count))) -> decltype(subrange(__it, __it + __count)) { |
| 56 | -> decltype(subrange(__it, __it + __count)) { | ||
| 57 | return subrange(__it, __it + __count); | 56 | return subrange(__it, __it + __count); |
| 58 | } | 57 | } |
| 59 | 58 |
lib/libcxx/include/__ranges/data.h+3-4| ... | @@ -40,7 +40,7 @@ template <class _Tp> | ... | @@ -40,7 +40,7 @@ template <class _Tp> |
| 40 | concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>; | 40 | concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>; |
| 41 | 41 | ||
| 42 | template <class _Tp> | 42 | template <class _Tp> |
| 43 | concept __member_data = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { | 43 | concept __member_data = __can_borrow<_Tp> && requires(_Tp&& __t) { |
| 44 | { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object; | 44 | { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object; |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| ... | @@ -83,9 +83,8 @@ struct __fn { | ... | @@ -83,9 +83,8 @@ struct __fn { |
| 83 | 83 | ||
| 84 | template <class _Tp> | 84 | template <class _Tp> |
| 85 | requires is_rvalue_reference_v<_Tp&&> | 85 | requires is_rvalue_reference_v<_Tp&&> |
| 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept( |
| 87 | noexcept(noexcept(ranges::data(static_cast<const _Tp&&>(__t)))) | 87 | noexcept(ranges::data(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::data(static_cast<const _Tp&&>(__t))) { |
| 88 | -> decltype(ranges::data(static_cast<const _Tp&&>(__t))) { | ||
| 89 | return ranges::data(static_cast<const _Tp&&>(__t)); | 88 | return ranges::data(static_cast<const _Tp&&>(__t)); |
| 90 | } | 89 | } |
| 91 | }; | 90 | }; |
lib/libcxx/include/__ranges/drop_view.h+8-8| ... | @@ -266,7 +266,7 @@ struct __fn { | ... | @@ -266,7 +266,7 @@ struct __fn { |
| 266 | class _RawRange = remove_cvref_t<_Range>, | 266 | class _RawRange = remove_cvref_t<_Range>, |
| 267 | class _Dist = range_difference_t<_Range>> | 267 | class _Dist = range_difference_t<_Range>> |
| 268 | requires (__is_repeat_specialization<_RawRange> && sized_range<_RawRange>) | 268 | requires (__is_repeat_specialization<_RawRange> && sized_range<_RawRange>) |
| 269 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const | 269 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const |
| 270 | noexcept(noexcept(views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))) | 270 | noexcept(noexcept(views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))) |
| 271 | -> decltype( views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))) | 271 | -> decltype( views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))) |
| 272 | { return views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); } | 272 | { return views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); } |
| ... | @@ -277,7 +277,7 @@ struct __fn { | ... | @@ -277,7 +277,7 @@ struct __fn { |
| 277 | class _RawRange = remove_cvref_t<_Range>, | 277 | class _RawRange = remove_cvref_t<_Range>, |
| 278 | class _Dist = range_difference_t<_Range>> | 278 | class _Dist = range_difference_t<_Range>> |
| 279 | requires (__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>) | 279 | requires (__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>) |
| 280 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI | 280 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 281 | constexpr auto operator()(_Range&& __range, _Np&&) const | 281 | constexpr auto operator()(_Range&& __range, _Np&&) const |
| 282 | noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))) | 282 | noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))) |
| 283 | -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) | 283 | -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) |
| ... | @@ -289,14 +289,14 @@ struct __fn { | ... | @@ -289,14 +289,14 @@ struct __fn { |
| 289 | template <class _Range, convertible_to<range_difference_t<_Range>> _Np, class _RawRange = remove_cvref_t<_Range>> | 289 | template <class _Range, convertible_to<range_difference_t<_Range>> _Np, class _RawRange = remove_cvref_t<_Range>> |
| 290 | // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other | 290 | // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other |
| 291 | // overloads. | 291 | // overloads. |
| 292 | requires( | 292 | requires(!(__is_empty_view<_RawRange> || |
| 293 | !(__is_empty_view<_RawRange> || | ||
| 294 | # if _LIBCPP_STD_VER >= 23 | 293 | # if _LIBCPP_STD_VER >= 23 |
| 295 | __is_repeat_specialization<_RawRange> || | 294 | __is_repeat_specialization<_RawRange> || |
| 296 | # endif | 295 | # endif |
| 297 | (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> && | 296 | (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> && |
| 298 | random_access_range<_RawRange>) || | 297 | random_access_range<_RawRange>) || |
| 299 | (__is_passthrough_specialization<_RawRange> && sized_range<_RawRange> && random_access_range<_RawRange>))) | 298 | (__is_passthrough_specialization<_RawRange> && sized_range<_RawRange> && |
| 299 | random_access_range<_RawRange>))) | ||
| 300 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const | 300 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const |
| 301 | noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))) | 301 | noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))) |
| 302 | -> decltype(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) { | 302 | -> decltype(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) { |
lib/libcxx/include/__ranges/elements_view.h+1-1| ... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
| 16 | #include <__concepts/derived_from.h> | 16 | #include <__concepts/derived_from.h> |
| 17 | #include <__concepts/equality_comparable.h> | 17 | #include <__concepts/equality_comparable.h> |
| 18 | #include <__config> | 18 | #include <__config> |
| 19 | #include <__fwd/get.h> | 19 | #include <__fwd/complex.h> |
| 20 | #include <__iterator/concepts.h> | 20 | #include <__iterator/concepts.h> |
| 21 | #include <__iterator/iterator_traits.h> | 21 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__ranges/access.h> | 22 | #include <__ranges/access.h> |
lib/libcxx/include/__ranges/empty.h+1-1| ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | namespace ranges { | 29 | namespace ranges { |
| 30 | namespace __empty { | 30 | namespace __empty { |
| 31 | template <class _Tp> | 31 | template <class _Tp> |
| 32 | concept __member_empty = __workaround_52970<_Tp> && requires(_Tp&& __t) { bool(__t.empty()); }; | 32 | concept __member_empty = requires(_Tp&& __t) { bool(__t.empty()); }; |
| 33 | 33 | ||
| 34 | template <class _Tp> | 34 | template <class _Tp> |
| 35 | concept __can_invoke_size = !__member_empty<_Tp> && requires(_Tp&& __t) { ranges::size(__t); }; | 35 | concept __can_invoke_size = !__member_empty<_Tp> && requires(_Tp&& __t) { ranges::size(__t); }; |
lib/libcxx/include/__ranges/iota_view.h+5-4| ... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
| 22 | #include <__concepts/semiregular.h> | 22 | #include <__concepts/semiregular.h> |
| 23 | #include <__concepts/totally_ordered.h> | 23 | #include <__concepts/totally_ordered.h> |
| 24 | #include <__config> | 24 | #include <__config> |
| 25 | #include <__functional/ranges_operations.h> | ||
| 26 | #include <__iterator/concepts.h> | 25 | #include <__iterator/concepts.h> |
| 27 | #include <__iterator/incrementable_traits.h> | 26 | #include <__iterator/incrementable_traits.h> |
| 28 | #include <__iterator/iterator_traits.h> | 27 | #include <__iterator/iterator_traits.h> |
| ... | @@ -31,7 +30,7 @@ | ... | @@ -31,7 +30,7 @@ |
| 31 | #include <__ranges/movable_box.h> | 30 | #include <__ranges/movable_box.h> |
| 32 | #include <__ranges/view_interface.h> | 31 | #include <__ranges/view_interface.h> |
| 33 | #include <__type_traits/conditional.h> | 32 | #include <__type_traits/conditional.h> |
| 34 | #include <__type_traits/is_nothrow_copy_constructible.h> | 33 | #include <__type_traits/is_nothrow_constructible.h> |
| 35 | #include <__type_traits/make_unsigned.h> | 34 | #include <__type_traits/make_unsigned.h> |
| 36 | #include <__type_traits/type_identity.h> | 35 | #include <__type_traits/type_identity.h> |
| 37 | #include <__utility/forward.h> | 36 | #include <__utility/forward.h> |
| ... | @@ -313,8 +312,8 @@ public: | ... | @@ -313,8 +312,8 @@ public: |
| 313 | : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) { | 312 | : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) { |
| 314 | // Validate the precondition if possible. | 313 | // Validate the precondition if possible. |
| 315 | if constexpr (totally_ordered_with<_Start, _BoundSentinel>) { | 314 | if constexpr (totally_ordered_with<_Start, _BoundSentinel>) { |
| 316 | _LIBCPP_ASSERT_UNCATEGORIZED( | 315 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 317 | ranges::less_equal()(__value_, __bound_sentinel_), "Precondition violated: value is greater than bound."); | 316 | bool(__value_ <= __bound_sentinel_), "iota_view: bound must be reachable from value"); |
| 318 | } | 317 | } |
| 319 | } | 318 | } |
| 320 | 319 | ||
| ... | @@ -345,6 +344,8 @@ public: | ... | @@ -345,6 +344,8 @@ public: |
| 345 | return __iterator{__bound_sentinel_}; | 344 | return __iterator{__bound_sentinel_}; |
| 346 | } | 345 | } |
| 347 | 346 | ||
| 347 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return __value_ == __bound_sentinel_; } | ||
| 348 | |||
| 348 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 349 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 349 | requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || | 350 | requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || |
| 350 | (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> | 351 | (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> |
lib/libcxx/include/__ranges/lazy_split_view.h+2-2| ... | @@ -403,8 +403,8 @@ template <class _Range, class _Pattern> | ... | @@ -403,8 +403,8 @@ template <class _Range, class _Pattern> |
| 403 | lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>; | 403 | lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>; |
| 404 | 404 | ||
| 405 | template <input_range _Range> | 405 | template <input_range _Range> |
| 406 | lazy_split_view(_Range&&, range_value_t<_Range>) | 406 | lazy_split_view(_Range&&, |
| 407 | -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>; | 407 | range_value_t<_Range>) -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>; |
| 408 | 408 | ||
| 409 | namespace views { | 409 | namespace views { |
| 410 | namespace __lazy_split_view { | 410 | namespace __lazy_split_view { |
lib/libcxx/include/__ranges/movable_box.h-2| ... | @@ -17,8 +17,6 @@ | ... | @@ -17,8 +17,6 @@ |
| 17 | #include <__memory/addressof.h> | 17 | #include <__memory/addressof.h> |
| 18 | #include <__memory/construct_at.h> | 18 | #include <__memory/construct_at.h> |
| 19 | #include <__type_traits/is_nothrow_constructible.h> | 19 | #include <__type_traits/is_nothrow_constructible.h> |
| 20 | #include <__type_traits/is_nothrow_copy_constructible.h> | ||
| 21 | #include <__type_traits/is_nothrow_default_constructible.h> | ||
| 22 | #include <__utility/move.h> | 20 | #include <__utility/move.h> |
| 23 | #include <optional> | 21 | #include <optional> |
| 24 | 22 |
lib/libcxx/include/__ranges/range_adaptor.h+36-17| ... | @@ -19,6 +19,7 @@ | ... | @@ -19,6 +19,7 @@ |
| 19 | #include <__functional/invoke.h> | 19 | #include <__functional/invoke.h> |
| 20 | #include <__ranges/concepts.h> | 20 | #include <__ranges/concepts.h> |
| 21 | #include <__type_traits/decay.h> | 21 | #include <__type_traits/decay.h> |
| 22 | #include <__type_traits/is_class.h> | ||
| 22 | #include <__type_traits/is_nothrow_constructible.h> | 23 | #include <__type_traits/is_nothrow_constructible.h> |
| 23 | #include <__type_traits/remove_cvref.h> | 24 | #include <__type_traits/remove_cvref.h> |
| 24 | #include <__utility/forward.h> | 25 | #include <__utility/forward.h> |
| ... | @@ -35,12 +36,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -35,12 +36,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 36 | ||
| 36 | #if _LIBCPP_STD_VER >= 20 | 37 | #if _LIBCPP_STD_VER >= 20 |
| 37 | 38 | ||
| 39 | namespace ranges { | ||
| 40 | |||
| 38 | // CRTP base that one can derive from in order to be considered a range adaptor closure | 41 | // CRTP base that one can derive from in order to be considered a range adaptor closure |
| 39 | // by the library. When deriving from this class, a pipe operator will be provided to | 42 | // by the library. When deriving from this class, a pipe operator will be provided to |
| 40 | // make the following hold: | 43 | // make the following hold: |
| 41 | // - `x | f` is equivalent to `f(x)` | 44 | // - `x | f` is equivalent to `f(x)` |
| 42 | // - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))` | 45 | // - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))` |
| 43 | template <class _Tp> | 46 | template <class _Tp> |
| 47 | requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> | ||
| 44 | struct __range_adaptor_closure; | 48 | struct __range_adaptor_closure; |
| 45 | 49 | ||
| 46 | // Type that wraps an arbitrary function object and makes it into a range adaptor closure, | 50 | // Type that wraps an arbitrary function object and makes it into a range adaptor closure, |
| ... | @@ -52,27 +56,42 @@ struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_ | ... | @@ -52,27 +56,42 @@ struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_ |
| 52 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t); | 56 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t); |
| 53 | 57 | ||
| 54 | template <class _Tp> | 58 | template <class _Tp> |
| 55 | concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>; | 59 | _Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*); |
| 56 | 60 | ||
| 57 | template <class _Tp> | 61 | template <class _Tp> |
| 58 | struct __range_adaptor_closure { | 62 | concept _RangeAdaptorClosure = !ranges::range<remove_cvref_t<_Tp>> && requires { |
| 59 | template <ranges::viewable_range _View, _RangeAdaptorClosure _Closure> | 63 | // Ensure that `remove_cvref_t<_Tp>` is derived from `__range_adaptor_closure<remove_cvref_t<_Tp>>` and isn't derived |
| 60 | requires same_as<_Tp, remove_cvref_t<_Closure>> && invocable<_Closure, _View> | 64 | // from `__range_adaptor_closure<U>` for any other type `U`. |
| 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) | 65 | { ranges::__derived_from_range_adaptor_closure((remove_cvref_t<_Tp>*)nullptr) } -> same_as<remove_cvref_t<_Tp>>; |
| 62 | operator|(_View&& __view, _Closure&& __closure) noexcept(is_nothrow_invocable_v<_Closure, _View>) { | ||
| 63 | return std::invoke(std::forward<_Closure>(__closure), std::forward<_View>(__view)); | ||
| 64 | } | ||
| 65 | |||
| 66 | template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure> | ||
| 67 | requires same_as<_Tp, remove_cvref_t<_Closure>> && constructible_from<decay_t<_Closure>, _Closure> && | ||
| 68 | constructible_from<decay_t<_OtherClosure>, _OtherClosure> | ||
| 69 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept( | ||
| 70 | is_nothrow_constructible_v<decay_t<_Closure>, _Closure> && | ||
| 71 | is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) { | ||
| 72 | return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); | ||
| 73 | } | ||
| 74 | }; | 66 | }; |
| 75 | 67 | ||
| 68 | template <ranges::range _Range, _RangeAdaptorClosure _Closure> | ||
| 69 | requires invocable<_Closure, _Range> | ||
| 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) | ||
| 71 | operator|(_Range&& __range, _Closure&& __closure) noexcept(is_nothrow_invocable_v<_Closure, _Range>) { | ||
| 72 | return std::invoke(std::forward<_Closure>(__closure), std::forward<_Range>(__range)); | ||
| 73 | } | ||
| 74 | |||
| 75 | template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure> | ||
| 76 | requires constructible_from<decay_t<_Closure>, _Closure> && constructible_from<decay_t<_OtherClosure>, _OtherClosure> | ||
| 77 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept( | ||
| 78 | is_nothrow_constructible_v<decay_t<_Closure>, _Closure> && | ||
| 79 | is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) { | ||
| 80 | return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); | ||
| 81 | } | ||
| 82 | |||
| 83 | template <class _Tp> | ||
| 84 | requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> | ||
| 85 | struct __range_adaptor_closure {}; | ||
| 86 | |||
| 87 | # if _LIBCPP_STD_VER >= 23 | ||
| 88 | template <class _Tp> | ||
| 89 | requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> | ||
| 90 | class range_adaptor_closure : public __range_adaptor_closure<_Tp> {}; | ||
| 91 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 92 | |||
| 93 | } // namespace ranges | ||
| 94 | |||
| 76 | #endif // _LIBCPP_STD_VER >= 20 | 95 | #endif // _LIBCPP_STD_VER >= 20 |
| 77 | 96 | ||
| 78 | _LIBCPP_END_NAMESPACE_STD | 97 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__ranges/rbegin.h+2-3| ... | @@ -36,12 +36,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -36,12 +36,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | namespace ranges { | 36 | namespace ranges { |
| 37 | namespace __rbegin { | 37 | namespace __rbegin { |
| 38 | template <class _Tp> | 38 | template <class _Tp> |
| 39 | concept __member_rbegin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { | 39 | concept __member_rbegin = __can_borrow<_Tp> && requires(_Tp&& __t) { |
| 40 | { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator; | 40 | { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator; |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | void rbegin(auto&) = delete; | 43 | void rbegin() = delete; |
| 44 | void rbegin(const auto&) = delete; | ||
| 45 | 44 | ||
| 46 | template <class _Tp> | 45 | template <class _Tp> |
| 47 | concept __unqualified_rbegin = | 46 | concept __unqualified_rbegin = |
lib/libcxx/include/__ranges/ref_view.h+1-1| ... | @@ -43,7 +43,7 @@ class ref_view : public view_interface<ref_view<_Range>> { | ... | @@ -43,7 +43,7 @@ class ref_view : public view_interface<ref_view<_Range>> { |
| 43 | _Range* __range_; | 43 | _Range* __range_; |
| 44 | 44 | ||
| 45 | static void __fun(_Range&); | 45 | static void __fun(_Range&); |
| 46 | static void __fun(_Range&&) = delete; | 46 | static void __fun(_Range&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276 |
| 47 | 47 | ||
| 48 | public: | 48 | public: |
| 49 | template <class _Tp> | 49 | template <class _Tp> |
lib/libcxx/include/__ranges/rend.h+4-6| ... | @@ -37,13 +37,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -37,13 +37,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | namespace ranges { | 37 | namespace ranges { |
| 38 | namespace __rend { | 38 | namespace __rend { |
| 39 | template <class _Tp> | 39 | template <class _Tp> |
| 40 | concept __member_rend = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { | 40 | concept __member_rend = __can_borrow<_Tp> && requires(_Tp&& __t) { |
| 41 | ranges::rbegin(__t); | 41 | ranges::rbegin(__t); |
| 42 | { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>; | 42 | { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>; |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | void rend(auto&) = delete; | 45 | void rend() = delete; |
| 46 | void rend(const auto&) = delete; | ||
| 47 | 46 | ||
| 48 | template <class _Tp> | 47 | template <class _Tp> |
| 49 | concept __unqualified_rend = | 48 | concept __unqualified_rend = |
| ... | @@ -105,9 +104,8 @@ struct __fn { | ... | @@ -105,9 +104,8 @@ struct __fn { |
| 105 | 104 | ||
| 106 | template <class _Tp> | 105 | template <class _Tp> |
| 107 | requires is_rvalue_reference_v<_Tp&&> | 106 | requires is_rvalue_reference_v<_Tp&&> |
| 108 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | 107 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept( |
| 109 | noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t)))) | 108 | noexcept(ranges::rend(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::rend(static_cast<const _Tp&&>(__t))) { |
| 110 | -> decltype(ranges::rend(static_cast<const _Tp&&>(__t))) { | ||
| 111 | return ranges::rend(static_cast<const _Tp&&>(__t)); | 109 | return ranges::rend(static_cast<const _Tp&&>(__t)); |
| 112 | } | 110 | } |
| 113 | }; | 111 | }; |
lib/libcxx/include/__ranges/repeat_view.h+9-8| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP___RANGES_REPEAT_VIEW_H | 10 | #ifndef _LIBCPP___RANGES_REPEAT_VIEW_H |
| 11 | #define _LIBCPP___RANGES_REPEAT_VIEW_H | 11 | #define _LIBCPP___RANGES_REPEAT_VIEW_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 13 | #include <__concepts/constructible.h> | 14 | #include <__concepts/constructible.h> |
| 14 | #include <__concepts/same_as.h> | 15 | #include <__concepts/same_as.h> |
| 15 | #include <__concepts/semiregular.h> | 16 | #include <__concepts/semiregular.h> |
| ... | @@ -21,6 +22,7 @@ | ... | @@ -21,6 +22,7 @@ |
| 21 | #include <__ranges/iota_view.h> | 22 | #include <__ranges/iota_view.h> |
| 22 | #include <__ranges/movable_box.h> | 23 | #include <__ranges/movable_box.h> |
| 23 | #include <__ranges/view_interface.h> | 24 | #include <__ranges/view_interface.h> |
| 25 | #include <__type_traits/decay.h> | ||
| 24 | #include <__type_traits/is_object.h> | 26 | #include <__type_traits/is_object.h> |
| 25 | #include <__type_traits/make_unsigned.h> | 27 | #include <__type_traits/make_unsigned.h> |
| 26 | #include <__type_traits/remove_cv.h> | 28 | #include <__type_traits/remove_cv.h> |
| ... | @@ -126,8 +128,8 @@ private: | ... | @@ -126,8 +128,8 @@ private: |
| 126 | _LIBCPP_NO_UNIQUE_ADDRESS _Bound __bound_ = _Bound(); | 128 | _LIBCPP_NO_UNIQUE_ADDRESS _Bound __bound_ = _Bound(); |
| 127 | }; | 129 | }; |
| 128 | 130 | ||
| 129 | template <class _Tp, class _Bound> | 131 | template <class _Tp, class _Bound = unreachable_sentinel_t> |
| 130 | repeat_view(_Tp, _Bound) -> repeat_view<_Tp, _Bound>; | 132 | repeat_view(_Tp, _Bound = _Bound()) -> repeat_view<_Tp, _Bound>; |
| 131 | 133 | ||
| 132 | // [range.repeat.iterator] | 134 | // [range.repeat.iterator] |
| 133 | template <move_constructible _Tp, semiregular _Bound> | 135 | template <move_constructible _Tp, semiregular _Bound> |
| ... | @@ -228,14 +230,13 @@ namespace views { | ... | @@ -228,14 +230,13 @@ namespace views { |
| 228 | namespace __repeat { | 230 | namespace __repeat { |
| 229 | struct __fn { | 231 | struct __fn { |
| 230 | template <class _Tp> | 232 | template <class _Tp> |
| 231 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __value) const | 233 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Tp&& __value) |
| 232 | noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value)))) | 234 | noexcept(noexcept(ranges::repeat_view<decay_t<_Tp>>(std::forward<_Tp>(__value)))) |
| 233 | -> decltype( ranges::repeat_view(std::forward<_Tp>(__value))) | 235 | -> decltype( ranges::repeat_view<decay_t<_Tp>>(std::forward<_Tp>(__value))) |
| 234 | { return ranges::repeat_view(std::forward<_Tp>(__value)); } | 236 | { return ranges::repeat_view<decay_t<_Tp>>(std::forward<_Tp>(__value)); } |
| 235 | |||
| 236 | 237 | ||
| 237 | template <class _Tp, class _Bound> | 238 | template <class _Tp, class _Bound> |
| 238 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __value, _Bound&& __bound_sentinel) const | 239 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Tp&& __value, _Bound&& __bound_sentinel) |
| 239 | noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)))) | 240 | noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)))) |
| 240 | -> decltype( ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel))) | 241 | -> decltype( ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel))) |
| 241 | { return ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)); } | 242 | { return ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)); } |
lib/libcxx/include/__ranges/reverse_view.h+2-3| ... | @@ -181,9 +181,8 @@ struct __fn : __range_adaptor_closure<__fn> { | ... | @@ -181,9 +181,8 @@ struct __fn : __range_adaptor_closure<__fn> { |
| 181 | template <class _Range> | 181 | template <class _Range> |
| 182 | requires(!__is_reverse_view<remove_cvref_t<_Range>> && !__is_sized_reverse_subrange<remove_cvref_t<_Range>> && | 182 | requires(!__is_reverse_view<remove_cvref_t<_Range>> && !__is_sized_reverse_subrange<remove_cvref_t<_Range>> && |
| 183 | !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>) | 183 | !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>) |
| 184 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const | 184 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const noexcept(noexcept(reverse_view{ |
| 185 | noexcept(noexcept(reverse_view{std::forward<_Range>(__range)})) | 185 | std::forward<_Range>(__range)})) -> decltype(reverse_view{std::forward<_Range>(__range)}) { |
| 186 | -> decltype(reverse_view{std::forward<_Range>(__range)}) { | ||
| 187 | return reverse_view{std::forward<_Range>(__range)}; | 186 | return reverse_view{std::forward<_Range>(__range)}; |
| 188 | } | 187 | } |
| 189 | }; | 188 | }; |
lib/libcxx/include/__ranges/single_view.h+2| ... | @@ -70,6 +70,8 @@ public: | ... | @@ -70,6 +70,8 @@ public: |
| 70 | 70 | ||
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* end() const noexcept { return data() + 1; } | 71 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* end() const noexcept { return data() + 1; } |
| 72 | 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return false; } | ||
| 74 | |||
| 73 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 1; } | 75 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 1; } |
| 74 | 76 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data() noexcept { return __value_.operator->(); } | 77 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data() noexcept { return __value_.operator->(); } |
lib/libcxx/include/__ranges/size.h+2-3| ... | @@ -41,14 +41,13 @@ inline constexpr bool disable_sized_range = false; | ... | @@ -41,14 +41,13 @@ inline constexpr bool disable_sized_range = false; |
| 41 | 41 | ||
| 42 | namespace ranges { | 42 | namespace ranges { |
| 43 | namespace __size { | 43 | namespace __size { |
| 44 | void size(auto&) = delete; | 44 | void size() = delete; |
| 45 | void size(const auto&) = delete; | ||
| 46 | 45 | ||
| 47 | template <class _Tp> | 46 | template <class _Tp> |
| 48 | concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; | 47 | concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; |
| 49 | 48 | ||
| 50 | template <class _Tp> | 49 | template <class _Tp> |
| 51 | concept __member_size = __size_enabled<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { | 50 | concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) { |
| 52 | { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like; | 51 | { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like; |
| 53 | }; | 52 | }; |
| 54 | 53 |
lib/libcxx/include/__ranges/split_view.h+2-2| ... | @@ -200,7 +200,7 @@ namespace __split_view { | ... | @@ -200,7 +200,7 @@ namespace __split_view { |
| 200 | struct __fn { | 200 | struct __fn { |
| 201 | // clang-format off | 201 | // clang-format off |
| 202 | template <class _Range, class _Pattern> | 202 | template <class _Range, class _Pattern> |
| 203 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI | 203 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 204 | constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const | 204 | constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const |
| 205 | noexcept(noexcept(split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))) | 205 | noexcept(noexcept(split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))) |
| 206 | -> decltype( split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) | 206 | -> decltype( split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) |
| ... | @@ -209,7 +209,7 @@ struct __fn { | ... | @@ -209,7 +209,7 @@ struct __fn { |
| 209 | 209 | ||
| 210 | template <class _Pattern> | 210 | template <class _Pattern> |
| 211 | requires constructible_from<decay_t<_Pattern>, _Pattern> | 211 | requires constructible_from<decay_t<_Pattern>, _Pattern> |
| 212 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const | 212 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const |
| 213 | noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) { | 213 | noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) { |
| 214 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); | 214 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); |
| 215 | } | 215 | } |
lib/libcxx/include/__ranges/subrange.h+8-11| ... | @@ -17,7 +17,6 @@ | ... | @@ -17,7 +17,6 @@ |
| 17 | #include <__concepts/derived_from.h> | 17 | #include <__concepts/derived_from.h> |
| 18 | #include <__concepts/different_from.h> | 18 | #include <__concepts/different_from.h> |
| 19 | #include <__config> | 19 | #include <__config> |
| 20 | #include <__fwd/get.h> | ||
| 21 | #include <__fwd/subrange.h> | 20 | #include <__fwd/subrange.h> |
| 22 | #include <__iterator/advance.h> | 21 | #include <__iterator/advance.h> |
| 23 | #include <__iterator/concepts.h> | 22 | #include <__iterator/concepts.h> |
| ... | @@ -29,8 +28,8 @@ | ... | @@ -29,8 +28,8 @@ |
| 29 | #include <__ranges/enable_borrowed_range.h> | 28 | #include <__ranges/enable_borrowed_range.h> |
| 30 | #include <__ranges/size.h> | 29 | #include <__ranges/size.h> |
| 31 | #include <__ranges/view_interface.h> | 30 | #include <__ranges/view_interface.h> |
| 32 | #include <__tuple/pair_like.h> | ||
| 33 | #include <__tuple/tuple_element.h> | 31 | #include <__tuple/tuple_element.h> |
| 32 | #include <__tuple/tuple_like_no_subrange.h> | ||
| 34 | #include <__tuple/tuple_size.h> | 33 | #include <__tuple/tuple_size.h> |
| 35 | #include <__type_traits/conditional.h> | 34 | #include <__type_traits/conditional.h> |
| 36 | #include <__type_traits/decay.h> | 35 | #include <__type_traits/decay.h> |
| ... | @@ -65,7 +64,7 @@ concept __convertible_to_non_slicing = | ... | @@ -65,7 +64,7 @@ concept __convertible_to_non_slicing = |
| 65 | 64 | ||
| 66 | template <class _Pair, class _Iter, class _Sent> | 65 | template <class _Pair, class _Iter, class _Sent> |
| 67 | concept __pair_like_convertible_from = | 66 | concept __pair_like_convertible_from = |
| 68 | !range<_Pair> && __pair_like<_Pair> && constructible_from<_Pair, _Iter, _Sent> && | 67 | !range<_Pair> && __pair_like_no_subrange<_Pair> && constructible_from<_Pair, _Iter, _Sent> && |
| 69 | __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> && convertible_to<_Sent, tuple_element_t<1, _Pair>>; | 68 | __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> && convertible_to<_Sent, tuple_element_t<1, _Pair>>; |
| 70 | 69 | ||
| 71 | template <input_or_output_iterator _Iter, | 70 | template <input_or_output_iterator _Iter, |
| ... | @@ -126,8 +125,7 @@ public: | ... | @@ -126,8 +125,7 @@ public: |
| 126 | requires(_Kind == subrange_kind::sized) | 125 | requires(_Kind == subrange_kind::sized) |
| 127 | : subrange(ranges::begin(__range), ranges::end(__range), __n) {} | 126 | : subrange(ranges::begin(__range), ranges::end(__range), __n) {} |
| 128 | 127 | ||
| 129 | template <__different_from<subrange> _Pair> | 128 | template <__pair_like_convertible_from<const _Iter&, const _Sent&> _Pair> |
| 130 | requires __pair_like_convertible_from<_Pair, const _Iter&, const _Sent&> | ||
| 131 | _LIBCPP_HIDE_FROM_ABI constexpr operator _Pair() const { | 129 | _LIBCPP_HIDE_FROM_ABI constexpr operator _Pair() const { |
| 132 | return _Pair(__begin_, __end_); | 130 | return _Pair(__begin_, __end_); |
| 133 | } | 131 | } |
| ... | @@ -202,12 +200,11 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent> | ... | @@ -202,12 +200,11 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent> |
| 202 | subrange(_Iter, _Sent, make_unsigned_t<iter_difference_t<_Iter>>) -> subrange<_Iter, _Sent, subrange_kind::sized>; | 200 | subrange(_Iter, _Sent, make_unsigned_t<iter_difference_t<_Iter>>) -> subrange<_Iter, _Sent, subrange_kind::sized>; |
| 203 | 201 | ||
| 204 | template <borrowed_range _Range> | 202 | template <borrowed_range _Range> |
| 205 | subrange(_Range&&) | 203 | subrange(_Range&&) -> subrange<iterator_t<_Range>, |
| 206 | -> subrange<iterator_t<_Range>, | 204 | sentinel_t<_Range>, |
| 207 | sentinel_t<_Range>, | 205 | (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>) |
| 208 | (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>) | 206 | ? subrange_kind::sized |
| 209 | ? subrange_kind::sized | 207 | : subrange_kind::unsized>; |
| 210 | : subrange_kind::unsized>; | ||
| 211 | 208 | ||
| 212 | template <borrowed_range _Range> | 209 | template <borrowed_range _Range> |
| 213 | subrange(_Range&&, make_unsigned_t<range_difference_t<_Range>>) | 210 | subrange(_Range&&, make_unsigned_t<range_difference_t<_Range>>) |
lib/libcxx/include/__ranges/take_view.h+2-2| ... | @@ -308,7 +308,7 @@ struct __fn { | ... | @@ -308,7 +308,7 @@ struct __fn { |
| 308 | class _RawRange = remove_cvref_t<_Range>, | 308 | class _RawRange = remove_cvref_t<_Range>, |
| 309 | class _Dist = range_difference_t<_Range>> | 309 | class _Dist = range_difference_t<_Range>> |
| 310 | requires(__is_repeat_specialization<_RawRange> && sized_range<_RawRange>) | 310 | requires(__is_repeat_specialization<_RawRange> && sized_range<_RawRange>) |
| 311 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const | 311 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const |
| 312 | noexcept(noexcept(views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))) | 312 | noexcept(noexcept(views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))) |
| 313 | -> decltype( views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))) | 313 | -> decltype( views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))) |
| 314 | { return views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); } | 314 | { return views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); } |
| ... | @@ -319,7 +319,7 @@ struct __fn { | ... | @@ -319,7 +319,7 @@ struct __fn { |
| 319 | class _RawRange = remove_cvref_t<_Range>, | 319 | class _RawRange = remove_cvref_t<_Range>, |
| 320 | class _Dist = range_difference_t<_Range>> | 320 | class _Dist = range_difference_t<_Range>> |
| 321 | requires(__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>) | 321 | requires(__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>) |
| 322 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const | 322 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const |
| 323 | noexcept(noexcept(views::repeat(*__range.__value_, static_cast<_Dist>(__n)))) | 323 | noexcept(noexcept(views::repeat(*__range.__value_, static_cast<_Dist>(__n)))) |
| 324 | -> decltype( views::repeat(*__range.__value_, static_cast<_Dist>(__n))) | 324 | -> decltype( views::repeat(*__range.__value_, static_cast<_Dist>(__n))) |
| 325 | { return views::repeat(*__range.__value_, static_cast<_Dist>(__n)); } | 325 | { return views::repeat(*__range.__value_, static_cast<_Dist>(__n)); } |
lib/libcxx/include/__ranges/to.h+8-7| ... | @@ -24,6 +24,7 @@ | ... | @@ -24,6 +24,7 @@ |
| 24 | #include <__ranges/concepts.h> | 24 | #include <__ranges/concepts.h> |
| 25 | #include <__ranges/from_range.h> | 25 | #include <__ranges/from_range.h> |
| 26 | #include <__ranges/range_adaptor.h> | 26 | #include <__ranges/range_adaptor.h> |
| 27 | #include <__ranges/ref_view.h> | ||
| 27 | #include <__ranges/size.h> | 28 | #include <__ranges/size.h> |
| 28 | #include <__ranges/transform_view.h> | 29 | #include <__ranges/transform_view.h> |
| 29 | #include <__type_traits/add_pointer.h> | 30 | #include <__type_traits/add_pointer.h> |
| ... | @@ -85,7 +86,7 @@ concept __always_false = false; | ... | @@ -85,7 +86,7 @@ concept __always_false = false; |
| 85 | // `ranges::to` base template -- the `_Container` type is a simple type template parameter. | 86 | // `ranges::to` base template -- the `_Container` type is a simple type template parameter. |
| 86 | template <class _Container, input_range _Range, class... _Args> | 87 | template <class _Container, input_range _Range, class... _Args> |
| 87 | requires(!view<_Container>) | 88 | requires(!view<_Container>) |
| 88 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __range, _Args&&... __args) { | 89 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __range, _Args&&... __args) { |
| 89 | // Mandates: C is a cv-unqualified class type. | 90 | // Mandates: C is a cv-unqualified class type. |
| 90 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); | 91 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); |
| 91 | static_assert( | 92 | static_assert( |
| ... | @@ -129,7 +130,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __r | ... | @@ -129,7 +130,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __r |
| 129 | // Try the recursive case. | 130 | // Try the recursive case. |
| 130 | } else if constexpr (input_range<range_reference_t<_Range>>) { | 131 | } else if constexpr (input_range<range_reference_t<_Range>>) { |
| 131 | return ranges::to<_Container>( | 132 | return ranges::to<_Container>( |
| 132 | __range | views::transform([](auto&& __elem) { | 133 | ref_view(__range) | views::transform([](auto&& __elem) { |
| 133 | return ranges::to<range_value_t<_Container>>(std::forward<decltype(__elem)>(__elem)); | 134 | return ranges::to<range_value_t<_Container>>(std::forward<decltype(__elem)>(__elem)); |
| 134 | }), | 135 | }), |
| 135 | std::forward<_Args>(__args)...); | 136 | std::forward<_Args>(__args)...); |
| ... | @@ -192,7 +193,7 @@ struct _Deducer { | ... | @@ -192,7 +193,7 @@ struct _Deducer { |
| 192 | // `ranges::to` specialization -- `_Container` is a template template parameter requiring deduction to figure out the | 193 | // `ranges::to` specialization -- `_Container` is a template template parameter requiring deduction to figure out the |
| 193 | // container element type. | 194 | // container element type. |
| 194 | template <template <class...> class _Container, input_range _Range, class... _Args> | 195 | template <template <class...> class _Container, input_range _Range, class... _Args> |
| 195 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range, _Args&&... __args) { | 196 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range, _Args&&... __args) { |
| 196 | using _DeduceExpr = typename _Deducer<_Container, _Range, _Args...>::type; | 197 | using _DeduceExpr = typename _Deducer<_Container, _Range, _Args...>::type; |
| 197 | return ranges::to<_DeduceExpr>(std::forward<_Range>(__range), std::forward<_Args>(__args)...); | 198 | return ranges::to<_DeduceExpr>(std::forward<_Range>(__range), std::forward<_Args>(__args)...); |
| 198 | } | 199 | } |
| ... | @@ -201,13 +202,13 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range, | ... | @@ -201,13 +202,13 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range, |
| 201 | // parameter. | 202 | // parameter. |
| 202 | template <class _Container, class... _Args> | 203 | template <class _Container, class... _Args> |
| 203 | requires(!view<_Container>) | 204 | requires(!view<_Container>) |
| 204 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) { | 205 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) { |
| 205 | // Mandates: C is a cv-unqualified class type. | 206 | // Mandates: C is a cv-unqualified class type. |
| 206 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); | 207 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); |
| 207 | static_assert( | 208 | static_assert( |
| 208 | !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); | 209 | !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); |
| 209 | 210 | ||
| 210 | auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) | 211 | auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static |
| 211 | requires requires { // | 212 | requires requires { // |
| 212 | /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); | 213 | /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); |
| 213 | } | 214 | } |
| ... | @@ -219,11 +220,11 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) | ... | @@ -219,11 +220,11 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) |
| 219 | // Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template | 220 | // Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template |
| 220 | // parameter. | 221 | // parameter. |
| 221 | template <template <class...> class _Container, class... _Args> | 222 | template <template <class...> class _Container, class... _Args> |
| 222 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) { | 223 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) { |
| 223 | // clang-format off | 224 | // clang-format off |
| 224 | auto __to_func = []<input_range _Range, class... _Tail, | 225 | auto __to_func = []<input_range _Range, class... _Tail, |
| 225 | class _DeducedExpr = typename _Deducer<_Container, _Range, _Tail...>::type> | 226 | class _DeducedExpr = typename _Deducer<_Container, _Range, _Tail...>::type> |
| 226 | (_Range&& __range, _Tail&& ... __tail) | 227 | (_Range&& __range, _Tail&& ... __tail) static |
| 227 | requires requires { // | 228 | requires requires { // |
| 228 | /**/ ranges::to<_DeducedExpr>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); | 229 | /**/ ranges::to<_DeducedExpr>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); |
| 229 | } | 230 | } |
lib/libcxx/include/__ranges/transform_view.h-7| ... | @@ -326,13 +326,6 @@ public: | ... | @@ -326,13 +326,6 @@ public: |
| 326 | { | 326 | { |
| 327 | return __x.__current_ - __y.__current_; | 327 | return __x.__current_ - __y.__current_; |
| 328 | } | 328 | } |
| 329 | |||
| 330 | _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __i) noexcept(noexcept(*__i)) { | ||
| 331 | if constexpr (is_lvalue_reference_v<decltype(*__i)>) | ||
| 332 | return std::move(*__i); | ||
| 333 | else | ||
| 334 | return *__i; | ||
| 335 | } | ||
| 336 | }; | 329 | }; |
| 337 | 330 | ||
| 338 | # if _LIBCPP_STD_VER >= 23 | 331 | # if _LIBCPP_STD_VER >= 23 |
lib/libcxx/include/__ranges/view_interface.h+13-4| ... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
| 21 | #include <__ranges/access.h> | 21 | #include <__ranges/access.h> |
| 22 | #include <__ranges/concepts.h> | 22 | #include <__ranges/concepts.h> |
| 23 | #include <__ranges/empty.h> | 23 | #include <__ranges/empty.h> |
| 24 | #include <__ranges/size.h> | ||
| 24 | #include <__type_traits/is_class.h> | 25 | #include <__type_traits/is_class.h> |
| 25 | #include <__type_traits/make_unsigned.h> | 26 | #include <__type_traits/make_unsigned.h> |
| 26 | #include <__type_traits/remove_cv.h> | 27 | #include <__type_traits/remove_cv.h> |
| ... | @@ -51,16 +52,24 @@ class view_interface { | ... | @@ -51,16 +52,24 @@ class view_interface { |
| 51 | public: | 52 | public: |
| 52 | template <class _D2 = _Derived> | 53 | template <class _D2 = _Derived> |
| 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() |
| 54 | requires forward_range<_D2> | 55 | requires sized_range<_D2> || forward_range<_D2> |
| 55 | { | 56 | { |
| 56 | return ranges::begin(__derived()) == ranges::end(__derived()); | 57 | if constexpr (sized_range<_D2>) { |
| 58 | return ranges::size(__derived()) == 0; | ||
| 59 | } else { | ||
| 60 | return ranges::begin(__derived()) == ranges::end(__derived()); | ||
| 61 | } | ||
| 57 | } | 62 | } |
| 58 | 63 | ||
| 59 | template <class _D2 = _Derived> | 64 | template <class _D2 = _Derived> |
| 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const |
| 61 | requires forward_range<const _D2> | 66 | requires sized_range<const _D2> || forward_range<const _D2> |
| 62 | { | 67 | { |
| 63 | return ranges::begin(__derived()) == ranges::end(__derived()); | 68 | if constexpr (sized_range<const _D2>) { |
| 69 | return ranges::size(__derived()) == 0; | ||
| 70 | } else { | ||
| 71 | return ranges::begin(__derived()) == ranges::end(__derived()); | ||
| 72 | } | ||
| 64 | } | 73 | } |
| 65 | 74 | ||
| 66 | template <class _D2 = _Derived> | 75 | template <class _D2 = _Derived> |
lib/libcxx/include/__ranges/zip_view.h+6-5| ... | @@ -30,12 +30,13 @@ | ... | @@ -30,12 +30,13 @@ |
| 30 | #include <__ranges/enable_borrowed_range.h> | 30 | #include <__ranges/enable_borrowed_range.h> |
| 31 | #include <__ranges/size.h> | 31 | #include <__ranges/size.h> |
| 32 | #include <__ranges/view_interface.h> | 32 | #include <__ranges/view_interface.h> |
| 33 | #include <__type_traits/is_nothrow_move_constructible.h> | 33 | #include <__type_traits/is_nothrow_constructible.h> |
| 34 | #include <__type_traits/make_unsigned.h> | 34 | #include <__type_traits/make_unsigned.h> |
| 35 | #include <__utility/declval.h> | 35 | #include <__utility/declval.h> |
| 36 | #include <__utility/forward.h> | 36 | #include <__utility/forward.h> |
| 37 | #include <__utility/integer_sequence.h> | 37 | #include <__utility/integer_sequence.h> |
| 38 | #include <__utility/move.h> | 38 | #include <__utility/move.h> |
| 39 | #include <__utility/pair.h> | ||
| 39 | #include <tuple> | 40 | #include <tuple> |
| 40 | 41 | ||
| 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -489,12 +490,12 @@ namespace views { | ... | @@ -489,12 +490,12 @@ namespace views { |
| 489 | namespace __zip { | 490 | namespace __zip { |
| 490 | 491 | ||
| 491 | struct __fn { | 492 | struct __fn { |
| 492 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; } | 493 | _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()() noexcept { return empty_view<tuple<>>{}; } |
| 493 | 494 | ||
| 494 | template <class... _Ranges> | 495 | template <class... _Ranges> |
| 495 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const | 496 | _LIBCPP_HIDE_FROM_ABI static constexpr auto |
| 496 | noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...))) | 497 | operator()(_Ranges&&... __rs) noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...))) |
| 497 | -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) { | 498 | -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) { |
| 498 | return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...); | 499 | return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...); |
| 499 | } | 500 | } |
| 500 | }; | 501 | }; |
lib/libcxx/include/__split_buffer+17-7| ... | @@ -24,13 +24,14 @@ | ... | @@ -24,13 +24,14 @@ |
| 24 | #include <__memory/pointer_traits.h> | 24 | #include <__memory/pointer_traits.h> |
| 25 | #include <__memory/swap_allocator.h> | 25 | #include <__memory/swap_allocator.h> |
| 26 | #include <__type_traits/add_lvalue_reference.h> | 26 | #include <__type_traits/add_lvalue_reference.h> |
| 27 | #include <__type_traits/conditional.h> | ||
| 27 | #include <__type_traits/enable_if.h> | 28 | #include <__type_traits/enable_if.h> |
| 28 | #include <__type_traits/integral_constant.h> | 29 | #include <__type_traits/integral_constant.h> |
| 29 | #include <__type_traits/is_nothrow_default_constructible.h> | 30 | #include <__type_traits/is_nothrow_assignable.h> |
| 30 | #include <__type_traits/is_nothrow_move_assignable.h> | 31 | #include <__type_traits/is_nothrow_constructible.h> |
| 31 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 32 | #include <__type_traits/is_swappable.h> | 32 | #include <__type_traits/is_swappable.h> |
| 33 | #include <__type_traits/is_trivially_destructible.h> | 33 | #include <__type_traits/is_trivially_destructible.h> |
| 34 | #include <__type_traits/is_trivially_relocatable.h> | ||
| 34 | #include <__type_traits/remove_reference.h> | 35 | #include <__type_traits/remove_reference.h> |
| 35 | #include <__utility/forward.h> | 36 | #include <__utility/forward.h> |
| 36 | #include <__utility/move.h> | 37 | #include <__utility/move.h> |
| ... | @@ -65,6 +66,15 @@ public: | ... | @@ -65,6 +66,15 @@ public: |
| 65 | using iterator = pointer; | 66 | using iterator = pointer; |
| 66 | using const_iterator = const_pointer; | 67 | using const_iterator = const_pointer; |
| 67 | 68 | ||
| 69 | // A __split_buffer contains the following members which may be trivially relocatable: | ||
| 70 | // - pointer: may be trivially relocatable, so it's checked | ||
| 71 | // - allocator_type: may be trivially relocatable, so it's checked | ||
| 72 | // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are. | ||
| 73 | using __trivially_relocatable = __conditional_t< | ||
| 74 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | ||
| 75 | __split_buffer, | ||
| 76 | void>; | ||
| 77 | |||
| 68 | pointer __first_; | 78 | pointer __first_; |
| 69 | pointer __begin_; | 79 | pointer __begin_; |
| 70 | pointer __end_; | 80 | pointer __end_; |
| ... | @@ -188,7 +198,7 @@ public: | ... | @@ -188,7 +198,7 @@ public: |
| 188 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; | 198 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; |
| 189 | 199 | ||
| 190 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) | 200 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) |
| 191 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value); | 201 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>); |
| 192 | 202 | ||
| 193 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | 203 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; |
| 194 | 204 | ||
| ... | @@ -201,8 +211,8 @@ private: | ... | @@ -201,8 +211,8 @@ private: |
| 201 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} | 211 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} |
| 202 | 212 | ||
| 203 | struct _ConstructTransaction { | 213 | struct _ConstructTransaction { |
| 204 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction( | 214 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 205 | pointer* __p, size_type __n) _NOEXCEPT | 215 | _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT |
| 206 | : __pos_(*__p), | 216 | : __pos_(*__p), |
| 207 | __end_(*__p + __n), | 217 | __end_(*__p + __n), |
| 208 | __dest_(__p) {} | 218 | __dest_(__p) {} |
| ... | @@ -410,7 +420,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) | ... | @@ -410,7 +420,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) |
| 410 | 420 | ||
| 411 | template <class _Tp, class _Allocator> | 421 | template <class _Tp, class _Allocator> |
| 412 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) | 422 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) |
| 413 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value) { | 423 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) { |
| 414 | std::swap(__first_, __x.__first_); | 424 | std::swap(__first_, __x.__first_); |
| 415 | std::swap(__begin_, __x.__begin_); | 425 | std::swap(__begin_, __x.__begin_); |
| 416 | std::swap(__end_, __x.__end_); | 426 | std::swap(__end_, __x.__end_); |
lib/libcxx/include/__stop_token/stop_callback.h+4-6| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H | 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H |
| 11 | #define _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H | 11 | #define _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__concepts/constructible.h> | 13 | #include <__concepts/constructible.h> |
| 15 | #include <__concepts/destructible.h> | 14 | #include <__concepts/destructible.h> |
| 16 | #include <__concepts/invocable.h> | 15 | #include <__concepts/invocable.h> |
| ... | @@ -21,6 +20,7 @@ | ... | @@ -21,6 +20,7 @@ |
| 21 | #include <__type_traits/is_nothrow_constructible.h> | 20 | #include <__type_traits/is_nothrow_constructible.h> |
| 22 | #include <__utility/forward.h> | 21 | #include <__utility/forward.h> |
| 23 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 23 | #include <__utility/private_constructor_tag.h> | ||
| 24 | 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | # pragma GCC system_header | 26 | # pragma GCC system_header |
| ... | @@ -49,13 +49,13 @@ public: | ... | @@ -49,13 +49,13 @@ public: |
| 49 | requires constructible_from<_Callback, _Cb> | 49 | requires constructible_from<_Callback, _Cb> |
| 50 | _LIBCPP_HIDE_FROM_ABI explicit stop_callback(const stop_token& __st, | 50 | _LIBCPP_HIDE_FROM_ABI explicit stop_callback(const stop_token& __st, |
| 51 | _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>) | 51 | _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>) |
| 52 | : stop_callback(__private_tag{}, __st.__state_, std::forward<_Cb>(__cb)) {} | 52 | : stop_callback(__private_constructor_tag{}, __st.__state_, std::forward<_Cb>(__cb)) {} |
| 53 | 53 | ||
| 54 | template <class _Cb> | 54 | template <class _Cb> |
| 55 | requires constructible_from<_Callback, _Cb> | 55 | requires constructible_from<_Callback, _Cb> |
| 56 | _LIBCPP_HIDE_FROM_ABI explicit stop_callback(stop_token&& __st, | 56 | _LIBCPP_HIDE_FROM_ABI explicit stop_callback(stop_token&& __st, |
| 57 | _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>) | 57 | _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>) |
| 58 | : stop_callback(__private_tag{}, std::move(__st.__state_), std::forward<_Cb>(__cb)) {} | 58 | : stop_callback(__private_constructor_tag{}, std::move(__st.__state_), std::forward<_Cb>(__cb)) {} |
| 59 | 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI ~stop_callback() { | 60 | _LIBCPP_HIDE_FROM_ABI ~stop_callback() { |
| 61 | if (__state_) { | 61 | if (__state_) { |
| ... | @@ -74,10 +74,8 @@ private: | ... | @@ -74,10 +74,8 @@ private: |
| 74 | 74 | ||
| 75 | friend __stop_callback_base; | 75 | friend __stop_callback_base; |
| 76 | 76 | ||
| 77 | struct __private_tag {}; | ||
| 78 | |||
| 79 | template <class _StatePtr, class _Cb> | 77 | template <class _StatePtr, class _Cb> |
| 80 | _LIBCPP_HIDE_FROM_ABI explicit stop_callback(__private_tag, _StatePtr&& __state, _Cb&& __cb) noexcept( | 78 | _LIBCPP_HIDE_FROM_ABI explicit stop_callback(__private_constructor_tag, _StatePtr&& __state, _Cb&& __cb) noexcept( |
| 81 | is_nothrow_constructible_v<_Callback, _Cb>) | 79 | is_nothrow_constructible_v<_Callback, _Cb>) |
| 82 | : __stop_callback_base([](__stop_callback_base* __cb_base) noexcept { | 80 | : __stop_callback_base([](__stop_callback_base* __cb_base) noexcept { |
| 83 | // stop callback is supposed to only be called once | 81 | // stop callback is supposed to only be called once |
lib/libcxx/include/__stop_token/stop_source.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_SOURCE_H | 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_SOURCE_H |
| 11 | #define _LIBCPP___STOP_TOKEN_STOP_SOURCE_H | 11 | #define _LIBCPP___STOP_TOKEN_STOP_SOURCE_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__stop_token/intrusive_shared_ptr.h> | 14 | #include <__stop_token/intrusive_shared_ptr.h> |
| 16 | #include <__stop_token/stop_state.h> | 15 | #include <__stop_token/stop_state.h> |
lib/libcxx/include/__stop_token/stop_state.h+1-1| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_STATE_H | 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_STATE_H |
| 11 | #define _LIBCPP___STOP_TOKEN_STOP_STATE_H | 11 | #define _LIBCPP___STOP_TOKEN_STOP_STATE_H |
| 12 | 12 | ||
| 13 | #include <__availability> | 13 | #include <__assert> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__stop_token/atomic_unique_lock.h> | 15 | #include <__stop_token/atomic_unique_lock.h> |
| 16 | #include <__stop_token/intrusive_list_view.h> | 16 | #include <__stop_token/intrusive_list_view.h> |
lib/libcxx/include/__stop_token/stop_token.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H | 10 | #ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H |
| 11 | #define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H | 11 | #define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__stop_token/intrusive_shared_ptr.h> | 14 | #include <__stop_token/intrusive_shared_ptr.h> |
| 16 | #include <__stop_token/stop_state.h> | 15 | #include <__stop_token/stop_state.h> |
lib/libcxx/include/__string/char_traits.h+88-346| ... | @@ -9,14 +9,16 @@ | ... | @@ -9,14 +9,16 @@ |
| 9 | #ifndef _LIBCPP___STRING_CHAR_TRAITS_H | 9 | #ifndef _LIBCPP___STRING_CHAR_TRAITS_H |
| 10 | #define _LIBCPP___STRING_CHAR_TRAITS_H | 10 | #define _LIBCPP___STRING_CHAR_TRAITS_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy_n.h> | ||
| 13 | #include <__algorithm/fill_n.h> | 12 | #include <__algorithm/fill_n.h> |
| 13 | #include <__algorithm/find.h> | ||
| 14 | #include <__algorithm/find_end.h> | 14 | #include <__algorithm/find_end.h> |
| 15 | #include <__algorithm/find_first_of.h> | 15 | #include <__algorithm/find_first_of.h> |
| 16 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 17 | #include <__assert> | ||
| 17 | #include <__compare/ordering.h> | 18 | #include <__compare/ordering.h> |
| 18 | #include <__config> | 19 | #include <__config> |
| 19 | #include <__functional/hash.h> | 20 | #include <__functional/hash.h> |
| 21 | #include <__functional/identity.h> | ||
| 20 | #include <__iterator/iterator_traits.h> | 22 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__string/constexpr_c_functions.h> | 23 | #include <__string/constexpr_c_functions.h> |
| 22 | #include <__type_traits/is_constant_evaluated.h> | 24 | #include <__type_traits/is_constant_evaluated.h> |
| ... | @@ -72,106 +74,6 @@ exposition-only to document what members a char_traits specialization should pro | ... | @@ -72,106 +74,6 @@ exposition-only to document what members a char_traits specialization should pro |
| 72 | }; | 74 | }; |
| 73 | */ | 75 | */ |
| 74 | 76 | ||
| 75 | // | ||
| 76 | // Temporary extension to provide a base template for std::char_traits. | ||
| 77 | // TODO(LLVM-19): Remove this class. | ||
| 78 | // | ||
| 79 | #if !defined(_LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION) | ||
| 80 | template <class _CharT> | ||
| 81 | struct _LIBCPP_DEPRECATED_( | ||
| 82 | "char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided " | ||
| 83 | "for a temporary period. It will be removed in LLVM 19, so please migrate off of it.") char_traits { | ||
| 84 | using char_type = _CharT; | ||
| 85 | using int_type = int; | ||
| 86 | using off_type = streamoff; | ||
| 87 | using pos_type = streampos; | ||
| 88 | using state_type = mbstate_t; | ||
| 89 | |||
| 90 | static inline void _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI | ||
| 91 | assign(char_type& __c1, const char_type& __c2) _NOEXCEPT { | ||
| 92 | __c1 = __c2; | ||
| 93 | } | ||
| 94 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 95 | return __c1 == __c2; | ||
| 96 | } | ||
| 97 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 98 | return __c1 < __c2; | ||
| 99 | } | ||
| 100 | |||
| 101 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int | ||
| 102 | compare(const char_type* __s1, const char_type* __s2, size_t __n) { | ||
| 103 | for (; __n; --__n, ++__s1, ++__s2) { | ||
| 104 | if (lt(*__s1, *__s2)) | ||
| 105 | return -1; | ||
| 106 | if (lt(*__s2, *__s1)) | ||
| 107 | return 1; | ||
| 108 | } | ||
| 109 | return 0; | ||
| 110 | } | ||
| 111 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) { | ||
| 112 | size_t __len = 0; | ||
| 113 | for (; !eq(*__s, char_type(0)); ++__s) | ||
| 114 | ++__len; | ||
| 115 | return __len; | ||
| 116 | } | ||
| 117 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | ||
| 118 | find(const char_type* __s, size_t __n, const char_type& __a) { | ||
| 119 | for (; __n; --__n) { | ||
| 120 | if (eq(*__s, __a)) | ||
| 121 | return __s; | ||
| 122 | ++__s; | ||
| 123 | } | ||
| 124 | return nullptr; | ||
| 125 | } | ||
| 126 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 127 | move(char_type* __s1, const char_type* __s2, size_t __n) { | ||
| 128 | if (__n == 0) | ||
| 129 | return __s1; | ||
| 130 | char_type* __r = __s1; | ||
| 131 | if (__s1 < __s2) { | ||
| 132 | for (; __n; --__n, ++__s1, ++__s2) | ||
| 133 | assign(*__s1, *__s2); | ||
| 134 | } else if (__s2 < __s1) { | ||
| 135 | __s1 += __n; | ||
| 136 | __s2 += __n; | ||
| 137 | for (; __n; --__n) | ||
| 138 | assign(*--__s1, *--__s2); | ||
| 139 | } | ||
| 140 | return __r; | ||
| 141 | } | ||
| 142 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 143 | copy(char_type* __s1, const char_type* __s2, size_t __n) { | ||
| 144 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), | ||
| 145 | "char_traits::copy: source and destination ranges overlap"); | ||
| 146 | char_type* __r = __s1; | ||
| 147 | for (; __n; --__n, ++__s1, ++__s2) | ||
| 148 | assign(*__s1, *__s2); | ||
| 149 | return __r; | ||
| 150 | } | ||
| 151 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 152 | assign(char_type* __s, size_t __n, char_type __a) { | ||
| 153 | char_type* __r = __s; | ||
| 154 | for (; __n; --__n, ++__s) | ||
| 155 | assign(*__s, __a); | ||
| 156 | return __r; | ||
| 157 | } | ||
| 158 | |||
| 159 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | ||
| 160 | return eq_int_type(__c, eof()) ? ~eof() : __c; | ||
| 161 | } | ||
| 162 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | ||
| 163 | return char_type(__c); | ||
| 164 | } | ||
| 165 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { | ||
| 166 | return int_type(__c); | ||
| 167 | } | ||
| 168 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT { | ||
| 169 | return __c1 == __c2; | ||
| 170 | } | ||
| 171 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); } | ||
| 172 | }; | ||
| 173 | #endif // !defined(_LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION) | ||
| 174 | |||
| 175 | // char_traits<char> | 77 | // char_traits<char> |
| 176 | 78 | ||
| 177 | template <> | 79 | template <> |
| ... | @@ -243,7 +145,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { | ... | @@ -243,7 +145,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { |
| 243 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 145 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
| 244 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), | 146 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), |
| 245 | "char_traits::copy: source and destination ranges overlap"); | 147 | "char_traits::copy: source and destination ranges overlap"); |
| 246 | std::copy_n(__s2, __n, __s1); | 148 | std::__constexpr_memmove(__s1, __s2, __element_count(__n)); |
| 247 | return __s1; | 149 | return __s1; |
| 248 | } | 150 | } |
| 249 | 151 | ||
| ... | @@ -268,31 +170,72 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { | ... | @@ -268,31 +170,72 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { |
| 268 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); } | 170 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); } |
| 269 | }; | 171 | }; |
| 270 | 172 | ||
| 271 | // char_traits<wchar_t> | 173 | template <class _CharT, class _IntT, _IntT _EOFVal> |
| 272 | 174 | struct __char_traits_base { | |
| 273 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 175 | using char_type = _CharT; |
| 274 | template <> | 176 | using int_type = _IntT; |
| 275 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> { | ||
| 276 | using char_type = wchar_t; | ||
| 277 | using int_type = wint_t; | ||
| 278 | using off_type = streamoff; | 177 | using off_type = streamoff; |
| 279 | using pos_type = streampos; | ||
| 280 | using state_type = mbstate_t; | 178 | using state_type = mbstate_t; |
| 281 | # if _LIBCPP_STD_VER >= 20 | 179 | #if _LIBCPP_STD_VER >= 20 |
| 282 | using comparison_category = strong_ordering; | 180 | using comparison_category = strong_ordering; |
| 283 | # endif | 181 | #endif |
| 284 | 182 | ||
| 285 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void | 183 | // There are different aliases for the different char types, but they are all aliases to this type |
| 286 | assign(char_type& __c1, const char_type& __c2) _NOEXCEPT { | 184 | using pos_type = fpos<mbstate_t>; |
| 287 | __c1 = __c2; | 185 | |
| 186 | _LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX17 void | ||
| 187 | assign(char_type& __lhs, const char_type& __rhs) _NOEXCEPT { | ||
| 188 | __lhs = __rhs; | ||
| 288 | } | 189 | } |
| 289 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT { | 190 | |
| 290 | return __c1 == __c2; | 191 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq(char_type __lhs, char_type __rhs) _NOEXCEPT { |
| 192 | return __lhs == __rhs; | ||
| 291 | } | 193 | } |
| 292 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT { | 194 | |
| 293 | return __c1 < __c2; | 195 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool lt(char_type __lhs, char_type __rhs) _NOEXCEPT { |
| 196 | return __lhs < __rhs; | ||
| 197 | } | ||
| 198 | |||
| 199 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 200 | move(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT { | ||
| 201 | return std::__constexpr_memmove(__dest, __src, __element_count(__n)); | ||
| 202 | } | ||
| 203 | |||
| 204 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 205 | copy(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT { | ||
| 206 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__dest, __dest + __n, __src), | ||
| 207 | "char_traits::copy: source and destination ranges overlap"); | ||
| 208 | return std::__constexpr_memmove(__dest, __src, __element_count(__n)); | ||
| 294 | } | 209 | } |
| 295 | 210 | ||
| 211 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 212 | assign(char_type* __str, size_t __n, char_type __fill_char) _NOEXCEPT { | ||
| 213 | std::fill_n(__str, __n, __fill_char); | ||
| 214 | return __str; | ||
| 215 | } | ||
| 216 | |||
| 217 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | ||
| 218 | return char_type(__c); | ||
| 219 | } | ||
| 220 | |||
| 221 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { return int_type(__c); } | ||
| 222 | |||
| 223 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __lhs, int_type __rhs) _NOEXCEPT { | ||
| 224 | return __lhs == __rhs; | ||
| 225 | } | ||
| 226 | |||
| 227 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return _EOFVal; } | ||
| 228 | |||
| 229 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | ||
| 230 | return eq_int_type(__c, eof()) ? static_cast<int_type>(~eof()) : __c; | ||
| 231 | } | ||
| 232 | }; | ||
| 233 | |||
| 234 | // char_traits<wchar_t> | ||
| 235 | |||
| 236 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 237 | template <> | ||
| 238 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> { | ||
| 296 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 239 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 297 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 240 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
| 298 | if (__n == 0) | 241 | if (__n == 0) |
| ... | @@ -310,184 +253,46 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> { | ... | @@ -310,184 +253,46 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> { |
| 310 | return nullptr; | 253 | return nullptr; |
| 311 | return std::__constexpr_wmemchr(__s, __a, __n); | 254 | return std::__constexpr_wmemchr(__s, __a, __n); |
| 312 | } | 255 | } |
| 313 | |||
| 314 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 315 | move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 316 | return std::__constexpr_memmove(__s1, __s2, __element_count(__n)); | ||
| 317 | } | ||
| 318 | |||
| 319 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 320 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 321 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), | ||
| 322 | "char_traits::copy: source and destination ranges overlap"); | ||
| 323 | std::copy_n(__s2, __n, __s1); | ||
| 324 | return __s1; | ||
| 325 | } | ||
| 326 | |||
| 327 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 328 | assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | ||
| 329 | std::fill_n(__s, __n, __a); | ||
| 330 | return __s; | ||
| 331 | } | ||
| 332 | |||
| 333 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | ||
| 334 | return eq_int_type(__c, eof()) ? ~eof() : __c; | ||
| 335 | } | ||
| 336 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | ||
| 337 | return char_type(__c); | ||
| 338 | } | ||
| 339 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { | ||
| 340 | return int_type(__c); | ||
| 341 | } | ||
| 342 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT { | ||
| 343 | return __c1 == __c2; | ||
| 344 | } | ||
| 345 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(WEOF); } | ||
| 346 | }; | 256 | }; |
| 347 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 257 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 348 | 258 | ||
| 349 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | 259 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 350 | 260 | ||
| 351 | template <> | 261 | template <> |
| 352 | struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> { | 262 | struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> |
| 353 | using char_type = char8_t; | 263 | : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> { |
| 354 | using int_type = unsigned int; | ||
| 355 | using off_type = streamoff; | ||
| 356 | using pos_type = u8streampos; | ||
| 357 | using state_type = mbstate_t; | ||
| 358 | # if _LIBCPP_STD_VER >= 20 | ||
| 359 | using comparison_category = strong_ordering; | ||
| 360 | # endif | ||
| 361 | |||
| 362 | static inline _LIBCPP_HIDE_FROM_ABI constexpr void assign(char_type& __c1, const char_type& __c2) noexcept { | ||
| 363 | __c1 = __c2; | ||
| 364 | } | ||
| 365 | static inline _LIBCPP_HIDE_FROM_ABI constexpr bool eq(char_type __c1, char_type __c2) noexcept { | ||
| 366 | return __c1 == __c2; | ||
| 367 | } | ||
| 368 | static inline _LIBCPP_HIDE_FROM_ABI constexpr bool lt(char_type __c1, char_type __c2) noexcept { return __c1 < __c2; } | ||
| 369 | |||
| 370 | static _LIBCPP_HIDE_FROM_ABI constexpr int | 264 | static _LIBCPP_HIDE_FROM_ABI constexpr int |
| 371 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 265 | compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept { |
| 372 | return std::__constexpr_memcmp(__s1, __s2, __element_count(__n)); | 266 | return std::__constexpr_memcmp(__s1, __s2, __element_count(__n)); |
| 373 | } | 267 | } |
| 374 | 268 | ||
| 375 | static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __s) _NOEXCEPT; | 269 | static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __str) noexcept { |
| 376 | 270 | return std::__constexpr_strlen(__str); | |
| 377 | _LIBCPP_HIDE_FROM_ABI static constexpr const char_type* | ||
| 378 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | ||
| 379 | |||
| 380 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 381 | move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 382 | return std::__constexpr_memmove(__s1, __s2, __element_count(__n)); | ||
| 383 | } | ||
| 384 | |||
| 385 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 386 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 387 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), | ||
| 388 | "char_traits::copy: source and destination ranges overlap"); | ||
| 389 | std::copy_n(__s2, __n, __s1); | ||
| 390 | return __s1; | ||
| 391 | } | ||
| 392 | |||
| 393 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type* | ||
| 394 | assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | ||
| 395 | std::fill_n(__s, __n, __a); | ||
| 396 | return __s; | ||
| 397 | } | 271 | } |
| 398 | 272 | ||
| 399 | static inline _LIBCPP_HIDE_FROM_ABI constexpr int_type not_eof(int_type __c) noexcept { | 273 | _LIBCPP_HIDE_FROM_ABI static constexpr const char_type* |
| 400 | return eq_int_type(__c, eof()) ? ~eof() : __c; | 274 | find(const char_type* __s, size_t __n, const char_type& __a) noexcept { |
| 401 | } | 275 | return std::__constexpr_memchr(__s, __a, __n); |
| 402 | static inline _LIBCPP_HIDE_FROM_ABI constexpr char_type to_char_type(int_type __c) noexcept { return char_type(__c); } | ||
| 403 | static inline _LIBCPP_HIDE_FROM_ABI constexpr int_type to_int_type(char_type __c) noexcept { return int_type(__c); } | ||
| 404 | static inline _LIBCPP_HIDE_FROM_ABI constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept { | ||
| 405 | return __c1 == __c2; | ||
| 406 | } | 276 | } |
| 407 | static inline _LIBCPP_HIDE_FROM_ABI constexpr int_type eof() noexcept { return int_type(EOF); } | ||
| 408 | }; | 277 | }; |
| 409 | 278 | ||
| 410 | // TODO use '__builtin_strlen' if it ever supports char8_t ?? | ||
| 411 | inline constexpr size_t char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT { | ||
| 412 | size_t __len = 0; | ||
| 413 | for (; !eq(*__s, char_type(0)); ++__s) | ||
| 414 | ++__len; | ||
| 415 | return __len; | ||
| 416 | } | ||
| 417 | |||
| 418 | // TODO use '__builtin_char_memchr' if it ever supports char8_t ?? | ||
| 419 | inline constexpr const char8_t* | ||
| 420 | char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | ||
| 421 | for (; __n; --__n) { | ||
| 422 | if (eq(*__s, __a)) | ||
| 423 | return __s; | ||
| 424 | ++__s; | ||
| 425 | } | ||
| 426 | return nullptr; | ||
| 427 | } | ||
| 428 | |||
| 429 | #endif // _LIBCPP_HAS_NO_CHAR8_T | 279 | #endif // _LIBCPP_HAS_NO_CHAR8_T |
| 430 | 280 | ||
| 431 | template <> | 281 | template <> |
| 432 | struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> { | 282 | struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> |
| 433 | using char_type = char16_t; | 283 | : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> { |
| 434 | using int_type = uint_least16_t; | ||
| 435 | using off_type = streamoff; | ||
| 436 | using pos_type = u16streampos; | ||
| 437 | using state_type = mbstate_t; | ||
| 438 | #if _LIBCPP_STD_VER >= 20 | ||
| 439 | using comparison_category = strong_ordering; | ||
| 440 | #endif | ||
| 441 | |||
| 442 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void | ||
| 443 | assign(char_type& __c1, const char_type& __c2) _NOEXCEPT { | ||
| 444 | __c1 = __c2; | ||
| 445 | } | ||
| 446 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 447 | return __c1 == __c2; | ||
| 448 | } | ||
| 449 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 450 | return __c1 < __c2; | ||
| 451 | } | ||
| 452 | |||
| 453 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 284 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 454 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | 285 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 455 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; | 286 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; |
| 456 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | ||
| 457 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | ||
| 458 | |||
| 459 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* | ||
| 460 | move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 461 | return std::__constexpr_memmove(__s1, __s2, __element_count(__n)); | ||
| 462 | } | ||
| 463 | 287 | ||
| 464 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* | 288 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 465 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 289 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 466 | _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2), | 290 | __identity __proj; |
| 467 | "char_traits::copy: source and destination ranges overlap"); | 291 | const char_type* __match = std::__find(__s, __s + __n, __a, __proj); |
| 468 | std::copy_n(__s2, __n, __s1); | 292 | if (__match == __s + __n) |
| 469 | return __s1; | 293 | return nullptr; |
| 470 | } | 294 | return __match; |
| 471 | |||
| 472 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* | ||
| 473 | assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | ||
| 474 | std::fill_n(__s, __n, __a); | ||
| 475 | return __s; | ||
| 476 | } | ||
| 477 | |||
| 478 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | ||
| 479 | return eq_int_type(__c, eof()) ? ~eof() : __c; | ||
| 480 | } | ||
| 481 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | ||
| 482 | return char_type(__c); | ||
| 483 | } | ||
| 484 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { | ||
| 485 | return int_type(__c); | ||
| 486 | } | ||
| 487 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT { | ||
| 488 | return __c1 == __c2; | ||
| 489 | } | 295 | } |
| 490 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(0xFFFF); } | ||
| 491 | }; | 296 | }; |
| 492 | 297 | ||
| 493 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 298 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| ... | @@ -508,74 +313,21 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const | ... | @@ -508,74 +313,21 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const |
| 508 | return __len; | 313 | return __len; |
| 509 | } | 314 | } |
| 510 | 315 | ||
| 511 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 const char16_t* | ||
| 512 | char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | ||
| 513 | for (; __n; --__n) { | ||
| 514 | if (eq(*__s, __a)) | ||
| 515 | return __s; | ||
| 516 | ++__s; | ||
| 517 | } | ||
| 518 | return nullptr; | ||
| 519 | } | ||
| 520 | |||
| 521 | template <> | 316 | template <> |
| 522 | struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> { | 317 | struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> |
| 523 | using char_type = char32_t; | 318 | : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> { |
| 524 | using int_type = uint_least32_t; | ||
| 525 | using off_type = streamoff; | ||
| 526 | using pos_type = u32streampos; | ||
| 527 | using state_type = mbstate_t; | ||
| 528 | #if _LIBCPP_STD_VER >= 20 | ||
| 529 | using comparison_category = strong_ordering; | ||
| 530 | #endif | ||
| 531 | |||
| 532 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void | ||
| 533 | assign(char_type& __c1, const char_type& __c2) _NOEXCEPT { | ||
| 534 | __c1 = __c2; | ||
| 535 | } | ||
| 536 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 537 | return __c1 == __c2; | ||
| 538 | } | ||
| 539 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 540 | return __c1 < __c2; | ||
| 541 | } | ||
| 542 | |||
| 543 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 319 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 544 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | 320 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 545 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; | 321 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; |
| 546 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | ||
| 547 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | ||
| 548 | |||
| 549 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* | ||
| 550 | move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 551 | return std::__constexpr_memmove(__s1, __s2, __element_count(__n)); | ||
| 552 | } | ||
| 553 | |||
| 554 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* | ||
| 555 | copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | ||
| 556 | std::copy_n(__s2, __n, __s1); | ||
| 557 | return __s1; | ||
| 558 | } | ||
| 559 | |||
| 560 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type* | ||
| 561 | assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | ||
| 562 | std::fill_n(__s, __n, __a); | ||
| 563 | return __s; | ||
| 564 | } | ||
| 565 | 322 | ||
| 566 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | 323 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 567 | return eq_int_type(__c, eof()) ? ~eof() : __c; | 324 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 568 | } | 325 | __identity __proj; |
| 569 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | 326 | const char_type* __match = std::__find(__s, __s + __n, __a, __proj); |
| 570 | return char_type(__c); | 327 | if (__match == __s + __n) |
| 571 | } | 328 | return nullptr; |
| 572 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { | 329 | return __match; |
| 573 | return int_type(__c); | ||
| 574 | } | ||
| 575 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT { | ||
| 576 | return __c1 == __c2; | ||
| 577 | } | 330 | } |
| 578 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(0xFFFFFFFF); } | ||
| 579 | }; | 331 | }; |
| 580 | 332 | ||
| 581 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 333 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| ... | @@ -596,16 +348,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const | ... | @@ -596,16 +348,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const |
| 596 | return __len; | 348 | return __len; |
| 597 | } | 349 | } |
| 598 | 350 | ||
| 599 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 const char32_t* | ||
| 600 | char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | ||
| 601 | for (; __n; --__n) { | ||
| 602 | if (eq(*__s, __a)) | ||
| 603 | return __s; | ||
| 604 | ++__s; | ||
| 605 | } | ||
| 606 | return nullptr; | ||
| 607 | } | ||
| 608 | |||
| 609 | // helper fns for basic_string and string_view | 351 | // helper fns for basic_string and string_view |
| 610 | 352 | ||
| 611 | // __str_find | 353 | // __str_find |
lib/libcxx/include/__string/constexpr_c_functions.h+21-6| ... | @@ -35,18 +35,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -35,18 +35,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | // of elements as opposed to a number of bytes. | 35 | // of elements as opposed to a number of bytes. |
| 36 | enum class __element_count : size_t {}; | 36 | enum class __element_count : size_t {}; |
| 37 | 37 | ||
| 38 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const char* __str) { | 38 | template <class _Tp> |
| 39 | inline const bool __is_char_type = false; | ||
| 40 | |||
| 41 | template <> | ||
| 42 | inline const bool __is_char_type<char> = true; | ||
| 43 | |||
| 44 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | ||
| 45 | template <> | ||
| 46 | inline const bool __is_char_type<char8_t> = true; | ||
| 47 | #endif | ||
| 48 | |||
| 49 | template <class _Tp> | ||
| 50 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const _Tp* __str) _NOEXCEPT { | ||
| 51 | static_assert(__is_char_type<_Tp>, "__constexpr_strlen only works with char and char8_t"); | ||
| 39 | // GCC currently doesn't support __builtin_strlen for heap-allocated memory during constant evaluation. | 52 | // GCC currently doesn't support __builtin_strlen for heap-allocated memory during constant evaluation. |
| 40 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816 | 53 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816 |
| 41 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 42 | if (__libcpp_is_constant_evaluated()) { | 54 | if (__libcpp_is_constant_evaluated()) { |
| 55 | #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_COMPILER_CLANG_BASED) | ||
| 56 | if constexpr (is_same_v<_Tp, char>) | ||
| 57 | return __builtin_strlen(__str); | ||
| 58 | #endif | ||
| 43 | size_t __i = 0; | 59 | size_t __i = 0; |
| 44 | for (; __str[__i] != '\0'; ++__i) | 60 | for (; __str[__i] != '\0'; ++__i) |
| 45 | ; | 61 | ; |
| 46 | return __i; | 62 | return __i; |
| 47 | } | 63 | } |
| 48 | #endif | 64 | return __builtin_strlen(reinterpret_cast<const char*>(__str)); |
| 49 | return __builtin_strlen(__str); | ||
| 50 | } | 65 | } |
| 51 | 66 | ||
| 52 | // Because of __libcpp_is_trivially_lexicographically_comparable we know that comparing the object representations is | 67 | // Because of __libcpp_is_trivially_lexicographically_comparable we know that comparing the object representations is |
| ... | @@ -108,7 +123,7 @@ __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n | ... | @@ -108,7 +123,7 @@ __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n |
| 108 | } | 123 | } |
| 109 | return true; | 124 | return true; |
| 110 | } else { | 125 | } else { |
| 111 | return __builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp)) == 0; | 126 | return ::__builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp)) == 0; |
| 112 | } | 127 | } |
| 113 | } | 128 | } |
| 114 | 129 | ||
| ... | @@ -209,7 +224,7 @@ __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) { | ... | @@ -209,7 +224,7 @@ __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) { |
| 209 | std::__assign_trivially_copyable(__dest[__i], __src[__i]); | 224 | std::__assign_trivially_copyable(__dest[__i], __src[__i]); |
| 210 | } | 225 | } |
| 211 | } else if (__count > 0) { | 226 | } else if (__count > 0) { |
| 212 | ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __libcpp_datasizeof<_Tp>::value); | 227 | ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>); |
| 213 | } | 228 | } |
| 214 | return __dest; | 229 | return __dest; |
| 215 | } | 230 | } |
lib/libcxx/include/__support/android/locale_bionic.h deleted-72| ... | @@ -1,72 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H | ||
| 11 | #define _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H | ||
| 12 | |||
| 13 | #if defined(__BIONIC__) | ||
| 14 | |||
| 15 | # ifdef __cplusplus | ||
| 16 | extern "C" { | ||
| 17 | # endif | ||
| 18 | |||
| 19 | # include <stdlib.h> | ||
| 20 | # include <xlocale.h> | ||
| 21 | |||
| 22 | # ifdef __cplusplus | ||
| 23 | } | ||
| 24 | # endif | ||
| 25 | |||
| 26 | # if defined(__ANDROID__) | ||
| 27 | |||
| 28 | # include <android/api-level.h> | ||
| 29 | # if __ANDROID_API__ < 21 | ||
| 30 | # include <__support/xlocale/__posix_l_fallback.h> | ||
| 31 | # endif | ||
| 32 | |||
| 33 | // If we do not have this header, we are in a platform build rather than an NDK | ||
| 34 | // build, which will always be at least as new as the ToT NDK, in which case we | ||
| 35 | // don't need any of the inlines below since libc provides them. | ||
| 36 | # if __has_include(<android/ndk-version.h>) | ||
| 37 | # include <android/ndk-version.h> | ||
| 38 | // In NDK versions later than 16, locale-aware functions are provided by | ||
| 39 | // legacy_stdlib_inlines.h | ||
| 40 | # if __NDK_MAJOR__ <= 16 | ||
| 41 | # if __ANDROID_API__ < 21 | ||
| 42 | # include <__support/xlocale/__strtonum_fallback.h> | ||
| 43 | # elif __ANDROID_API__ < 26 | ||
| 44 | |||
| 45 | # if defined(__cplusplus) | ||
| 46 | extern "C" { | ||
| 47 | # endif | ||
| 48 | |||
| 49 | inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) { | ||
| 50 | return ::strtof(__nptr, __endptr); | ||
| 51 | } | ||
| 52 | |||
| 53 | inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) { | ||
| 54 | return ::strtod(__nptr, __endptr); | ||
| 55 | } | ||
| 56 | |||
| 57 | inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 58 | return ::strtol(__nptr, __endptr, __base); | ||
| 59 | } | ||
| 60 | |||
| 61 | # if defined(__cplusplus) | ||
| 62 | } | ||
| 63 | # endif | ||
| 64 | |||
| 65 | # endif // __ANDROID_API__ < 26 | ||
| 66 | |||
| 67 | # endif // __NDK_MAJOR__ <= 16 | ||
| 68 | # endif // __has_include(<android/ndk-version.h>) | ||
| 69 | # endif // defined(__ANDROID__) | ||
| 70 | |||
| 71 | #endif // defined(__BIONIC__) | ||
| 72 | #endif // _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H | ||
lib/libcxx/include/__support/fuchsia/xlocale.h deleted-22| ... | @@ -1,22 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H | ||
| 11 | #define _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H | ||
| 12 | |||
| 13 | #if defined(__Fuchsia__) | ||
| 14 | |||
| 15 | # include <__support/xlocale/__posix_l_fallback.h> | ||
| 16 | # include <__support/xlocale/__strtonum_fallback.h> | ||
| 17 | # include <cstdlib> | ||
| 18 | # include <cwchar> | ||
| 19 | |||
| 20 | #endif // defined(__Fuchsia__) | ||
| 21 | |||
| 22 | #endif // _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H | ||
lib/libcxx/include/__support/ibm/xlocale.h deleted-122| ... | @@ -1,122 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___SUPPORT_IBM_XLOCALE_H | ||
| 11 | #define _LIBCPP___SUPPORT_IBM_XLOCALE_H | ||
| 12 | |||
| 13 | #if defined(__MVS__) | ||
| 14 | # include <__support/ibm/locale_mgmt_zos.h> | ||
| 15 | #endif // defined(__MVS__) | ||
| 16 | |||
| 17 | #include <stdarg.h> | ||
| 18 | |||
| 19 | #include "cstdlib" | ||
| 20 | |||
| 21 | #ifdef __cplusplus | ||
| 22 | extern "C" { | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if defined(__MVS__) | ||
| 26 | # include <wctype.h> | ||
| 27 | // POSIX routines | ||
| 28 | # include <__support/xlocale/__posix_l_fallback.h> | ||
| 29 | #endif // defined(__MVS__) | ||
| 30 | |||
| 31 | namespace { | ||
| 32 | |||
| 33 | struct __setAndRestore { | ||
| 34 | explicit __setAndRestore(locale_t locale) { | ||
| 35 | if (locale == (locale_t)0) { | ||
| 36 | __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0); | ||
| 37 | __stored = uselocale(__cloc); | ||
| 38 | } else { | ||
| 39 | __stored = uselocale(locale); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | ~__setAndRestore() { | ||
| 44 | uselocale(__stored); | ||
| 45 | if (__cloc) | ||
| 46 | freelocale(__cloc); | ||
| 47 | } | ||
| 48 | |||
| 49 | private: | ||
| 50 | locale_t __stored = (locale_t)0; | ||
| 51 | locale_t __cloc = (locale_t)0; | ||
| 52 | }; | ||
| 53 | |||
| 54 | } // namespace | ||
| 55 | |||
| 56 | // The following are not POSIX routines. These are quick-and-dirty hacks | ||
| 57 | // to make things pretend to work | ||
| 58 | inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { | ||
| 59 | __setAndRestore __newloc(locale); | ||
| 60 | return ::strtoll(__nptr, __endptr, __base); | ||
| 61 | } | ||
| 62 | |||
| 63 | inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { | ||
| 64 | __setAndRestore __newloc(locale); | ||
| 65 | return ::strtol(__nptr, __endptr, __base); | ||
| 66 | } | ||
| 67 | |||
| 68 | inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) { | ||
| 69 | __setAndRestore __newloc(locale); | ||
| 70 | return ::strtod(__nptr, __endptr); | ||
| 71 | } | ||
| 72 | |||
| 73 | inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t locale) { | ||
| 74 | __setAndRestore __newloc(locale); | ||
| 75 | return ::strtof(__nptr, __endptr); | ||
| 76 | } | ||
| 77 | |||
| 78 | inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t locale) { | ||
| 79 | __setAndRestore __newloc(locale); | ||
| 80 | return ::strtold(__nptr, __endptr); | ||
| 81 | } | ||
| 82 | |||
| 83 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 84 | strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { | ||
| 85 | __setAndRestore __newloc(locale); | ||
| 86 | return ::strtoull(__nptr, __endptr, __base); | ||
| 87 | } | ||
| 88 | |||
| 89 | inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { | ||
| 90 | __setAndRestore __newloc(locale); | ||
| 91 | return ::strtoul(__nptr, __endptr, __base); | ||
| 92 | } | ||
| 93 | |||
| 94 | inline _LIBCPP_HIDE_FROM_ABI int vasprintf(char** strp, const char* fmt, va_list ap) { | ||
| 95 | const size_t buff_size = 256; | ||
| 96 | if ((*strp = (char*)malloc(buff_size)) == NULL) { | ||
| 97 | return -1; | ||
| 98 | } | ||
| 99 | |||
| 100 | va_list ap_copy; | ||
| 101 | // va_copy may not be provided by the C library in C++ 03 mode. | ||
| 102 | #if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy) | ||
| 103 | __builtin_va_copy(ap_copy, ap); | ||
| 104 | #else | ||
| 105 | va_copy(ap_copy, ap); | ||
| 106 | #endif | ||
| 107 | int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy); | ||
| 108 | va_end(ap_copy); | ||
| 109 | |||
| 110 | if ((size_t)str_size >= buff_size) { | ||
| 111 | if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) { | ||
| 112 | return -1; | ||
| 113 | } | ||
| 114 | str_size = vsnprintf(*strp, str_size + 1, fmt, ap); | ||
| 115 | } | ||
| 116 | return str_size; | ||
| 117 | } | ||
| 118 | |||
| 119 | #ifdef __cplusplus | ||
| 120 | } | ||
| 121 | #endif | ||
| 122 | #endif // _LIBCPP___SUPPORT_IBM_XLOCALE_H | ||
lib/libcxx/include/__support/musl/xlocale.h deleted-53| ... | @@ -1,53 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | // This adds support for the extended locale functions that are currently | ||
| 10 | // missing from the Musl C library. | ||
| 11 | // | ||
| 12 | // This only works when the specified locale is "C" or "POSIX", but that's | ||
| 13 | // about as good as we can do without implementing full xlocale support | ||
| 14 | // in Musl. | ||
| 15 | //===----------------------------------------------------------------------===// | ||
| 16 | |||
| 17 | #ifndef _LIBCPP___SUPPORT_MUSL_XLOCALE_H | ||
| 18 | #define _LIBCPP___SUPPORT_MUSL_XLOCALE_H | ||
| 19 | |||
| 20 | #include <cstdlib> | ||
| 21 | #include <cwchar> | ||
| 22 | |||
| 23 | #ifdef __cplusplus | ||
| 24 | extern "C" { | ||
| 25 | #endif | ||
| 26 | |||
| 27 | inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 28 | return ::strtoll(__nptr, __endptr, __base); | ||
| 29 | } | ||
| 30 | |||
| 31 | inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long | ||
| 32 | strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 33 | return ::strtoull(__nptr, __endptr, __base); | ||
| 34 | } | ||
| 35 | |||
| 36 | inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) { | ||
| 37 | return ::wcstoll(__nptr, __endptr, __base); | ||
| 38 | } | ||
| 39 | |||
| 40 | inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long | ||
| 41 | wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) { | ||
| 42 | return ::wcstoull(__nptr, __endptr, __base); | ||
| 43 | } | ||
| 44 | |||
| 45 | inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) { | ||
| 46 | return ::wcstold(__nptr, __endptr); | ||
| 47 | } | ||
| 48 | |||
| 49 | #ifdef __cplusplus | ||
| 50 | } | ||
| 51 | #endif | ||
| 52 | |||
| 53 | #endif // _LIBCPP___SUPPORT_MUSL_XLOCALE_H | ||
lib/libcxx/include/__support/newlib/xlocale.h deleted-22| ... | @@ -1,22 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H | ||
| 10 | #define _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H | ||
| 11 | |||
| 12 | #if defined(_NEWLIB_VERSION) | ||
| 13 | |||
| 14 | # if !defined(__NEWLIB__) || __NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 | ||
| 15 | # include <__support/xlocale/__nop_locale_mgmt.h> | ||
| 16 | # include <__support/xlocale/__posix_l_fallback.h> | ||
| 17 | # include <__support/xlocale/__strtonum_fallback.h> | ||
| 18 | # endif | ||
| 19 | |||
| 20 | #endif // _NEWLIB_VERSION | ||
| 21 | |||
| 22 | #endif | ||
lib/libcxx/include/__support/openbsd/xlocale.h deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H | ||
| 11 | #define _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H | ||
| 12 | |||
| 13 | #include <__support/xlocale/__strtonum_fallback.h> | ||
| 14 | #include <clocale> | ||
| 15 | #include <cstdlib> | ||
| 16 | #include <ctype.h> | ||
| 17 | #include <cwctype> | ||
| 18 | |||
| 19 | #ifdef __cplusplus | ||
| 20 | extern "C" { | ||
| 21 | #endif | ||
| 22 | |||
| 23 | inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 24 | return ::strtol(__nptr, __endptr, __base); | ||
| 25 | } | ||
| 26 | |||
| 27 | inline _LIBCPP_HIDE_FROM_ABI_C unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 28 | return ::strtoul(__nptr, __endptr, __base); | ||
| 29 | } | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | } | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #endif | ||
lib/libcxx/include/__support/win32/locale_win32.h deleted-239| ... | @@ -1,239 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===-----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H | ||
| 11 | #define _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <cstddef> | ||
| 15 | #include <locale.h> // _locale_t | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <string> | ||
| 18 | |||
| 19 | #define _X_ALL LC_ALL | ||
| 20 | #define _X_COLLATE LC_COLLATE | ||
| 21 | #define _X_CTYPE LC_CTYPE | ||
| 22 | #define _X_MONETARY LC_MONETARY | ||
| 23 | #define _X_NUMERIC LC_NUMERIC | ||
| 24 | #define _X_TIME LC_TIME | ||
| 25 | #define _X_MAX LC_MAX | ||
| 26 | #define _X_MESSAGES 6 | ||
| 27 | #define _NCAT (_X_MESSAGES + 1) | ||
| 28 | |||
| 29 | #define _CATMASK(n) ((1 << (n)) >> 1) | ||
| 30 | #define _M_COLLATE _CATMASK(_X_COLLATE) | ||
| 31 | #define _M_CTYPE _CATMASK(_X_CTYPE) | ||
| 32 | #define _M_MONETARY _CATMASK(_X_MONETARY) | ||
| 33 | #define _M_NUMERIC _CATMASK(_X_NUMERIC) | ||
| 34 | #define _M_TIME _CATMASK(_X_TIME) | ||
| 35 | #define _M_MESSAGES _CATMASK(_X_MESSAGES) | ||
| 36 | #define _M_ALL (_CATMASK(_NCAT) - 1) | ||
| 37 | |||
| 38 | #define LC_COLLATE_MASK _M_COLLATE | ||
| 39 | #define LC_CTYPE_MASK _M_CTYPE | ||
| 40 | #define LC_MONETARY_MASK _M_MONETARY | ||
| 41 | #define LC_NUMERIC_MASK _M_NUMERIC | ||
| 42 | #define LC_TIME_MASK _M_TIME | ||
| 43 | #define LC_MESSAGES_MASK _M_MESSAGES | ||
| 44 | #define LC_ALL_MASK \ | ||
| 45 | (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK) | ||
| 46 | |||
| 47 | class __lconv_storage { | ||
| 48 | public: | ||
| 49 | __lconv_storage(const lconv* __lc_input) { | ||
| 50 | __lc_ = *__lc_input; | ||
| 51 | |||
| 52 | __decimal_point_ = __lc_input->decimal_point; | ||
| 53 | __thousands_sep_ = __lc_input->thousands_sep; | ||
| 54 | __grouping_ = __lc_input->grouping; | ||
| 55 | __int_curr_symbol_ = __lc_input->int_curr_symbol; | ||
| 56 | __currency_symbol_ = __lc_input->currency_symbol; | ||
| 57 | __mon_decimal_point_ = __lc_input->mon_decimal_point; | ||
| 58 | __mon_thousands_sep_ = __lc_input->mon_thousands_sep; | ||
| 59 | __mon_grouping_ = __lc_input->mon_grouping; | ||
| 60 | __positive_sign_ = __lc_input->positive_sign; | ||
| 61 | __negative_sign_ = __lc_input->negative_sign; | ||
| 62 | |||
| 63 | __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str()); | ||
| 64 | __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str()); | ||
| 65 | __lc_.grouping = const_cast<char*>(__grouping_.c_str()); | ||
| 66 | __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str()); | ||
| 67 | __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str()); | ||
| 68 | __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str()); | ||
| 69 | __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str()); | ||
| 70 | __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str()); | ||
| 71 | __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str()); | ||
| 72 | __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str()); | ||
| 73 | } | ||
| 74 | |||
| 75 | lconv* __get() { return &__lc_; } | ||
| 76 | |||
| 77 | private: | ||
| 78 | lconv __lc_; | ||
| 79 | std::string __decimal_point_; | ||
| 80 | std::string __thousands_sep_; | ||
| 81 | std::string __grouping_; | ||
| 82 | std::string __int_curr_symbol_; | ||
| 83 | std::string __currency_symbol_; | ||
| 84 | std::string __mon_decimal_point_; | ||
| 85 | std::string __mon_thousands_sep_; | ||
| 86 | std::string __mon_grouping_; | ||
| 87 | std::string __positive_sign_; | ||
| 88 | std::string __negative_sign_; | ||
| 89 | }; | ||
| 90 | |||
| 91 | class locale_t { | ||
| 92 | public: | ||
| 93 | locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {} | ||
| 94 | locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {} | ||
| 95 | locale_t(_locale_t __xlocale, const char* __xlocale_str) | ||
| 96 | : __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {} | ||
| 97 | locale_t(const locale_t& __l) : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {} | ||
| 98 | |||
| 99 | ~locale_t() { delete __lc_; } | ||
| 100 | |||
| 101 | locale_t& operator=(const locale_t& __l) { | ||
| 102 | __locale_ = __l.__locale_; | ||
| 103 | __locale_str_ = __l.__locale_str_; | ||
| 104 | // __lc_ not copied | ||
| 105 | return *this; | ||
| 106 | } | ||
| 107 | |||
| 108 | friend bool operator==(const locale_t& __left, const locale_t& __right) { | ||
| 109 | return __left.__locale_ == __right.__locale_; | ||
| 110 | } | ||
| 111 | |||
| 112 | friend bool operator==(const locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; } | ||
| 113 | |||
| 114 | friend bool operator==(const locale_t& __left, long long __right) { | ||
| 115 | return __left.__locale_ == nullptr && __right == 0; | ||
| 116 | } | ||
| 117 | |||
| 118 | friend bool operator==(const locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; } | ||
| 119 | |||
| 120 | friend bool operator==(int __left, const locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; } | ||
| 121 | |||
| 122 | friend bool operator==(std::nullptr_t, const locale_t& __right) { return nullptr == __right.__locale_; } | ||
| 123 | |||
| 124 | friend bool operator!=(const locale_t& __left, const locale_t& __right) { return !(__left == __right); } | ||
| 125 | |||
| 126 | friend bool operator!=(const locale_t& __left, int __right) { return !(__left == __right); } | ||
| 127 | |||
| 128 | friend bool operator!=(const locale_t& __left, long long __right) { return !(__left == __right); } | ||
| 129 | |||
| 130 | friend bool operator!=(const locale_t& __left, std::nullptr_t __right) { return !(__left == __right); } | ||
| 131 | |||
| 132 | friend bool operator!=(int __left, const locale_t& __right) { return !(__left == __right); } | ||
| 133 | |||
| 134 | friend bool operator!=(std::nullptr_t __left, const locale_t& __right) { return !(__left == __right); } | ||
| 135 | |||
| 136 | operator bool() const { return __locale_ != nullptr; } | ||
| 137 | |||
| 138 | const char* __get_locale() const { return __locale_str_; } | ||
| 139 | |||
| 140 | operator _locale_t() const { return __locale_; } | ||
| 141 | |||
| 142 | lconv* __store_lconv(const lconv* __input_lc) { | ||
| 143 | delete __lc_; | ||
| 144 | __lc_ = new __lconv_storage(__input_lc); | ||
| 145 | return __lc_->__get(); | ||
| 146 | } | ||
| 147 | |||
| 148 | private: | ||
| 149 | _locale_t __locale_; | ||
| 150 | const char* __locale_str_; | ||
| 151 | __lconv_storage* __lc_ = nullptr; | ||
| 152 | }; | ||
| 153 | |||
| 154 | // Locale management functions | ||
| 155 | #define freelocale _free_locale | ||
| 156 | // FIXME: base currently unused. Needs manual work to construct the new locale | ||
| 157 | locale_t newlocale(int __mask, const char* __locale, locale_t __base); | ||
| 158 | // uselocale can't be implemented on Windows because Windows allows partial modification | ||
| 159 | // of thread-local locale and so _get_current_locale() returns a copy while uselocale does | ||
| 160 | // not create any copies. | ||
| 161 | // We can still implement raii even without uselocale though. | ||
| 162 | |||
| 163 | lconv* localeconv_l(locale_t& __loc); | ||
| 164 | size_t mbrlen_l(const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 165 | size_t mbsrtowcs_l( | ||
| 166 | wchar_t* __restrict __dst, const char** __restrict __src, size_t __len, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 167 | size_t wcrtomb_l(char* __restrict __s, wchar_t __wc, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 168 | size_t mbrtowc_l( | ||
| 169 | wchar_t* __restrict __pwc, const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc); | ||
| 170 | size_t mbsnrtowcs_l(wchar_t* __restrict __dst, | ||
| 171 | const char** __restrict __src, | ||
| 172 | size_t __nms, | ||
| 173 | size_t __len, | ||
| 174 | mbstate_t* __restrict __ps, | ||
| 175 | locale_t __loc); | ||
| 176 | size_t wcsnrtombs_l(char* __restrict __dst, | ||
| 177 | const wchar_t** __restrict __src, | ||
| 178 | size_t __nwc, | ||
| 179 | size_t __len, | ||
| 180 | mbstate_t* __restrict __ps, | ||
| 181 | locale_t __loc); | ||
| 182 | wint_t btowc_l(int __c, locale_t __loc); | ||
| 183 | int wctob_l(wint_t __c, locale_t __loc); | ||
| 184 | |||
| 185 | decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l); | ||
| 186 | |||
| 187 | // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ | ||
| 188 | #define mbtowc_l _mbtowc_l | ||
| 189 | #define strtoll_l _strtoi64_l | ||
| 190 | #define strtoull_l _strtoui64_l | ||
| 191 | #define strtod_l _strtod_l | ||
| 192 | #if defined(_LIBCPP_MSVCRT) | ||
| 193 | # define strtof_l _strtof_l | ||
| 194 | # define strtold_l _strtold_l | ||
| 195 | #else | ||
| 196 | _LIBCPP_EXPORTED_FROM_ABI float strtof_l(const char*, char**, locale_t); | ||
| 197 | _LIBCPP_EXPORTED_FROM_ABI long double strtold_l(const char*, char**, locale_t); | ||
| 198 | #endif | ||
| 199 | inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, _locale_t __loc) { return _islower_l((int)__c, __loc); } | ||
| 200 | |||
| 201 | inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, _locale_t __loc) { return _isupper_l((int)__c, __loc); } | ||
| 202 | |||
| 203 | #define isdigit_l _isdigit_l | ||
| 204 | #define isxdigit_l _isxdigit_l | ||
| 205 | #define strcoll_l _strcoll_l | ||
| 206 | #define strxfrm_l _strxfrm_l | ||
| 207 | #define wcscoll_l _wcscoll_l | ||
| 208 | #define wcsxfrm_l _wcsxfrm_l | ||
| 209 | #define toupper_l _toupper_l | ||
| 210 | #define tolower_l _tolower_l | ||
| 211 | #define iswspace_l _iswspace_l | ||
| 212 | #define iswprint_l _iswprint_l | ||
| 213 | #define iswcntrl_l _iswcntrl_l | ||
| 214 | #define iswupper_l _iswupper_l | ||
| 215 | #define iswlower_l _iswlower_l | ||
| 216 | #define iswalpha_l _iswalpha_l | ||
| 217 | #define iswdigit_l _iswdigit_l | ||
| 218 | #define iswpunct_l _iswpunct_l | ||
| 219 | #define iswxdigit_l _iswxdigit_l | ||
| 220 | #define towupper_l _towupper_l | ||
| 221 | #define towlower_l _towlower_l | ||
| 222 | #if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800 | ||
| 223 | _LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc); | ||
| 224 | #else | ||
| 225 | # define strftime_l _strftime_l | ||
| 226 | #endif | ||
| 227 | #define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__) | ||
| 228 | #define sprintf_l(__s, __l, __f, ...) _sprintf_l(__s, __f, __l, __VA_ARGS__) | ||
| 229 | #define vsprintf_l(__s, __l, __f, ...) _vsprintf_l(__s, __f, __l, __VA_ARGS__) | ||
| 230 | #define vsnprintf_l(__s, __n, __l, __f, ...) _vsnprintf_l(__s, __n, __f, __l, __VA_ARGS__) | ||
| 231 | _LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...); | ||
| 232 | _LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...); | ||
| 233 | _LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap); | ||
| 234 | |||
| 235 | // not-so-pressing FIXME: use locale to determine blank characters | ||
| 236 | inline int isblank_l(int __c, locale_t /*loc*/) { return (__c == ' ' || __c == '\t'); } | ||
| 237 | inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); } | ||
| 238 | |||
| 239 | #endif // _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H | ||
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+4-12| ... | @@ -12,20 +12,16 @@ | ... | @@ -12,20 +12,16 @@ |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | 14 | ||
| 15 | #ifdef __cplusplus | ||
| 16 | extern "C" { | ||
| 17 | #endif | ||
| 18 | |||
| 19 | // Patch over lack of extended locale support | 15 | // Patch over lack of extended locale support |
| 20 | typedef void* locale_t; | 16 | typedef void* locale_t; |
| 21 | 17 | ||
| 22 | inline _LIBCPP_HIDE_FROM_ABI_C locale_t duplocale(locale_t) { return NULL; } | 18 | inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; } |
| 23 | 19 | ||
| 24 | inline _LIBCPP_HIDE_FROM_ABI_C void freelocale(locale_t) {} | 20 | inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {} |
| 25 | 21 | ||
| 26 | inline _LIBCPP_HIDE_FROM_ABI_C locale_t newlocale(int, const char*, locale_t) { return NULL; } | 22 | inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; } |
| 27 | 23 | ||
| 28 | inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; } | 24 | inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; } |
| 29 | 25 | ||
| 30 | #define LC_COLLATE_MASK (1 << LC_COLLATE) | 26 | #define LC_COLLATE_MASK (1 << LC_COLLATE) |
| 31 | #define LC_CTYPE_MASK (1 << LC_CTYPE) | 27 | #define LC_CTYPE_MASK (1 << LC_CTYPE) |
| ... | @@ -36,8 +32,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; } | ... | @@ -36,8 +32,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; } |
| 36 | #define LC_ALL_MASK \ | 32 | #define LC_ALL_MASK \ |
| 37 | (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_MESSAGES_MASK) | 33 | (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_MESSAGES_MASK) |
| 38 | 34 | ||
| 39 | #ifdef __cplusplus | ||
| 40 | } // extern "C" | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H | 35 | #endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H |
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+34-42| ... | @@ -17,99 +17,91 @@ | ... | @@ -17,99 +17,91 @@ |
| 17 | 17 | ||
| 18 | #include <__config> | 18 | #include <__config> |
| 19 | #include <ctype.h> | 19 | #include <ctype.h> |
| 20 | #include <string.h> | ||
| 20 | #include <time.h> | 21 | #include <time.h> |
| 21 | 22 | ||
| 22 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 23 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 24 | # include <wchar.h> | ||
| 23 | # include <wctype.h> | 25 | # include <wctype.h> |
| 24 | #endif | 26 | #endif |
| 25 | 27 | ||
| 26 | #ifdef __cplusplus | 28 | inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { return ::isalnum(__c); } |
| 27 | extern "C" { | ||
| 28 | #endif | ||
| 29 | |||
| 30 | inline _LIBCPP_HIDE_FROM_ABI_C int isalnum_l(int __c, locale_t) { return ::isalnum(__c); } | ||
| 31 | |||
| 32 | inline _LIBCPP_HIDE_FROM_ABI_C int isalpha_l(int __c, locale_t) { return ::isalpha(__c); } | ||
| 33 | 29 | ||
| 34 | inline _LIBCPP_HIDE_FROM_ABI_C int isblank_l(int __c, locale_t) { return ::isblank(__c); } | 30 | inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) { return ::isalpha(__c); } |
| 35 | 31 | ||
| 36 | inline _LIBCPP_HIDE_FROM_ABI_C int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); } | 32 | inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); } |
| 37 | 33 | ||
| 38 | inline _LIBCPP_HIDE_FROM_ABI_C int isdigit_l(int __c, locale_t) { return ::isdigit(__c); } | 34 | inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); } |
| 39 | 35 | ||
| 40 | inline _LIBCPP_HIDE_FROM_ABI_C int isgraph_l(int __c, locale_t) { return ::isgraph(__c); } | 36 | inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) { return ::isgraph(__c); } |
| 41 | 37 | ||
| 42 | inline _LIBCPP_HIDE_FROM_ABI_C int islower_l(int __c, locale_t) { return ::islower(__c); } | 38 | inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) { return ::islower(__c); } |
| 43 | 39 | ||
| 44 | inline _LIBCPP_HIDE_FROM_ABI_C int isprint_l(int __c, locale_t) { return ::isprint(__c); } | 40 | inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) { return ::isprint(__c); } |
| 45 | 41 | ||
| 46 | inline _LIBCPP_HIDE_FROM_ABI_C int ispunct_l(int __c, locale_t) { return ::ispunct(__c); } | 42 | inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) { return ::ispunct(__c); } |
| 47 | 43 | ||
| 48 | inline _LIBCPP_HIDE_FROM_ABI_C int isspace_l(int __c, locale_t) { return ::isspace(__c); } | 44 | inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) { return ::isspace(__c); } |
| 49 | 45 | ||
| 50 | inline _LIBCPP_HIDE_FROM_ABI_C int isupper_l(int __c, locale_t) { return ::isupper(__c); } | 46 | inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) { return ::isupper(__c); } |
| 51 | 47 | ||
| 52 | inline _LIBCPP_HIDE_FROM_ABI_C int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); } | 48 | inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); } |
| 53 | 49 | ||
| 54 | inline _LIBCPP_HIDE_FROM_ABI_C int toupper_l(int __c, locale_t) { return ::toupper(__c); } | 50 | inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) { return ::toupper(__c); } |
| 55 | 51 | ||
| 56 | inline _LIBCPP_HIDE_FROM_ABI_C int tolower_l(int __c, locale_t) { return ::tolower(__c); } | 52 | inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) { return ::tolower(__c); } |
| 57 | 53 | ||
| 58 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 54 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 59 | inline _LIBCPP_HIDE_FROM_ABI_C int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); } | 55 | inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); } |
| 60 | 56 | ||
| 61 | inline _LIBCPP_HIDE_FROM_ABI_C int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); } | 57 | inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); } |
| 62 | 58 | ||
| 63 | inline _LIBCPP_HIDE_FROM_ABI_C int iswblank_l(wint_t __c, locale_t) { return ::iswblank(__c); } | 59 | inline _LIBCPP_HIDE_FROM_ABI int iswblank_l(wint_t __c, locale_t) { return ::iswblank(__c); } |
| 64 | 60 | ||
| 65 | inline _LIBCPP_HIDE_FROM_ABI_C int iswcntrl_l(wint_t __c, locale_t) { return ::iswcntrl(__c); } | 61 | inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) { return ::iswcntrl(__c); } |
| 66 | 62 | ||
| 67 | inline _LIBCPP_HIDE_FROM_ABI_C int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); } | 63 | inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); } |
| 68 | 64 | ||
| 69 | inline _LIBCPP_HIDE_FROM_ABI_C int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); } | 65 | inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); } |
| 70 | 66 | ||
| 71 | inline _LIBCPP_HIDE_FROM_ABI_C int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); } | 67 | inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); } |
| 72 | 68 | ||
| 73 | inline _LIBCPP_HIDE_FROM_ABI_C int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); } | 69 | inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); } |
| 74 | 70 | ||
| 75 | inline _LIBCPP_HIDE_FROM_ABI_C int iswpunct_l(wint_t __c, locale_t) { return ::iswpunct(__c); } | 71 | inline _LIBCPP_HIDE_FROM_ABI int iswpunct_l(wint_t __c, locale_t) { return ::iswpunct(__c); } |
| 76 | 72 | ||
| 77 | inline _LIBCPP_HIDE_FROM_ABI_C int iswspace_l(wint_t __c, locale_t) { return ::iswspace(__c); } | 73 | inline _LIBCPP_HIDE_FROM_ABI int iswspace_l(wint_t __c, locale_t) { return ::iswspace(__c); } |
| 78 | 74 | ||
| 79 | inline _LIBCPP_HIDE_FROM_ABI_C int iswupper_l(wint_t __c, locale_t) { return ::iswupper(__c); } | 75 | inline _LIBCPP_HIDE_FROM_ABI int iswupper_l(wint_t __c, locale_t) { return ::iswupper(__c); } |
| 80 | 76 | ||
| 81 | inline _LIBCPP_HIDE_FROM_ABI_C int iswxdigit_l(wint_t __c, locale_t) { return ::iswxdigit(__c); } | 77 | inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) { return ::iswxdigit(__c); } |
| 82 | 78 | ||
| 83 | inline _LIBCPP_HIDE_FROM_ABI_C wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); } | 79 | inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); } |
| 84 | 80 | ||
| 85 | inline _LIBCPP_HIDE_FROM_ABI_C wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); } | 81 | inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); } |
| 86 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 82 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 87 | 83 | ||
| 88 | inline _LIBCPP_HIDE_FROM_ABI_C int strcoll_l(const char* __s1, const char* __s2, locale_t) { | 84 | inline _LIBCPP_HIDE_FROM_ABI int strcoll_l(const char* __s1, const char* __s2, locale_t) { |
| 89 | return ::strcoll(__s1, __s2); | 85 | return ::strcoll(__s1, __s2); |
| 90 | } | 86 | } |
| 91 | 87 | ||
| 92 | inline _LIBCPP_HIDE_FROM_ABI_C size_t strxfrm_l(char* __dest, const char* __src, size_t __n, locale_t) { | 88 | inline _LIBCPP_HIDE_FROM_ABI size_t strxfrm_l(char* __dest, const char* __src, size_t __n, locale_t) { |
| 93 | return ::strxfrm(__dest, __src, __n); | 89 | return ::strxfrm(__dest, __src, __n); |
| 94 | } | 90 | } |
| 95 | 91 | ||
| 96 | inline _LIBCPP_HIDE_FROM_ABI_C size_t | 92 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| 97 | strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm, locale_t) { | 93 | strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm, locale_t) { |
| 98 | return ::strftime(__s, __max, __format, __tm); | 94 | return ::strftime(__s, __max, __format, __tm); |
| 99 | } | 95 | } |
| 100 | 96 | ||
| 101 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 97 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 102 | inline _LIBCPP_HIDE_FROM_ABI_C int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) { | 98 | inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) { |
| 103 | return ::wcscoll(__ws1, __ws2); | 99 | return ::wcscoll(__ws1, __ws2); |
| 104 | } | 100 | } |
| 105 | 101 | ||
| 106 | inline _LIBCPP_HIDE_FROM_ABI_C size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) { | 102 | inline _LIBCPP_HIDE_FROM_ABI size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) { |
| 107 | return ::wcsxfrm(__dest, __src, __n); | 103 | return ::wcsxfrm(__dest, __src, __n); |
| 108 | } | 104 | } |
| 109 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 105 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 110 | 106 | ||
| 111 | #ifdef __cplusplus | ||
| 112 | } | ||
| 113 | #endif | ||
| 114 | |||
| 115 | #endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H | 107 | #endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H |
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+5-29| ... | @@ -22,48 +22,24 @@ | ... | @@ -22,48 +22,24 @@ |
| 22 | # include <wchar.h> | 22 | # include <wchar.h> |
| 23 | #endif | 23 | #endif |
| 24 | 24 | ||
| 25 | #ifdef __cplusplus | 25 | inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) { |
| 26 | extern "C" { | ||
| 27 | #endif | ||
| 28 | |||
| 29 | inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) { | ||
| 30 | return ::strtof(__nptr, __endptr); | 26 | return ::strtof(__nptr, __endptr); |
| 31 | } | 27 | } |
| 32 | 28 | ||
| 33 | inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) { | 29 | inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) { |
| 34 | return ::strtod(__nptr, __endptr); | 30 | return ::strtod(__nptr, __endptr); |
| 35 | } | 31 | } |
| 36 | 32 | ||
| 37 | inline _LIBCPP_HIDE_FROM_ABI_C long double strtold_l(const char* __nptr, char** __endptr, locale_t) { | 33 | inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t) { |
| 38 | return ::strtold(__nptr, __endptr); | 34 | return ::strtold(__nptr, __endptr); |
| 39 | } | 35 | } |
| 40 | 36 | ||
| 41 | inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) { | 37 | inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) { |
| 42 | return ::strtoll(__nptr, __endptr, __base); | 38 | return ::strtoll(__nptr, __endptr, __base); |
| 43 | } | 39 | } |
| 44 | 40 | ||
| 45 | inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long | 41 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) { |
| 46 | strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 47 | return ::strtoull(__nptr, __endptr, __base); | 42 | return ::strtoull(__nptr, __endptr, __base); |
| 48 | } | 43 | } |
| 49 | 44 | ||
| 50 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 51 | inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) { | ||
| 52 | return ::wcstoll(__nptr, __endptr, __base); | ||
| 53 | } | ||
| 54 | |||
| 55 | inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long | ||
| 56 | wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) { | ||
| 57 | return ::wcstoull(__nptr, __endptr, __base); | ||
| 58 | } | ||
| 59 | |||
| 60 | inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) { | ||
| 61 | return ::wcstold(__nptr, __endptr); | ||
| 62 | } | ||
| 63 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 64 | |||
| 65 | #ifdef __cplusplus | ||
| 66 | } | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H | 45 | #endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H |
lib/libcxx/include/__system_error/errc.h+63-12| ... | @@ -58,18 +58,18 @@ enum class errc | ... | @@ -58,18 +58,18 @@ enum class errc |
| 58 | no_child_process, // ECHILD | 58 | no_child_process, // ECHILD |
| 59 | no_link, // ENOLINK | 59 | no_link, // ENOLINK |
| 60 | no_lock_available, // ENOLCK | 60 | no_lock_available, // ENOLCK |
| 61 | no_message_available, // ENODATA | 61 | no_message_available, // ENODATA // deprecated |
| 62 | no_message, // ENOMSG | 62 | no_message, // ENOMSG |
| 63 | no_protocol_option, // ENOPROTOOPT | 63 | no_protocol_option, // ENOPROTOOPT |
| 64 | no_space_on_device, // ENOSPC | 64 | no_space_on_device, // ENOSPC |
| 65 | no_stream_resources, // ENOSR | 65 | no_stream_resources, // ENOSR // deprecated |
| 66 | no_such_device_or_address, // ENXIO | 66 | no_such_device_or_address, // ENXIO |
| 67 | no_such_device, // ENODEV | 67 | no_such_device, // ENODEV |
| 68 | no_such_file_or_directory, // ENOENT | 68 | no_such_file_or_directory, // ENOENT |
| 69 | no_such_process, // ESRCH | 69 | no_such_process, // ESRCH |
| 70 | not_a_directory, // ENOTDIR | 70 | not_a_directory, // ENOTDIR |
| 71 | not_a_socket, // ENOTSOCK | 71 | not_a_socket, // ENOTSOCK |
| 72 | not_a_stream, // ENOSTR | 72 | not_a_stream, // ENOSTR // deprecated |
| 73 | not_connected, // ENOTCONN | 73 | not_connected, // ENOTCONN |
| 74 | not_enough_memory, // ENOMEM | 74 | not_enough_memory, // ENOMEM |
| 75 | not_supported, // ENOTSUP | 75 | not_supported, // ENOTSUP |
| ... | @@ -87,7 +87,7 @@ enum class errc | ... | @@ -87,7 +87,7 @@ enum class errc |
| 87 | resource_unavailable_try_again, // EAGAIN | 87 | resource_unavailable_try_again, // EAGAIN |
| 88 | result_out_of_range, // ERANGE | 88 | result_out_of_range, // ERANGE |
| 89 | state_not_recoverable, // ENOTRECOVERABLE | 89 | state_not_recoverable, // ENOTRECOVERABLE |
| 90 | stream_timeout, // ETIME | 90 | stream_timeout, // ETIME // deprecated |
| 91 | text_file_busy, // ETXTBSY | 91 | text_file_busy, // ETXTBSY |
| 92 | timed_out, // ETIMEDOUT | 92 | timed_out, // ETIMEDOUT |
| 93 | too_many_files_open_in_system, // ENFILE | 93 | too_many_files_open_in_system, // ENFILE |
| ... | @@ -107,12 +107,39 @@ enum class errc | ... | @@ -107,12 +107,39 @@ enum class errc |
| 107 | # pragma GCC system_header | 107 | # pragma GCC system_header |
| 108 | #endif | 108 | #endif |
| 109 | 109 | ||
| 110 | // The method of pushing and popping the diagnostics fails for GCC. GCC does | ||
| 111 | // not recognize the pragma's used to generate deprecated diagnostics for | ||
| 112 | // macros. So GCC does not need the pushing and popping. | ||
| 113 | // | ||
| 114 | // TODO Remove this when the deprecated constants are removed. | ||
| 115 | // | ||
| 116 | // Note based on the post-review comments in | ||
| 117 | // https://github.com/llvm/llvm-project/pull/80542 libc++ no longer deprecates | ||
| 118 | // the macros. Since C libraries may start to deprecate these POSIX macros the | ||
| 119 | // deprecation warning avoidance is kept. | ||
| 120 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) | ||
| 121 | # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 122 | # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 123 | #else | ||
| 124 | # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH | ||
| 125 | # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP | ||
| 126 | #endif | ||
| 127 | |||
| 110 | _LIBCPP_BEGIN_NAMESPACE_STD | 128 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 111 | 129 | ||
| 112 | // Some error codes are not present on all platforms, so we provide equivalents | 130 | // Some error codes are not present on all platforms, so we provide equivalents |
| 113 | // for them: | 131 | // for them: |
| 114 | 132 | ||
| 115 | // enum class errc | 133 | // enum class errc |
| 134 | // | ||
| 135 | // LWG3869 deprecates the UNIX STREAMS macros and enum values. | ||
| 136 | // This makes the code clumbersome: | ||
| 137 | // - the enum value is deprecated and should show a diagnostic, | ||
| 138 | // - the macro is deprecated and should _not_ show a diagnostic in this | ||
| 139 | // context, and | ||
| 140 | // - the macro is not always available. | ||
| 141 | // This leads to the odd pushing and popping of the deprecated | ||
| 142 | // diagnostic. | ||
| 116 | _LIBCPP_DECLARE_STRONG_ENUM(errc){ | 143 | _LIBCPP_DECLARE_STRONG_ENUM(errc){ |
| 117 | address_family_not_supported = EAFNOSUPPORT, | 144 | address_family_not_supported = EAFNOSUPPORT, |
| 118 | address_in_use = EADDRINUSE, | 145 | address_in_use = EADDRINUSE, |
| ... | @@ -154,30 +181,48 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){ | ... | @@ -154,30 +181,48 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){ |
| 154 | no_child_process = ECHILD, | 181 | no_child_process = ECHILD, |
| 155 | no_link = ENOLINK, | 182 | no_link = ENOLINK, |
| 156 | no_lock_available = ENOLCK, | 183 | no_lock_available = ENOLCK, |
| 184 | // clang-format off | ||
| 185 | no_message_available _LIBCPP_DEPRECATED = | ||
| 186 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH | ||
| 157 | #ifdef ENODATA | 187 | #ifdef ENODATA |
| 158 | no_message_available = ENODATA, | 188 | ENODATA |
| 159 | #else | 189 | #else |
| 160 | no_message_available = ENOMSG, | 190 | ENOMSG |
| 161 | #endif | 191 | #endif |
| 192 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP | ||
| 193 | , | ||
| 194 | // clang-format on | ||
| 162 | no_message = ENOMSG, | 195 | no_message = ENOMSG, |
| 163 | no_protocol_option = ENOPROTOOPT, | 196 | no_protocol_option = ENOPROTOOPT, |
| 164 | no_space_on_device = ENOSPC, | 197 | no_space_on_device = ENOSPC, |
| 198 | // clang-format off | ||
| 199 | no_stream_resources _LIBCPP_DEPRECATED = | ||
| 200 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH | ||
| 165 | #ifdef ENOSR | 201 | #ifdef ENOSR |
| 166 | no_stream_resources = ENOSR, | 202 | ENOSR |
| 167 | #else | 203 | #else |
| 168 | no_stream_resources = ENOMEM, | 204 | ENOMEM |
| 169 | #endif | 205 | #endif |
| 206 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP | ||
| 207 | , | ||
| 208 | // clang-format on | ||
| 170 | no_such_device_or_address = ENXIO, | 209 | no_such_device_or_address = ENXIO, |
| 171 | no_such_device = ENODEV, | 210 | no_such_device = ENODEV, |
| 172 | no_such_file_or_directory = ENOENT, | 211 | no_such_file_or_directory = ENOENT, |
| 173 | no_such_process = ESRCH, | 212 | no_such_process = ESRCH, |
| 174 | not_a_directory = ENOTDIR, | 213 | not_a_directory = ENOTDIR, |
| 175 | not_a_socket = ENOTSOCK, | 214 | not_a_socket = ENOTSOCK, |
| 215 | // clang-format off | ||
| 216 | not_a_stream _LIBCPP_DEPRECATED = | ||
| 217 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH | ||
| 176 | #ifdef ENOSTR | 218 | #ifdef ENOSTR |
| 177 | not_a_stream = ENOSTR, | 219 | ENOSTR |
| 178 | #else | 220 | #else |
| 179 | not_a_stream = EINVAL, | 221 | EINVAL |
| 180 | #endif | 222 | #endif |
| 223 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP | ||
| 224 | , | ||
| 225 | // clang-format on | ||
| 181 | not_connected = ENOTCONN, | 226 | not_connected = ENOTCONN, |
| 182 | not_enough_memory = ENOMEM, | 227 | not_enough_memory = ENOMEM, |
| 183 | not_supported = ENOTSUP, | 228 | not_supported = ENOTSUP, |
| ... | @@ -195,11 +240,17 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){ | ... | @@ -195,11 +240,17 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){ |
| 195 | resource_unavailable_try_again = EAGAIN, | 240 | resource_unavailable_try_again = EAGAIN, |
| 196 | result_out_of_range = ERANGE, | 241 | result_out_of_range = ERANGE, |
| 197 | state_not_recoverable = ENOTRECOVERABLE, | 242 | state_not_recoverable = ENOTRECOVERABLE, |
| 243 | // clang-format off | ||
| 244 | stream_timeout _LIBCPP_DEPRECATED = | ||
| 245 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH | ||
| 198 | #ifdef ETIME | 246 | #ifdef ETIME |
| 199 | stream_timeout = ETIME, | 247 | ETIME |
| 200 | #else | 248 | #else |
| 201 | stream_timeout = ETIMEDOUT, | 249 | ETIMEDOUT |
| 202 | #endif | 250 | #endif |
| 251 | _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP | ||
| 252 | , | ||
| 253 | // clang-format on | ||
| 203 | text_file_busy = ETXTBSY, | 254 | text_file_busy = ETXTBSY, |
| 204 | timed_out = ETIMEDOUT, | 255 | timed_out = ETIMEDOUT, |
| 205 | too_many_files_open_in_system = ENFILE, | 256 | too_many_files_open_in_system = ENFILE, |
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 | _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT; | 70 | __attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT; |
| 71 | _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT; | 71 | __attribute__((__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/__thread/formatter.h+1-1| ... | @@ -43,7 +43,7 @@ public: | ... | @@ -43,7 +43,7 @@ public: |
| 43 | 43 | ||
| 44 | template <class _FormatContext> | 44 | template <class _FormatContext> |
| 45 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(__thread_id __id, _FormatContext& __ctx) const { | 45 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(__thread_id __id, _FormatContext& __ctx) const { |
| 46 | // In __threading_support __libcpp_thread_id is either a | 46 | // In __thread/support/pthread.h, __libcpp_thread_id is either a |
| 47 | // unsigned long long or a pthread_t. | 47 | // unsigned long long or a pthread_t. |
| 48 | // | 48 | // |
| 49 | // The type of pthread_t is left unspecified in POSIX so it can be any | 49 | // The type of pthread_t is left unspecified in POSIX so it can be any |
lib/libcxx/include/__thread/id.h+2-2| ... | @@ -12,9 +12,9 @@ | ... | @@ -12,9 +12,9 @@ |
| 12 | 12 | ||
| 13 | #include <__compare/ordering.h> | 13 | #include <__compare/ordering.h> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__fwd/hash.h> | 15 | #include <__fwd/functional.h> |
| 16 | #include <__fwd/ostream.h> | 16 | #include <__fwd/ostream.h> |
| 17 | #include <__threading_support> | 17 | #include <__thread/support.h> |
| 18 | 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 20 | # pragma GCC system_header |
lib/libcxx/include/__thread/jthread.h+1-2| ... | @@ -10,13 +10,12 @@ | ... | @@ -10,13 +10,12 @@ |
| 10 | #ifndef _LIBCPP___THREAD_JTHREAD_H | 10 | #ifndef _LIBCPP___THREAD_JTHREAD_H |
| 11 | #define _LIBCPP___THREAD_JTHREAD_H | 11 | #define _LIBCPP___THREAD_JTHREAD_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__functional/invoke.h> | 14 | #include <__functional/invoke.h> |
| 16 | #include <__stop_token/stop_source.h> | 15 | #include <__stop_token/stop_source.h> |
| 17 | #include <__stop_token/stop_token.h> | 16 | #include <__stop_token/stop_token.h> |
| 17 | #include <__thread/support.h> | ||
| 18 | #include <__thread/thread.h> | 18 | #include <__thread/thread.h> |
| 19 | #include <__threading_support> | ||
| 20 | #include <__type_traits/decay.h> | 19 | #include <__type_traits/decay.h> |
| 21 | #include <__type_traits/is_constructible.h> | 20 | #include <__type_traits/is_constructible.h> |
| 22 | #include <__type_traits/is_same.h> | 21 | #include <__type_traits/is_same.h> |
lib/libcxx/include/__thread/poll_with_backoff.h+8-9| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H | 10 | #ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H |
| 11 | #define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H | 11 | #define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__chrono/duration.h> | 13 | #include <__chrono/duration.h> |
| 15 | #include <__chrono/high_resolution_clock.h> | 14 | #include <__chrono/high_resolution_clock.h> |
| 16 | #include <__config> | 15 | #include <__config> |
| ... | @@ -26,21 +25,21 @@ static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; | ... | @@ -26,21 +25,21 @@ static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; |
| 26 | // Polls a thread for a condition given by a predicate, and backs off based on a backoff policy | 25 | // Polls a thread for a condition given by a predicate, and backs off based on a backoff policy |
| 27 | // before polling again. | 26 | // before polling again. |
| 28 | // | 27 | // |
| 29 | // - __f is the "test function" that should return true if polling succeeded, and false if it failed. | 28 | // - __poll is the "test function" that should return true if polling succeeded, and false if it failed. |
| 30 | // | 29 | // |
| 31 | // - __bf is the "backoff policy", which is called with the duration since we started polling. It should | 30 | // - __backoff is the "backoff policy", which is called with the duration since we started polling. It should |
| 32 | // return false in order to resume polling, and true if polling should stop entirely for some reason. | 31 | // return false in order to resume polling, and true if polling should stop entirely for some reason. |
| 33 | // In general, backoff policies sleep for some time before returning control to the polling loop. | 32 | // In general, backoff policies sleep for some time before returning control to the polling loop. |
| 34 | // | 33 | // |
| 35 | // - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded, | 34 | // - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded, |
| 36 | // the polling loop will return false to report a timeout. | 35 | // the polling loop will return false to report a timeout. |
| 37 | template <class _Fn, class _BFn> | 36 | template <class _Poll, class _Backoff> |
| 38 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_backoff( | 37 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_backoff( |
| 39 | _Fn&& __f, _BFn&& __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) { | 38 | _Poll&& __poll, _Backoff&& __backoff, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) { |
| 40 | auto const __start = chrono::high_resolution_clock::now(); | 39 | auto const __start = chrono::high_resolution_clock::now(); |
| 41 | for (int __count = 0;;) { | 40 | for (int __count = 0;;) { |
| 42 | if (__f()) | 41 | if (__poll()) |
| 43 | return true; // _Fn completion means success | 42 | return true; // __poll completion means success |
| 44 | if (__count < __libcpp_polling_count) { | 43 | if (__count < __libcpp_polling_count) { |
| 45 | __count += 1; | 44 | __count += 1; |
| 46 | continue; | 45 | continue; |
| ... | @@ -48,8 +47,8 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_b | ... | @@ -48,8 +47,8 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_b |
| 48 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; | 47 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; |
| 49 | if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) | 48 | if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) |
| 50 | return false; // timeout failure | 49 | return false; // timeout failure |
| 51 | if (__bf(__elapsed)) | 50 | if (__backoff(__elapsed)) |
| 52 | return false; // _BFn completion means failure | 51 | return false; // __backoff completion means failure |
| 53 | } | 52 | } |
| 54 | } | 53 | } |
| 55 | 54 |
lib/libcxx/include/__thread/support.h created+123| ... | @@ -0,0 +1,123 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___THREAD_SUPPORT_H | ||
| 11 | #define _LIBCPP___THREAD_SUPPORT_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | /* | ||
| 20 | |||
| 21 | // | ||
| 22 | // The library supports multiple implementations of the basic threading functionality. | ||
| 23 | // The following functionality must be provided by any implementation: | ||
| 24 | // | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 27 | |||
| 28 | using __libcpp_timespec_t = ...; | ||
| 29 | |||
| 30 | // | ||
| 31 | // Mutex | ||
| 32 | // | ||
| 33 | using __libcpp_mutex_t = ...; | ||
| 34 | #define _LIBCPP_MUTEX_INITIALIZER ... | ||
| 35 | |||
| 36 | using __libcpp_recursive_mutex_t = ...; | ||
| 37 | |||
| 38 | int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t*); | ||
| 39 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t*); | ||
| 40 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t*); | ||
| 41 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t*); | ||
| 42 | int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t*); | ||
| 43 | |||
| 44 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t*); | ||
| 45 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t*); | ||
| 46 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t*); | ||
| 47 | int __libcpp_mutex_destroy(__libcpp_mutex_t*); | ||
| 48 | |||
| 49 | // | ||
| 50 | // Condition Variable | ||
| 51 | // | ||
| 52 | using __libcpp_condvar_t = ...; | ||
| 53 | #define _LIBCPP_CONDVAR_INITIALIZER ... | ||
| 54 | |||
| 55 | int __libcpp_condvar_signal(__libcpp_condvar_t*); | ||
| 56 | int __libcpp_condvar_broadcast(__libcpp_condvar_t*); | ||
| 57 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t*, __libcpp_mutex_t*); | ||
| 58 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS | ||
| 59 | int __libcpp_condvar_timedwait(__libcpp_condvar_t*, __libcpp_mutex_t*, __libcpp_timespec_t*); | ||
| 60 | int __libcpp_condvar_destroy(__libcpp_condvar_t*); | ||
| 61 | |||
| 62 | // | ||
| 63 | // Execute once | ||
| 64 | // | ||
| 65 | using __libcpp_exec_once_flag = ...; | ||
| 66 | #define _LIBCPP_EXEC_ONCE_INITIALIZER ... | ||
| 67 | |||
| 68 | int __libcpp_execute_once(__libcpp_exec_once_flag*, void (*__init_routine)()); | ||
| 69 | |||
| 70 | // | ||
| 71 | // Thread id | ||
| 72 | // | ||
| 73 | using __libcpp_thread_id = ...; | ||
| 74 | |||
| 75 | bool __libcpp_thread_id_equal(__libcpp_thread_id, __libcpp_thread_id); | ||
| 76 | bool __libcpp_thread_id_less(__libcpp_thread_id, __libcpp_thread_id); | ||
| 77 | |||
| 78 | // | ||
| 79 | // Thread | ||
| 80 | // | ||
| 81 | #define _LIBCPP_NULL_THREAD ... | ||
| 82 | using __libcpp_thread_t = ...; | ||
| 83 | |||
| 84 | bool __libcpp_thread_isnull(const __libcpp_thread_t*); | ||
| 85 | int __libcpp_thread_create(__libcpp_thread_t*, void* (*__func)(void*), void* __arg); | ||
| 86 | __libcpp_thread_id __libcpp_thread_get_current_id(); | ||
| 87 | __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t*); | ||
| 88 | int __libcpp_thread_join(__libcpp_thread_t*); | ||
| 89 | int __libcpp_thread_detach(__libcpp_thread_t*); | ||
| 90 | void __libcpp_thread_yield(); | ||
| 91 | void __libcpp_thread_sleep_for(const chrono::nanoseconds&); | ||
| 92 | |||
| 93 | // | ||
| 94 | // Thread local storage | ||
| 95 | // | ||
| 96 | #define _LIBCPP_TLS_DESTRUCTOR_CC ... | ||
| 97 | using __libcpp_tls_key = ...; | ||
| 98 | |||
| 99 | int __libcpp_tls_create(__libcpp_tls_key*, void (*__at_exit)(void*)); | ||
| 100 | void* __libcpp_tls_get(__libcpp_tls_key); | ||
| 101 | int __libcpp_tls_set(__libcpp_tls_key, void*); | ||
| 102 | |||
| 103 | _LIBCPP_END_NAMESPACE_STD | ||
| 104 | |||
| 105 | */ | ||
| 106 | |||
| 107 | #if !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 108 | |||
| 109 | # if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
| 110 | # include <__thread/support/external.h> | ||
| 111 | # elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | ||
| 112 | # include <__thread/support/pthread.h> | ||
| 113 | # elif defined(_LIBCPP_HAS_THREAD_API_C11) | ||
| 114 | # include <__thread/support/c11.h> | ||
| 115 | # elif defined(_LIBCPP_HAS_THREAD_API_WIN32) | ||
| 116 | # include <__thread/support/windows.h> | ||
| 117 | # else | ||
| 118 | # error "No threading API was selected" | ||
| 119 | # endif | ||
| 120 | |||
| 121 | #endif // !_LIBCPP_HAS_NO_THREADS | ||
| 122 | |||
| 123 | #endif // _LIBCPP___THREAD_SUPPORT_H | ||
lib/libcxx/include/__thread/support/c11.h created+191| ... | @@ -0,0 +1,191 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___THREAD_SUPPORT_C11_H | ||
| 11 | #define _LIBCPP___THREAD_SUPPORT_C11_H | ||
| 12 | |||
| 13 | #include <__chrono/convert_to_timespec.h> | ||
| 14 | #include <__chrono/duration.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <ctime> | ||
| 17 | #include <errno.h> | ||
| 18 | #include <threads.h> | ||
| 19 | |||
| 20 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 21 | # pragma GCC system_header | ||
| 22 | #endif | ||
| 23 | |||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 25 | |||
| 26 | using __libcpp_timespec_t = ::timespec; | ||
| 27 | |||
| 28 | // | ||
| 29 | // Mutex | ||
| 30 | // | ||
| 31 | typedef mtx_t __libcpp_mutex_t; | ||
| 32 | // mtx_t is a struct so using {} for initialization is valid. | ||
| 33 | #define _LIBCPP_MUTEX_INITIALIZER \ | ||
| 34 | {} | ||
| 35 | |||
| 36 | typedef mtx_t __libcpp_recursive_mutex_t; | ||
| 37 | |||
| 38 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) { | ||
| 39 | return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL; | ||
| 40 | } | ||
| 41 | |||
| 42 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 43 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { | ||
| 44 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; | ||
| 45 | } | ||
| 46 | |||
| 47 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | ||
| 48 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { | ||
| 49 | return mtx_trylock(__m) == thrd_success; | ||
| 50 | } | ||
| 51 | |||
| 52 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 53 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { | ||
| 54 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; | ||
| 55 | } | ||
| 56 | |||
| 57 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) { | ||
| 58 | mtx_destroy(__m); | ||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | |||
| 62 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { | ||
| 63 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; | ||
| 64 | } | ||
| 65 | |||
| 66 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { | ||
| 67 | return mtx_trylock(__m) == thrd_success; | ||
| 68 | } | ||
| 69 | |||
| 70 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { | ||
| 71 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; | ||
| 72 | } | ||
| 73 | |||
| 74 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) { | ||
| 75 | mtx_destroy(__m); | ||
| 76 | return 0; | ||
| 77 | } | ||
| 78 | |||
| 79 | // | ||
| 80 | // Condition Variable | ||
| 81 | // | ||
| 82 | typedef cnd_t __libcpp_condvar_t; | ||
| 83 | // cnd_t is a struct so using {} for initialization is valid. | ||
| 84 | #define _LIBCPP_CONDVAR_INITIALIZER \ | ||
| 85 | {} | ||
| 86 | |||
| 87 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { | ||
| 88 | return cnd_signal(__cv) == thrd_success ? 0 : EINVAL; | ||
| 89 | } | ||
| 90 | |||
| 91 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) { | ||
| 92 | return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL; | ||
| 93 | } | ||
| 94 | |||
| 95 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 96 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { | ||
| 97 | return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL; | ||
| 98 | } | ||
| 99 | |||
| 100 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 101 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) { | ||
| 102 | int __ec = cnd_timedwait(__cv, __m, __ts); | ||
| 103 | return __ec == thrd_timedout ? ETIMEDOUT : __ec; | ||
| 104 | } | ||
| 105 | |||
| 106 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) { | ||
| 107 | cnd_destroy(__cv); | ||
| 108 | return 0; | ||
| 109 | } | ||
| 110 | |||
| 111 | // | ||
| 112 | // Execute once | ||
| 113 | // | ||
| 114 | typedef ::once_flag __libcpp_exec_once_flag; | ||
| 115 | #define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT | ||
| 116 | |||
| 117 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* flag, void (*init_routine)(void)) { | ||
| 118 | ::call_once(flag, init_routine); | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 122 | // | ||
| 123 | // Thread id | ||
| 124 | // | ||
| 125 | typedef thrd_t __libcpp_thread_id; | ||
| 126 | |||
| 127 | // Returns non-zero if the thread ids are equal, otherwise 0 | ||
| 128 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) { | ||
| 129 | return thrd_equal(t1, t2) != 0; | ||
| 130 | } | ||
| 131 | |||
| 132 | // Returns non-zero if t1 < t2, otherwise 0 | ||
| 133 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) { | ||
| 134 | return t1 < t2; | ||
| 135 | } | ||
| 136 | |||
| 137 | // | ||
| 138 | // Thread | ||
| 139 | // | ||
| 140 | #define _LIBCPP_NULL_THREAD 0U | ||
| 141 | |||
| 142 | typedef thrd_t __libcpp_thread_t; | ||
| 143 | |||
| 144 | inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { return *__t; } | ||
| 145 | |||
| 146 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { | ||
| 147 | return __libcpp_thread_get_id(__t) == 0; | ||
| 148 | } | ||
| 149 | |||
| 150 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) { | ||
| 151 | int __ec = thrd_create(__t, reinterpret_cast<thrd_start_t>(__func), __arg); | ||
| 152 | return __ec == thrd_nomem ? ENOMEM : __ec; | ||
| 153 | } | ||
| 154 | |||
| 155 | inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id() { return thrd_current(); } | ||
| 156 | |||
| 157 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t) { | ||
| 158 | return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL; | ||
| 159 | } | ||
| 160 | |||
| 161 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t) { | ||
| 162 | return thrd_detach(*__t) == thrd_success ? 0 : EINVAL; | ||
| 163 | } | ||
| 164 | |||
| 165 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_yield() { thrd_yield(); } | ||
| 166 | |||
| 167 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { | ||
| 168 | __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns); | ||
| 169 | thrd_sleep(&__ts, nullptr); | ||
| 170 | } | ||
| 171 | |||
| 172 | // | ||
| 173 | // Thread local storage | ||
| 174 | // | ||
| 175 | #define _LIBCPP_TLS_DESTRUCTOR_CC /* nothing */ | ||
| 176 | |||
| 177 | typedef tss_t __libcpp_tls_key; | ||
| 178 | |||
| 179 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) { | ||
| 180 | return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL; | ||
| 181 | } | ||
| 182 | |||
| 183 | inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key) { return tss_get(__key); } | ||
| 184 | |||
| 185 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) { | ||
| 186 | return tss_set(__key, __p) == thrd_success ? 0 : EINVAL; | ||
| 187 | } | ||
| 188 | |||
| 189 | _LIBCPP_END_NAMESPACE_STD | ||
| 190 | |||
| 191 | #endif // _LIBCPP___THREAD_SUPPORT_C11_H | ||
lib/libcxx/include/__thread/support/external.h created+21| ... | @@ -0,0 +1,21 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___THREAD_SUPPORT_EXTERNAL_H | ||
| 11 | #define _LIBCPP___THREAD_SUPPORT_EXTERNAL_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #include <__external_threading> | ||
| 20 | |||
| 21 | #endif // _LIBCPP___THREAD_SUPPORT_EXTERNAL_H | ||
lib/libcxx/include/__thread/support/pthread.h created+221| ... | @@ -0,0 +1,221 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___THREAD_SUPPORT_PTHREAD_H | ||
| 11 | #define _LIBCPP___THREAD_SUPPORT_PTHREAD_H | ||
| 12 | |||
| 13 | #include <__chrono/convert_to_timespec.h> | ||
| 14 | #include <__chrono/duration.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <ctime> | ||
| 17 | #include <errno.h> | ||
| 18 | #include <pthread.h> | ||
| 19 | #include <sched.h> | ||
| 20 | |||
| 21 | #ifdef __MVS__ | ||
| 22 | # include <__support/ibm/nanosleep.h> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | // Some platforms require <bits/atomic_wide_counter.h> in order for | ||
| 26 | // PTHREAD_COND_INITIALIZER to be expanded. Normally that would come | ||
| 27 | // in via <pthread.h>, but it's a non-modular header on those platforms, | ||
| 28 | // so libc++'s <math.h> usually absorbs atomic_wide_counter.h into the | ||
| 29 | // module with <math.h> and makes atomic_wide_counter.h invisible. | ||
| 30 | // Include <math.h> here to work around that. | ||
| 31 | // This checks wheter a Clang module is built | ||
| 32 | #if __building_module(std) | ||
| 33 | # include <math.h> | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 37 | # pragma GCC system_header | ||
| 38 | #endif | ||
| 39 | |||
| 40 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 41 | |||
| 42 | using __libcpp_timespec_t = ::timespec; | ||
| 43 | |||
| 44 | // | ||
| 45 | // Mutex | ||
| 46 | // | ||
| 47 | typedef pthread_mutex_t __libcpp_mutex_t; | ||
| 48 | #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER | ||
| 49 | |||
| 50 | typedef pthread_mutex_t __libcpp_recursive_mutex_t; | ||
| 51 | |||
| 52 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) { | ||
| 53 | pthread_mutexattr_t __attr; | ||
| 54 | int __ec = pthread_mutexattr_init(&__attr); | ||
| 55 | if (__ec) | ||
| 56 | return __ec; | ||
| 57 | __ec = pthread_mutexattr_settype(&__attr, PTHREAD_MUTEX_RECURSIVE); | ||
| 58 | if (__ec) { | ||
| 59 | pthread_mutexattr_destroy(&__attr); | ||
| 60 | return __ec; | ||
| 61 | } | ||
| 62 | __ec = pthread_mutex_init(__m, &__attr); | ||
| 63 | if (__ec) { | ||
| 64 | pthread_mutexattr_destroy(&__attr); | ||
| 65 | return __ec; | ||
| 66 | } | ||
| 67 | __ec = pthread_mutexattr_destroy(&__attr); | ||
| 68 | if (__ec) { | ||
| 69 | pthread_mutex_destroy(__m); | ||
| 70 | return __ec; | ||
| 71 | } | ||
| 72 | return 0; | ||
| 73 | } | ||
| 74 | |||
| 75 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 76 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { | ||
| 77 | return pthread_mutex_lock(__m); | ||
| 78 | } | ||
| 79 | |||
| 80 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | ||
| 81 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { | ||
| 82 | return pthread_mutex_trylock(__m) == 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 86 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { | ||
| 87 | return pthread_mutex_unlock(__m); | ||
| 88 | } | ||
| 89 | |||
| 90 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) { | ||
| 91 | return pthread_mutex_destroy(__m); | ||
| 92 | } | ||
| 93 | |||
| 94 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { | ||
| 95 | return pthread_mutex_lock(__m); | ||
| 96 | } | ||
| 97 | |||
| 98 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { | ||
| 99 | return pthread_mutex_trylock(__m) == 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { | ||
| 103 | return pthread_mutex_unlock(__m); | ||
| 104 | } | ||
| 105 | |||
| 106 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) { return pthread_mutex_destroy(__m); } | ||
| 107 | |||
| 108 | // | ||
| 109 | // Condition Variable | ||
| 110 | // | ||
| 111 | typedef pthread_cond_t __libcpp_condvar_t; | ||
| 112 | #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER | ||
| 113 | |||
| 114 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { return pthread_cond_signal(__cv); } | ||
| 115 | |||
| 116 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) { | ||
| 117 | return pthread_cond_broadcast(__cv); | ||
| 118 | } | ||
| 119 | |||
| 120 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 121 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { | ||
| 122 | return pthread_cond_wait(__cv, __m); | ||
| 123 | } | ||
| 124 | |||
| 125 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 126 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) { | ||
| 127 | return pthread_cond_timedwait(__cv, __m, __ts); | ||
| 128 | } | ||
| 129 | |||
| 130 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) { | ||
| 131 | return pthread_cond_destroy(__cv); | ||
| 132 | } | ||
| 133 | |||
| 134 | // | ||
| 135 | // Execute once | ||
| 136 | // | ||
| 137 | typedef pthread_once_t __libcpp_exec_once_flag; | ||
| 138 | #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT | ||
| 139 | |||
| 140 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()) { | ||
| 141 | return pthread_once(__flag, __init_routine); | ||
| 142 | } | ||
| 143 | |||
| 144 | // | ||
| 145 | // Thread id | ||
| 146 | // | ||
| 147 | #if defined(__MVS__) | ||
| 148 | typedef unsigned long long __libcpp_thread_id; | ||
| 149 | #else | ||
| 150 | typedef pthread_t __libcpp_thread_id; | ||
| 151 | #endif | ||
| 152 | |||
| 153 | // Returns non-zero if the thread ids are equal, otherwise 0 | ||
| 154 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2) { | ||
| 155 | return __t1 == __t2; | ||
| 156 | } | ||
| 157 | |||
| 158 | // Returns non-zero if t1 < t2, otherwise 0 | ||
| 159 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2) { | ||
| 160 | return __t1 < __t2; | ||
| 161 | } | ||
| 162 | |||
| 163 | // | ||
| 164 | // Thread | ||
| 165 | // | ||
| 166 | #define _LIBCPP_NULL_THREAD ((__libcpp_thread_t())) | ||
| 167 | typedef pthread_t __libcpp_thread_t; | ||
| 168 | |||
| 169 | inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { | ||
| 170 | #if defined(__MVS__) | ||
| 171 | return __t->__; | ||
| 172 | #else | ||
| 173 | return *__t; | ||
| 174 | #endif | ||
| 175 | } | ||
| 176 | |||
| 177 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { | ||
| 178 | return __libcpp_thread_get_id(__t) == 0; | ||
| 179 | } | ||
| 180 | |||
| 181 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) { | ||
| 182 | return pthread_create(__t, nullptr, __func, __arg); | ||
| 183 | } | ||
| 184 | |||
| 185 | inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id() { | ||
| 186 | const __libcpp_thread_t __current_thread = pthread_self(); | ||
| 187 | return __libcpp_thread_get_id(&__current_thread); | ||
| 188 | } | ||
| 189 | |||
| 190 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t) { return pthread_join(*__t, nullptr); } | ||
| 191 | |||
| 192 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t) { return pthread_detach(*__t); } | ||
| 193 | |||
| 194 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_yield() { sched_yield(); } | ||
| 195 | |||
| 196 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { | ||
| 197 | __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns); | ||
| 198 | while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR) | ||
| 199 | ; | ||
| 200 | } | ||
| 201 | |||
| 202 | // | ||
| 203 | // Thread local storage | ||
| 204 | // | ||
| 205 | #define _LIBCPP_TLS_DESTRUCTOR_CC /* nothing */ | ||
| 206 | |||
| 207 | typedef pthread_key_t __libcpp_tls_key; | ||
| 208 | |||
| 209 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) { | ||
| 210 | return pthread_key_create(__key, __at_exit); | ||
| 211 | } | ||
| 212 | |||
| 213 | inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key) { return pthread_getspecific(__key); } | ||
| 214 | |||
| 215 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) { | ||
| 216 | return pthread_setspecific(__key, __p); | ||
| 217 | } | ||
| 218 | |||
| 219 | _LIBCPP_END_NAMESPACE_STD | ||
| 220 | |||
| 221 | #endif // _LIBCPP___THREAD_SUPPORT_PTHREAD_H | ||
lib/libcxx/include/__thread/support/windows.h created+133| ... | @@ -0,0 +1,133 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___THREAD_SUPPORT_WINDOWS_H | ||
| 11 | #define _LIBCPP___THREAD_SUPPORT_WINDOWS_H | ||
| 12 | |||
| 13 | #include <__chrono/duration.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <ctime> | ||
| 16 | |||
| 17 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | using __libcpp_timespec_t = ::timespec; | ||
| 24 | |||
| 25 | // | ||
| 26 | // Mutex | ||
| 27 | // | ||
| 28 | typedef void* __libcpp_mutex_t; | ||
| 29 | #define _LIBCPP_MUTEX_INITIALIZER 0 | ||
| 30 | |||
| 31 | #if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__) | ||
| 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]; | ||
| 35 | #else | ||
| 36 | # error Unsupported architecture | ||
| 37 | #endif | ||
| 38 | |||
| 39 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); | ||
| 40 | |||
| 41 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 42 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m); | ||
| 43 | |||
| 44 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | ||
| 45 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m); | ||
| 46 | |||
| 47 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 48 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m); | ||
| 49 | |||
| 50 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m); | ||
| 51 | |||
| 52 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m); | ||
| 53 | |||
| 54 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m); | ||
| 55 | |||
| 56 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); | ||
| 57 | |||
| 58 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); | ||
| 59 | |||
| 60 | // | ||
| 61 | // Condition variable | ||
| 62 | // | ||
| 63 | typedef void* __libcpp_condvar_t; | ||
| 64 | #define _LIBCPP_CONDVAR_INITIALIZER 0 | ||
| 65 | |||
| 66 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); | ||
| 67 | |||
| 68 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); | ||
| 69 | |||
| 70 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 71 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); | ||
| 72 | |||
| 73 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 74 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts); | ||
| 75 | |||
| 76 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); | ||
| 77 | |||
| 78 | // | ||
| 79 | // Execute once | ||
| 80 | // | ||
| 81 | typedef void* __libcpp_exec_once_flag; | ||
| 82 | #define _LIBCPP_EXEC_ONCE_INITIALIZER 0 | ||
| 83 | |||
| 84 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()); | ||
| 85 | |||
| 86 | // | ||
| 87 | // Thread id | ||
| 88 | // | ||
| 89 | typedef long __libcpp_thread_id; | ||
| 90 | |||
| 91 | _LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2); | ||
| 92 | |||
| 93 | _LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2); | ||
| 94 | |||
| 95 | // | ||
| 96 | // Thread | ||
| 97 | // | ||
| 98 | #define _LIBCPP_NULL_THREAD 0U | ||
| 99 | typedef void* __libcpp_thread_t; | ||
| 100 | |||
| 101 | _LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t); | ||
| 102 | |||
| 103 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg); | ||
| 104 | |||
| 105 | _LIBCPP_EXPORTED_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id(); | ||
| 106 | |||
| 107 | _LIBCPP_EXPORTED_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t); | ||
| 108 | |||
| 109 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t); | ||
| 110 | |||
| 111 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t); | ||
| 112 | |||
| 113 | _LIBCPP_EXPORTED_FROM_ABI void __libcpp_thread_yield(); | ||
| 114 | |||
| 115 | _LIBCPP_EXPORTED_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns); | ||
| 116 | |||
| 117 | // | ||
| 118 | // Thread local storage | ||
| 119 | // | ||
| 120 | typedef long __libcpp_tls_key; | ||
| 121 | |||
| 122 | #define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall | ||
| 123 | |||
| 124 | _LIBCPP_EXPORTED_FROM_ABI int | ||
| 125 | __libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)); | ||
| 126 | |||
| 127 | _LIBCPP_EXPORTED_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key); | ||
| 128 | |||
| 129 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p); | ||
| 130 | |||
| 131 | _LIBCPP_END_NAMESPACE_STD | ||
| 132 | |||
| 133 | #endif // _LIBCPP___THREAD_SUPPORT_WINDOWS_H | ||
lib/libcxx/include/__thread/this_thread.h+1-1| ... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__mutex/mutex.h> | 17 | #include <__mutex/mutex.h> |
| 18 | #include <__mutex/unique_lock.h> | 18 | #include <__mutex/unique_lock.h> |
| 19 | #include <__threading_support> | 19 | #include <__thread/support.h> |
| 20 | 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | # pragma GCC system_header | 22 | # pragma GCC system_header |
lib/libcxx/include/__thread/thread.h+6-7| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | #include <__mutex/mutex.h> | 19 | #include <__mutex/mutex.h> |
| 20 | #include <__system_error/system_error.h> | 20 | #include <__system_error/system_error.h> |
| 21 | #include <__thread/id.h> | 21 | #include <__thread/id.h> |
| 22 | #include <__threading_support> | 22 | #include <__thread/support.h> |
| 23 | #include <__utility/forward.h> | 23 | #include <__utility/forward.h> |
| 24 | #include <tuple> | 24 | #include <tuple> |
| 25 | 25 | ||
| ... | @@ -65,18 +65,17 @@ class __thread_specific_ptr { | ... | @@ -65,18 +65,17 @@ class __thread_specific_ptr { |
| 65 | 65 | ||
| 66 | // Only __thread_local_data() may construct a __thread_specific_ptr | 66 | // Only __thread_local_data() may construct a __thread_specific_ptr |
| 67 | // and only with _Tp == __thread_struct. | 67 | // and only with _Tp == __thread_struct. |
| 68 | static_assert((is_same<_Tp, __thread_struct>::value), ""); | 68 | static_assert(is_same<_Tp, __thread_struct>::value, ""); |
| 69 | __thread_specific_ptr(); | 69 | __thread_specific_ptr(); |
| 70 | friend _LIBCPP_EXPORTED_FROM_ABI __thread_specific_ptr<__thread_struct>& __thread_local_data(); | 70 | friend _LIBCPP_EXPORTED_FROM_ABI __thread_specific_ptr<__thread_struct>& __thread_local_data(); |
| 71 | 71 | ||
| 72 | __thread_specific_ptr(const __thread_specific_ptr&); | ||
| 73 | __thread_specific_ptr& operator=(const __thread_specific_ptr&); | ||
| 74 | |||
| 75 | _LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*); | 72 | _LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*); |
| 76 | 73 | ||
| 77 | public: | 74 | public: |
| 78 | typedef _Tp* pointer; | 75 | typedef _Tp* pointer; |
| 79 | 76 | ||
| 77 | __thread_specific_ptr(const __thread_specific_ptr&) = delete; | ||
| 78 | __thread_specific_ptr& operator=(const __thread_specific_ptr&) = delete; | ||
| 80 | ~__thread_specific_ptr(); | 79 | ~__thread_specific_ptr(); |
| 81 | 80 | ||
| 82 | _LIBCPP_HIDE_FROM_ABI pointer get() const { return static_cast<_Tp*>(__libcpp_tls_get(__key_)); } | 81 | _LIBCPP_HIDE_FROM_ABI pointer get() const { return static_cast<_Tp*>(__libcpp_tls_get(__key_)); } |
| ... | @@ -157,7 +156,7 @@ public: | ... | @@ -157,7 +156,7 @@ public: |
| 157 | 156 | ||
| 158 | _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} | 157 | _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} |
| 159 | #ifndef _LIBCPP_CXX03_LANG | 158 | #ifndef _LIBCPP_CXX03_LANG |
| 160 | template <class _Fp, class... _Args, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value> > | 159 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> |
| 161 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args); | 160 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args); |
| 162 | #else // _LIBCPP_CXX03_LANG | 161 | #else // _LIBCPP_CXX03_LANG |
| 163 | template <class _Fp> | 162 | template <class _Fp> |
| ... | @@ -203,7 +202,7 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) { | ... | @@ -203,7 +202,7 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) { |
| 203 | return nullptr; | 202 | return nullptr; |
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | template <class _Fp, class... _Args, class > | 205 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> > |
| 207 | thread::thread(_Fp&& __f, _Args&&... __args) { | 206 | thread::thread(_Fp&& __f, _Args&&... __args) { |
| 208 | typedef unique_ptr<__thread_struct> _TSPtr; | 207 | typedef unique_ptr<__thread_struct> _TSPtr; |
| 209 | _TSPtr __tsp(new __thread_struct); | 208 | _TSPtr __tsp(new __thread_struct); |
lib/libcxx/include/__thread/timed_backoff_policy.h+1-1| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | #ifndef _LIBCPP_HAS_NO_THREADS | 15 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 16 | 16 | ||
| 17 | # include <__chrono/duration.h> | 17 | # include <__chrono/duration.h> |
| 18 | # include <__threading_support> | 18 | # include <__thread/support.h> |
| 19 | 19 | ||
| 20 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header | 21 | # pragma GCC system_header |
lib/libcxx/include/__threading_support deleted-456| ... | @@ -1,456 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___THREADING_SUPPORT | ||
| 11 | #define _LIBCPP___THREADING_SUPPORT | ||
| 12 | |||
| 13 | #include <__availability> | ||
| 14 | #include <__chrono/convert_to_timespec.h> | ||
| 15 | #include <__chrono/duration.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__fwd/hash.h> | ||
| 18 | #include <ctime> | ||
| 19 | #include <errno.h> | ||
| 20 | |||
| 21 | #ifdef __MVS__ | ||
| 22 | # include <__support/ibm/nanosleep.h> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 26 | # pragma GCC system_header | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
| 30 | # include <__external_threading> | ||
| 31 | #elif !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 32 | |||
| 33 | # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | ||
| 34 | // Some platforms require <bits/atomic_wide_counter.h> in order for | ||
| 35 | // PTHREAD_COND_INITIALIZER to be expanded. Normally that would come | ||
| 36 | // in via <pthread.h>, but it's a non-modular header on those platforms, | ||
| 37 | // so libc++'s <math.h> usually absorbs atomic_wide_counter.h into the | ||
| 38 | // module with <math.h> and makes atomic_wide_counter.h invisible. | ||
| 39 | // Include <math.h> here to work around that. | ||
| 40 | # include <math.h> | ||
| 41 | |||
| 42 | # include <pthread.h> | ||
| 43 | # include <sched.h> | ||
| 44 | # elif defined(_LIBCPP_HAS_THREAD_API_C11) | ||
| 45 | # include <threads.h> | ||
| 46 | # endif | ||
| 47 | |||
| 48 | # if defined(_LIBCPP_HAS_THREAD_API_WIN32) | ||
| 49 | # define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_EXPORTED_FROM_ABI | ||
| 50 | # else | ||
| 51 | # define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_HIDE_FROM_ABI | ||
| 52 | # endif | ||
| 53 | |||
| 54 | typedef ::timespec __libcpp_timespec_t; | ||
| 55 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 56 | |||
| 57 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 58 | |||
| 59 | #if !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 60 | |||
| 61 | # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | ||
| 62 | // Mutex | ||
| 63 | typedef pthread_mutex_t __libcpp_mutex_t; | ||
| 64 | # define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER | ||
| 65 | |||
| 66 | typedef pthread_mutex_t __libcpp_recursive_mutex_t; | ||
| 67 | |||
| 68 | // Condition Variable | ||
| 69 | typedef pthread_cond_t __libcpp_condvar_t; | ||
| 70 | # define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER | ||
| 71 | |||
| 72 | // Execute once | ||
| 73 | typedef pthread_once_t __libcpp_exec_once_flag; | ||
| 74 | # define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT | ||
| 75 | |||
| 76 | // Thread id | ||
| 77 | # if defined(__MVS__) | ||
| 78 | typedef unsigned long long __libcpp_thread_id; | ||
| 79 | # else | ||
| 80 | typedef pthread_t __libcpp_thread_id; | ||
| 81 | # endif | ||
| 82 | |||
| 83 | // Thread | ||
| 84 | # define _LIBCPP_NULL_THREAD ((__libcpp_thread_t())) | ||
| 85 | typedef pthread_t __libcpp_thread_t; | ||
| 86 | |||
| 87 | // Thread Local Storage | ||
| 88 | typedef pthread_key_t __libcpp_tls_key; | ||
| 89 | |||
| 90 | # define _LIBCPP_TLS_DESTRUCTOR_CC | ||
| 91 | # elif defined(_LIBCPP_HAS_THREAD_API_C11) | ||
| 92 | // Mutex | ||
| 93 | typedef mtx_t __libcpp_mutex_t; | ||
| 94 | // mtx_t is a struct so using {} for initialization is valid. | ||
| 95 | # define _LIBCPP_MUTEX_INITIALIZER \ | ||
| 96 | {} | ||
| 97 | |||
| 98 | typedef mtx_t __libcpp_recursive_mutex_t; | ||
| 99 | |||
| 100 | // Condition Variable | ||
| 101 | typedef cnd_t __libcpp_condvar_t; | ||
| 102 | // cnd_t is a struct so using {} for initialization is valid. | ||
| 103 | # define _LIBCPP_CONDVAR_INITIALIZER \ | ||
| 104 | {} | ||
| 105 | |||
| 106 | // Execute once | ||
| 107 | typedef ::once_flag __libcpp_exec_once_flag; | ||
| 108 | # define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT | ||
| 109 | |||
| 110 | // Thread id | ||
| 111 | typedef thrd_t __libcpp_thread_id; | ||
| 112 | |||
| 113 | // Thread | ||
| 114 | # define _LIBCPP_NULL_THREAD 0U | ||
| 115 | |||
| 116 | typedef thrd_t __libcpp_thread_t; | ||
| 117 | |||
| 118 | // Thread Local Storage | ||
| 119 | typedef tss_t __libcpp_tls_key; | ||
| 120 | |||
| 121 | # define _LIBCPP_TLS_DESTRUCTOR_CC | ||
| 122 | # elif !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
| 123 | // Mutex | ||
| 124 | typedef void* __libcpp_mutex_t; | ||
| 125 | # define _LIBCPP_MUTEX_INITIALIZER 0 | ||
| 126 | |||
| 127 | # if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__) | ||
| 128 | typedef void* __libcpp_recursive_mutex_t[6]; | ||
| 129 | # elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__) | ||
| 130 | typedef void* __libcpp_recursive_mutex_t[5]; | ||
| 131 | # else | ||
| 132 | # error Unsupported architecture | ||
| 133 | # endif | ||
| 134 | |||
| 135 | // Condition Variable | ||
| 136 | typedef void* __libcpp_condvar_t; | ||
| 137 | # define _LIBCPP_CONDVAR_INITIALIZER 0 | ||
| 138 | |||
| 139 | // Execute Once | ||
| 140 | typedef void* __libcpp_exec_once_flag; | ||
| 141 | # define _LIBCPP_EXEC_ONCE_INITIALIZER 0 | ||
| 142 | |||
| 143 | // Thread ID | ||
| 144 | typedef long __libcpp_thread_id; | ||
| 145 | |||
| 146 | // Thread | ||
| 147 | # define _LIBCPP_NULL_THREAD 0U | ||
| 148 | |||
| 149 | typedef void* __libcpp_thread_t; | ||
| 150 | |||
| 151 | // Thread Local Storage | ||
| 152 | typedef long __libcpp_tls_key; | ||
| 153 | |||
| 154 | # define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall | ||
| 155 | # endif // !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
| 156 | |||
| 157 | # if !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
| 158 | // Mutex | ||
| 159 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 160 | int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); | ||
| 161 | |||
| 162 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 163 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m); | ||
| 164 | |||
| 165 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | ||
| 166 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m); | ||
| 167 | |||
| 168 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 169 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m); | ||
| 170 | |||
| 171 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 172 | int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m); | ||
| 173 | |||
| 174 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m); | ||
| 175 | |||
| 176 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m); | ||
| 177 | |||
| 178 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); | ||
| 179 | |||
| 180 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 181 | int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); | ||
| 182 | |||
| 183 | // Condition variable | ||
| 184 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 185 | int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); | ||
| 186 | |||
| 187 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 188 | int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); | ||
| 189 | |||
| 190 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 191 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); | ||
| 192 | |||
| 193 | _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | ||
| 194 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts); | ||
| 195 | |||
| 196 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 197 | int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); | ||
| 198 | |||
| 199 | // Execute once | ||
| 200 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 201 | int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()); | ||
| 202 | |||
| 203 | // Thread id | ||
| 204 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 205 | bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2); | ||
| 206 | |||
| 207 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 208 | bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2); | ||
| 209 | |||
| 210 | // Thread | ||
| 211 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 212 | bool __libcpp_thread_isnull(const __libcpp_thread_t* __t); | ||
| 213 | |||
| 214 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 215 | int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg); | ||
| 216 | |||
| 217 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 218 | __libcpp_thread_id __libcpp_thread_get_current_id(); | ||
| 219 | |||
| 220 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 221 | __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t); | ||
| 222 | |||
| 223 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 224 | int __libcpp_thread_join(__libcpp_thread_t* __t); | ||
| 225 | |||
| 226 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 227 | int __libcpp_thread_detach(__libcpp_thread_t* __t); | ||
| 228 | |||
| 229 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 230 | void __libcpp_thread_yield(); | ||
| 231 | |||
| 232 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 233 | void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns); | ||
| 234 | |||
| 235 | // Thread local storage | ||
| 236 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 237 | int __libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)); | ||
| 238 | |||
| 239 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 240 | void* __libcpp_tls_get(__libcpp_tls_key __key); | ||
| 241 | |||
| 242 | _LIBCPP_THREAD_ABI_VISIBILITY | ||
| 243 | int __libcpp_tls_set(__libcpp_tls_key __key, void* __p); | ||
| 244 | |||
| 245 | # endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
| 246 | |||
| 247 | # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | ||
| 248 | |||
| 249 | int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) { | ||
| 250 | pthread_mutexattr_t __attr; | ||
| 251 | int __ec = pthread_mutexattr_init(&__attr); | ||
| 252 | if (__ec) | ||
| 253 | return __ec; | ||
| 254 | __ec = pthread_mutexattr_settype(&__attr, PTHREAD_MUTEX_RECURSIVE); | ||
| 255 | if (__ec) { | ||
| 256 | pthread_mutexattr_destroy(&__attr); | ||
| 257 | return __ec; | ||
| 258 | } | ||
| 259 | __ec = pthread_mutex_init(__m, &__attr); | ||
| 260 | if (__ec) { | ||
| 261 | pthread_mutexattr_destroy(&__attr); | ||
| 262 | return __ec; | ||
| 263 | } | ||
| 264 | __ec = pthread_mutexattr_destroy(&__attr); | ||
| 265 | if (__ec) { | ||
| 266 | pthread_mutex_destroy(__m); | ||
| 267 | return __ec; | ||
| 268 | } | ||
| 269 | return 0; | ||
| 270 | } | ||
| 271 | |||
| 272 | int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_lock(__m); } | ||
| 273 | |||
| 274 | bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_trylock(__m) == 0; } | ||
| 275 | |||
| 276 | int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_unlock(__m); } | ||
| 277 | |||
| 278 | int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_destroy(__m); } | ||
| 279 | |||
| 280 | int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { return pthread_mutex_lock(__m); } | ||
| 281 | |||
| 282 | bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { return pthread_mutex_trylock(__m) == 0; } | ||
| 283 | |||
| 284 | int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { return pthread_mutex_unlock(__m); } | ||
| 285 | |||
| 286 | int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) { return pthread_mutex_destroy(__m); } | ||
| 287 | |||
| 288 | // Condition Variable | ||
| 289 | int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { return pthread_cond_signal(__cv); } | ||
| 290 | |||
| 291 | int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) { return pthread_cond_broadcast(__cv); } | ||
| 292 | |||
| 293 | int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { return pthread_cond_wait(__cv, __m); } | ||
| 294 | |||
| 295 | int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) { | ||
| 296 | return pthread_cond_timedwait(__cv, __m, __ts); | ||
| 297 | } | ||
| 298 | |||
| 299 | int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) { return pthread_cond_destroy(__cv); } | ||
| 300 | |||
| 301 | // Execute once | ||
| 302 | int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()) { | ||
| 303 | return pthread_once(__flag, __init_routine); | ||
| 304 | } | ||
| 305 | |||
| 306 | // Thread id | ||
| 307 | // Returns non-zero if the thread ids are equal, otherwise 0 | ||
| 308 | bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2) { return __t1 == __t2; } | ||
| 309 | |||
| 310 | // Returns non-zero if t1 < t2, otherwise 0 | ||
| 311 | bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2) { return __t1 < __t2; } | ||
| 312 | |||
| 313 | // Thread | ||
| 314 | bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { return __libcpp_thread_get_id(__t) == 0; } | ||
| 315 | |||
| 316 | int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) { | ||
| 317 | return pthread_create(__t, nullptr, __func, __arg); | ||
| 318 | } | ||
| 319 | |||
| 320 | __libcpp_thread_id __libcpp_thread_get_current_id() { | ||
| 321 | const __libcpp_thread_t __current_thread = pthread_self(); | ||
| 322 | return __libcpp_thread_get_id(&__current_thread); | ||
| 323 | } | ||
| 324 | |||
| 325 | __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { | ||
| 326 | # if defined(__MVS__) | ||
| 327 | return __t->__; | ||
| 328 | # else | ||
| 329 | return *__t; | ||
| 330 | # endif | ||
| 331 | } | ||
| 332 | |||
| 333 | int __libcpp_thread_join(__libcpp_thread_t* __t) { return pthread_join(*__t, nullptr); } | ||
| 334 | |||
| 335 | int __libcpp_thread_detach(__libcpp_thread_t* __t) { return pthread_detach(*__t); } | ||
| 336 | |||
| 337 | void __libcpp_thread_yield() { sched_yield(); } | ||
| 338 | |||
| 339 | void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { | ||
| 340 | __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns); | ||
| 341 | while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR) | ||
| 342 | ; | ||
| 343 | } | ||
| 344 | |||
| 345 | // Thread local storage | ||
| 346 | int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) { | ||
| 347 | return pthread_key_create(__key, __at_exit); | ||
| 348 | } | ||
| 349 | |||
| 350 | void* __libcpp_tls_get(__libcpp_tls_key __key) { return pthread_getspecific(__key); } | ||
| 351 | |||
| 352 | int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) { return pthread_setspecific(__key, __p); } | ||
| 353 | |||
| 354 | # elif defined(_LIBCPP_HAS_THREAD_API_C11) | ||
| 355 | |||
| 356 | int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) { | ||
| 357 | return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL; | ||
| 358 | } | ||
| 359 | |||
| 360 | int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { | ||
| 361 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; | ||
| 362 | } | ||
| 363 | |||
| 364 | bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { return mtx_trylock(__m) == thrd_success; } | ||
| 365 | |||
| 366 | int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { | ||
| 367 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; | ||
| 368 | } | ||
| 369 | |||
| 370 | int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) { | ||
| 371 | mtx_destroy(__m); | ||
| 372 | return 0; | ||
| 373 | } | ||
| 374 | |||
| 375 | int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { return mtx_lock(__m) == thrd_success ? 0 : EINVAL; } | ||
| 376 | |||
| 377 | bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { return mtx_trylock(__m) == thrd_success; } | ||
| 378 | |||
| 379 | int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; } | ||
| 380 | |||
| 381 | int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) { | ||
| 382 | mtx_destroy(__m); | ||
| 383 | return 0; | ||
| 384 | } | ||
| 385 | |||
| 386 | // Condition Variable | ||
| 387 | int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { return cnd_signal(__cv) == thrd_success ? 0 : EINVAL; } | ||
| 388 | |||
| 389 | int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) { return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL; } | ||
| 390 | |||
| 391 | int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { | ||
| 392 | return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL; | ||
| 393 | } | ||
| 394 | |||
| 395 | int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) { | ||
| 396 | int __ec = cnd_timedwait(__cv, __m, __ts); | ||
| 397 | return __ec == thrd_timedout ? ETIMEDOUT : __ec; | ||
| 398 | } | ||
| 399 | |||
| 400 | int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) { | ||
| 401 | cnd_destroy(__cv); | ||
| 402 | return 0; | ||
| 403 | } | ||
| 404 | |||
| 405 | // Execute once | ||
| 406 | int __libcpp_execute_once(__libcpp_exec_once_flag* flag, void (*init_routine)(void)) { | ||
| 407 | ::call_once(flag, init_routine); | ||
| 408 | return 0; | ||
| 409 | } | ||
| 410 | |||
| 411 | // Thread id | ||
| 412 | // Returns non-zero if the thread ids are equal, otherwise 0 | ||
| 413 | bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) { return thrd_equal(t1, t2) != 0; } | ||
| 414 | |||
| 415 | // Returns non-zero if t1 < t2, otherwise 0 | ||
| 416 | bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) { return t1 < t2; } | ||
| 417 | |||
| 418 | // Thread | ||
| 419 | bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { return __libcpp_thread_get_id(__t) == 0; } | ||
| 420 | |||
| 421 | int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) { | ||
| 422 | int __ec = thrd_create(__t, reinterpret_cast<thrd_start_t>(__func), __arg); | ||
| 423 | return __ec == thrd_nomem ? ENOMEM : __ec; | ||
| 424 | } | ||
| 425 | |||
| 426 | __libcpp_thread_id __libcpp_thread_get_current_id() { return thrd_current(); } | ||
| 427 | |||
| 428 | __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { return *__t; } | ||
| 429 | |||
| 430 | int __libcpp_thread_join(__libcpp_thread_t* __t) { return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL; } | ||
| 431 | |||
| 432 | int __libcpp_thread_detach(__libcpp_thread_t* __t) { return thrd_detach(*__t) == thrd_success ? 0 : EINVAL; } | ||
| 433 | |||
| 434 | void __libcpp_thread_yield() { thrd_yield(); } | ||
| 435 | |||
| 436 | void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { | ||
| 437 | __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns); | ||
| 438 | thrd_sleep(&__ts, nullptr); | ||
| 439 | } | ||
| 440 | |||
| 441 | // Thread local storage | ||
| 442 | int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) { | ||
| 443 | return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL; | ||
| 444 | } | ||
| 445 | |||
| 446 | void* __libcpp_tls_get(__libcpp_tls_key __key) { return tss_get(__key); } | ||
| 447 | |||
| 448 | int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) { return tss_set(__key, __p) == thrd_success ? 0 : EINVAL; } | ||
| 449 | |||
| 450 | # endif | ||
| 451 | |||
| 452 | #endif // !_LIBCPP_HAS_NO_THREADS | ||
| 453 | |||
| 454 | _LIBCPP_END_NAMESPACE_STD | ||
| 455 | |||
| 456 | #endif // _LIBCPP___THREADING_SUPPORT | ||
lib/libcxx/include/__tree+19-26| ... | @@ -26,11 +26,9 @@ | ... | @@ -26,11 +26,9 @@ |
| 26 | #include <__type_traits/can_extract_key.h> | 26 | #include <__type_traits/can_extract_key.h> |
| 27 | #include <__type_traits/conditional.h> | 27 | #include <__type_traits/conditional.h> |
| 28 | #include <__type_traits/is_const.h> | 28 | #include <__type_traits/is_const.h> |
| 29 | #include <__type_traits/is_copy_constructible.h> | 29 | #include <__type_traits/is_constructible.h> |
| 30 | #include <__type_traits/is_nothrow_copy_constructible.h> | 30 | #include <__type_traits/is_nothrow_assignable.h> |
| 31 | #include <__type_traits/is_nothrow_default_constructible.h> | 31 | #include <__type_traits/is_nothrow_constructible.h> |
| 32 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 33 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 34 | #include <__type_traits/is_pointer.h> | 32 | #include <__type_traits/is_pointer.h> |
| 35 | #include <__type_traits/is_same.h> | 33 | #include <__type_traits/is_same.h> |
| 36 | #include <__type_traits/is_swappable.h> | 34 | #include <__type_traits/is_swappable.h> |
| ... | @@ -547,10 +545,8 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { | ... | @@ -547,10 +545,8 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { |
| 547 | return __t.__get_value(); | 545 | return __t.__get_value(); |
| 548 | } | 546 | } |
| 549 | 547 | ||
| 550 | template <class _Up> | 548 | template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0> |
| 551 | _LIBCPP_HIDE_FROM_ABI static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, | 549 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { |
| 552 | __container_value_type const&> | ||
| 553 | __get_value(_Up& __t) { | ||
| 554 | return __t; | 550 | return __t; |
| 555 | } | 551 | } |
| 556 | 552 | ||
| ... | @@ -578,7 +574,7 @@ struct __tree_node_base_types { | ... | @@ -578,7 +574,7 @@ struct __tree_node_base_types { |
| 578 | #endif | 574 | #endif |
| 579 | 575 | ||
| 580 | private: | 576 | private: |
| 581 | static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value), | 577 | static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value, |
| 582 | "_VoidPtr does not point to unqualified void type"); | 578 | "_VoidPtr does not point to unqualified void type"); |
| 583 | }; | 579 | }; |
| 584 | 580 | ||
| ... | @@ -618,7 +614,7 @@ public: | ... | @@ -618,7 +614,7 @@ public: |
| 618 | 614 | ||
| 619 | private: | 615 | private: |
| 620 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); | 616 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); |
| 621 | static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value), | 617 | static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value, |
| 622 | "_VoidPtr does not rebind to _NodePtr."); | 618 | "_VoidPtr does not rebind to _NodePtr."); |
| 623 | }; | 619 | }; |
| 624 | 620 | ||
| ... | @@ -655,7 +651,6 @@ public: | ... | @@ -655,7 +651,6 @@ public: |
| 655 | 651 | ||
| 656 | _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); } | 652 | _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); } |
| 657 | 653 | ||
| 658 | private: | ||
| 659 | ~__tree_node_base() = delete; | 654 | ~__tree_node_base() = delete; |
| 660 | __tree_node_base(__tree_node_base const&) = delete; | 655 | __tree_node_base(__tree_node_base const&) = delete; |
| 661 | __tree_node_base& operator=(__tree_node_base const&) = delete; | 656 | __tree_node_base& operator=(__tree_node_base const&) = delete; |
| ... | @@ -670,7 +665,6 @@ public: | ... | @@ -670,7 +665,6 @@ public: |
| 670 | 665 | ||
| 671 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } | 666 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } |
| 672 | 667 | ||
| 673 | private: | ||
| 674 | ~__tree_node() = delete; | 668 | ~__tree_node() = delete; |
| 675 | __tree_node(__tree_node const&) = delete; | 669 | __tree_node(__tree_node const&) = delete; |
| 676 | __tree_node& operator=(__tree_node const&) = delete; | 670 | __tree_node& operator=(__tree_node const&) = delete; |
| ... | @@ -929,11 +923,11 @@ private: | ... | @@ -929,11 +923,11 @@ private: |
| 929 | // check for sane allocator pointer rebinding semantics. Rebinding the | 923 | // check for sane allocator pointer rebinding semantics. Rebinding the |
| 930 | // allocator for a new pointer type should be exactly the same as rebinding | 924 | // allocator for a new pointer type should be exactly the same as rebinding |
| 931 | // the pointer using 'pointer_traits'. | 925 | // the pointer using 'pointer_traits'. |
| 932 | static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value), | 926 | static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value, |
| 933 | "Allocator does not rebind pointers in a sane manner."); | 927 | "Allocator does not rebind pointers in a sane manner."); |
| 934 | typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator; | 928 | typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator; |
| 935 | typedef allocator_traits<__node_base_allocator> __node_base_traits; | 929 | typedef allocator_traits<__node_base_allocator> __node_base_traits; |
| 936 | static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value), | 930 | static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value, |
| 937 | "Allocator does not rebind pointers in a sane manner."); | 931 | "Allocator does not rebind pointers in a sane manner."); |
| 938 | 932 | ||
| 939 | private: | 933 | private: |
| ... | @@ -1010,11 +1004,10 @@ public: | ... | @@ -1010,11 +1004,10 @@ public: |
| 1010 | 1004 | ||
| 1011 | _LIBCPP_HIDE_FROM_ABI void swap(__tree& __t) | 1005 | _LIBCPP_HIDE_FROM_ABI void swap(__tree& __t) |
| 1012 | #if _LIBCPP_STD_VER <= 11 | 1006 | #if _LIBCPP_STD_VER <= 11 |
| 1013 | _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value && | 1007 | _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> && |
| 1014 | (!__node_traits::propagate_on_container_swap::value || | 1008 | (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)); |
| 1015 | __is_nothrow_swappable<__node_allocator>::value)); | ||
| 1016 | #else | 1009 | #else |
| 1017 | _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value); | 1010 | _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>); |
| 1018 | #endif | 1011 | #endif |
| 1019 | 1012 | ||
| 1020 | template <class _Key, class... _Args> | 1013 | template <class _Key, class... _Args> |
| ... | @@ -1117,12 +1110,12 @@ public: | ... | @@ -1117,12 +1110,12 @@ public: |
| 1117 | return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first; | 1110 | return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first; |
| 1118 | } | 1111 | } |
| 1119 | 1112 | ||
| 1120 | template <class _Vp, class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> > | 1113 | template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0> |
| 1121 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Vp&& __v) { | 1114 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Vp&& __v) { |
| 1122 | return __emplace_unique(std::forward<_Vp>(__v)); | 1115 | return __emplace_unique(std::forward<_Vp>(__v)); |
| 1123 | } | 1116 | } |
| 1124 | 1117 | ||
| 1125 | template <class _Vp, class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> > | 1118 | template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0> |
| 1126 | _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) { | 1119 | _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) { |
| 1127 | return __emplace_hint_unique(__p, std::forward<_Vp>(__v)); | 1120 | return __emplace_hint_unique(__p, std::forward<_Vp>(__v)); |
| 1128 | } | 1121 | } |
| ... | @@ -1405,7 +1398,7 @@ template <class _ForwardIterator> | ... | @@ -1405,7 +1398,7 @@ template <class _ForwardIterator> |
| 1405 | void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) { | 1398 | void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) { |
| 1406 | typedef iterator_traits<_ForwardIterator> _ITraits; | 1399 | typedef iterator_traits<_ForwardIterator> _ITraits; |
| 1407 | typedef typename _ITraits::value_type _ItValueType; | 1400 | typedef typename _ITraits::value_type _ItValueType; |
| 1408 | static_assert((is_same<_ItValueType, __container_value_type>::value), | 1401 | static_assert(is_same<_ItValueType, __container_value_type>::value, |
| 1409 | "__assign_unique may only be called with the containers value type"); | 1402 | "__assign_unique may only be called with the containers value type"); |
| 1410 | static_assert( | 1403 | static_assert( |
| 1411 | __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator"); | 1404 | __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator"); |
| ... | @@ -1535,7 +1528,7 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=( | ... | @@ -1535,7 +1528,7 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=( |
| 1535 | 1528 | ||
| 1536 | template <class _Tp, class _Compare, class _Allocator> | 1529 | template <class _Tp, class _Compare, class _Allocator> |
| 1537 | __tree<_Tp, _Compare, _Allocator>::~__tree() { | 1530 | __tree<_Tp, _Compare, _Allocator>::~__tree() { |
| 1538 | static_assert((is_copy_constructible<value_compare>::value), "Comparator must be copy-constructible."); | 1531 | static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible."); |
| 1539 | destroy(__root()); | 1532 | destroy(__root()); |
| 1540 | } | 1533 | } |
| 1541 | 1534 | ||
| ... | @@ -1553,10 +1546,10 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { | ... | @@ -1553,10 +1546,10 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { |
| 1553 | template <class _Tp, class _Compare, class _Allocator> | 1546 | template <class _Tp, class _Compare, class _Allocator> |
| 1554 | void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) | 1547 | void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) |
| 1555 | #if _LIBCPP_STD_VER <= 11 | 1548 | #if _LIBCPP_STD_VER <= 11 |
| 1556 | _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value && | 1549 | _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> && |
| 1557 | (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value)) | 1550 | (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)) |
| 1558 | #else | 1551 | #else |
| 1559 | _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value) | 1552 | _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>) |
| 1560 | #endif | 1553 | #endif |
| 1561 | { | 1554 | { |
| 1562 | using std::swap; | 1555 | using std::swap; |
lib/libcxx/include/__tuple/find_index.h created+62| ... | @@ -0,0 +1,62 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TUPLE_FIND_INDEX_H | ||
| 10 | #define _LIBCPP___TUPLE_FIND_INDEX_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/is_same.h> | ||
| 14 | #include <cstddef> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #if _LIBCPP_STD_VER >= 14 | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | namespace __find_detail { | ||
| 25 | |||
| 26 | static constexpr size_t __not_found = static_cast<size_t>(-1); | ||
| 27 | static constexpr size_t __ambiguous = __not_found - 1; | ||
| 28 | |||
| 29 | inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) { | ||
| 30 | return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous); | ||
| 31 | } | ||
| 32 | |||
| 33 | template <size_t _Nx> | ||
| 34 | inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) { | ||
| 35 | return __i == _Nx | ||
| 36 | ? __not_found | ||
| 37 | : __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]); | ||
| 38 | } | ||
| 39 | |||
| 40 | template <class _T1, class... _Args> | ||
| 41 | struct __find_exactly_one_checked { | ||
| 42 | static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...}; | ||
| 43 | static constexpr size_t value = __find_detail::__find_idx(0, __matches); | ||
| 44 | static_assert(value != __not_found, "type not found in type list"); | ||
| 45 | static_assert(value != __ambiguous, "type occurs more than once in type list"); | ||
| 46 | }; | ||
| 47 | |||
| 48 | template <class _T1> | ||
| 49 | struct __find_exactly_one_checked<_T1> { | ||
| 50 | static_assert(!is_same<_T1, _T1>::value, "type not in empty type list"); | ||
| 51 | }; | ||
| 52 | |||
| 53 | } // namespace __find_detail | ||
| 54 | |||
| 55 | template <typename _T1, typename... _Args> | ||
| 56 | struct __find_exactly_one_t : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {}; | ||
| 57 | |||
| 58 | _LIBCPP_END_NAMESPACE_STD | ||
| 59 | |||
| 60 | #endif // _LIBCPP_STD_VER >= 14 | ||
| 61 | |||
| 62 | #endif // _LIBCPP___TUPLE_FIND_INDEX_H | ||
lib/libcxx/include/__tuple/ignore.h created+39| ... | @@ -0,0 +1,39 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TUPLE_IGNORE_H | ||
| 10 | #define _LIBCPP___TUPLE_IGNORE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #ifndef _LIBCPP_CXX03_LANG | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | struct __ignore_type { | ||
| 23 | template <class _Tp> | ||
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const __ignore_type& operator=(const _Tp&) const noexcept { | ||
| 25 | return *this; | ||
| 26 | } | ||
| 27 | }; | ||
| 28 | |||
| 29 | # if _LIBCPP_STD_VER >= 17 | ||
| 30 | inline constexpr __ignore_type ignore; | ||
| 31 | # else | ||
| 32 | constexpr __ignore_type ignore; | ||
| 33 | # endif | ||
| 34 | |||
| 35 | _LIBCPP_END_NAMESPACE_STD | ||
| 36 | |||
| 37 | #endif // _LIBCPP_CXX03_LANG | ||
| 38 | |||
| 39 | #endif // _LIBCPP___TUPLE_IGNORE_H | ||
lib/libcxx/include/__tuple/make_tuple_types.h+3-3| ... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
| 16 | #include <__tuple/tuple_indices.h> | 16 | #include <__tuple/tuple_indices.h> |
| 17 | #include <__tuple/tuple_size.h> | 17 | #include <__tuple/tuple_size.h> |
| 18 | #include <__tuple/tuple_types.h> | 18 | #include <__tuple/tuple_types.h> |
| 19 | #include <__type_traits/apply_cv.h> | 19 | #include <__type_traits/copy_cvref.h> |
| 20 | #include <__type_traits/remove_cv.h> | 20 | #include <__type_traits/remove_cv.h> |
| 21 | #include <__type_traits/remove_reference.h> | 21 | #include <__type_traits/remove_reference.h> |
| 22 | #include <cstddef> | 22 | #include <cstddef> |
| ... | @@ -41,7 +41,7 @@ template <template <class...> class _Tuple, class... _Types, size_t... _Idx> | ... | @@ -41,7 +41,7 @@ template <template <class...> class _Tuple, class... _Types, size_t... _Idx> |
| 41 | struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { | 41 | struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { |
| 42 | // Specialization for pair, tuple, and __tuple_types | 42 | // Specialization for pair, tuple, and __tuple_types |
| 43 | template <class _Tp> | 43 | template <class _Tp> |
| 44 | using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__apply_cv_t<_Tp, __type_pack_element<_Idx, _Types...>>...>; | 44 | using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __type_pack_element<_Idx, _Types...>>...>; |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | template <class _Vt, size_t _Np, size_t... _Idx> | 47 | template <class _Vt, size_t _Np, size_t... _Idx> |
| ... | @@ -49,7 +49,7 @@ struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { | ... | @@ -49,7 +49,7 @@ struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { |
| 49 | template <size_t> | 49 | template <size_t> |
| 50 | using __value_type = _Vt; | 50 | using __value_type = _Vt; |
| 51 | template <class _Tp> | 51 | template <class _Tp> |
| 52 | using __apply_quals = __tuple_types<__apply_cv_t<_Tp, __value_type<_Idx>>...>; | 52 | using __apply_quals = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>; |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | template <class _Tp, | 55 | template <class _Tp, |
lib/libcxx/include/__tuple/pair_like.h deleted-32| ... | @@ -1,32 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TUPLE_PAIR_LIKE_H | ||
| 10 | #define _LIBCPP___TUPLE_PAIR_LIKE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__tuple/tuple_like.h> | ||
| 14 | #include <__tuple/tuple_size.h> | ||
| 15 | #include <__type_traits/remove_cvref.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | #if _LIBCPP_STD_VER >= 20 | ||
| 24 | |||
| 25 | template <class _Tp> | ||
| 26 | concept __pair_like = __tuple_like<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2; | ||
| 27 | |||
| 28 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 29 | |||
| 30 | _LIBCPP_END_NAMESPACE_STD | ||
| 31 | |||
| 32 | #endif // _LIBCPP___TUPLE_PAIR_LIKE_H | ||
lib/libcxx/include/__tuple/sfinae_helpers.h+3-40| ... | @@ -16,11 +16,10 @@ | ... | @@ -16,11 +16,10 @@ |
| 16 | #include <__tuple/tuple_like_ext.h> | 16 | #include <__tuple/tuple_like_ext.h> |
| 17 | #include <__tuple/tuple_size.h> | 17 | #include <__tuple/tuple_size.h> |
| 18 | #include <__tuple/tuple_types.h> | 18 | #include <__tuple/tuple_types.h> |
| 19 | #include <__type_traits/conjunction.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_assignable.h> | ||
| 22 | #include <__type_traits/is_constructible.h> | 22 | #include <__type_traits/is_constructible.h> |
| 23 | #include <__type_traits/is_convertible.h> | ||
| 24 | #include <__type_traits/is_same.h> | 23 | #include <__type_traits/is_same.h> |
| 25 | #include <__type_traits/remove_cvref.h> | 24 | #include <__type_traits/remove_cvref.h> |
| 26 | #include <__type_traits/remove_reference.h> | 25 | #include <__type_traits/remove_reference.h> |
| ... | @@ -34,40 +33,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -34,40 +33,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 33 | ||
| 35 | #ifndef _LIBCPP_CXX03_LANG | 34 | #ifndef _LIBCPP_CXX03_LANG |
| 36 | 35 | ||
| 37 | template <bool... _Preds> | ||
| 38 | struct __all_dummy; | ||
| 39 | |||
| 40 | template <bool... _Pred> | ||
| 41 | struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {}; | ||
| 42 | |||
| 43 | struct __tuple_sfinae_base { | 36 | struct __tuple_sfinae_base { |
| 44 | template <template <class, class...> class _Trait, class... _LArgs, class... _RArgs> | 37 | template <template <class, class...> class _Trait, class... _LArgs, class... _RArgs> |
| 45 | static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>) | 38 | static auto __do_test(__tuple_types<_LArgs...>, |
| 46 | -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>; | 39 | __tuple_types<_RArgs...>) -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>; |
| 47 | template <template <class...> class> | 40 | template <template <class...> class> |
| 48 | static auto __do_test(...) -> false_type; | 41 | static auto __do_test(...) -> false_type; |
| 49 | 42 | ||
| 50 | template <class _FromArgs, class _ToArgs> | 43 | template <class _FromArgs, class _ToArgs> |
| 51 | using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{})); | 44 | using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{})); |
| 52 | template <class _FromArgs, class _ToArgs> | ||
| 53 | using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{})); | ||
| 54 | template <class _FromArgs, class _ToArgs> | ||
| 55 | using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{})); | ||
| 56 | }; | 45 | }; |
| 57 | 46 | ||
| 58 | // __tuple_convertible | ||
| 59 | |||
| 60 | template <class _Tp, | ||
| 61 | class _Up, | ||
| 62 | bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value, | ||
| 63 | bool = __tuple_like_ext<_Up>::value> | ||
| 64 | struct __tuple_convertible : public false_type {}; | ||
| 65 | |||
| 66 | template <class _Tp, class _Up> | ||
| 67 | struct __tuple_convertible<_Tp, _Up, true, true> | ||
| 68 | : public __tuple_sfinae_base::__convertible< typename __make_tuple_types<_Tp>::type, | ||
| 69 | typename __make_tuple_types<_Up>::type > {}; | ||
| 70 | |||
| 71 | // __tuple_constructible | 47 | // __tuple_constructible |
| 72 | 48 | ||
| 73 | template <class _Tp, | 49 | template <class _Tp, |
| ... | @@ -81,19 +57,6 @@ struct __tuple_constructible<_Tp, _Up, true, true> | ... | @@ -81,19 +57,6 @@ struct __tuple_constructible<_Tp, _Up, true, true> |
| 81 | : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type, | 57 | : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type, |
| 82 | typename __make_tuple_types<_Up>::type > {}; | 58 | typename __make_tuple_types<_Up>::type > {}; |
| 83 | 59 | ||
| 84 | // __tuple_assignable | ||
| 85 | |||
| 86 | template <class _Tp, | ||
| 87 | class _Up, | ||
| 88 | bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value, | ||
| 89 | bool = __tuple_like_ext<_Up>::value> | ||
| 90 | struct __tuple_assignable : public false_type {}; | ||
| 91 | |||
| 92 | template <class _Tp, class _Up> | ||
| 93 | struct __tuple_assignable<_Tp, _Up, true, true> | ||
| 94 | : public __tuple_sfinae_base::__assignable< typename __make_tuple_types<_Tp>::type, | ||
| 95 | typename __make_tuple_types<_Up&>::type > {}; | ||
| 96 | |||
| 97 | template <size_t _Ip, class... _Tp> | 60 | template <size_t _Ip, class... _Tp> |
| 98 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > { | 61 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > { |
| 99 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; | 62 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; |
lib/libcxx/include/__tuple/tuple_element.h+3-32| ... | @@ -12,9 +12,6 @@ | ... | @@ -12,9 +12,6 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__tuple/tuple_indices.h> | 13 | #include <__tuple/tuple_indices.h> |
| 14 | #include <__tuple/tuple_types.h> | 14 | #include <__tuple/tuple_types.h> |
| 15 | #include <__type_traits/add_const.h> | ||
| 16 | #include <__type_traits/add_cv.h> | ||
| 17 | #include <__type_traits/add_volatile.h> | ||
| 18 | #include <cstddef> | 15 | #include <cstddef> |
| 19 | 16 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -28,47 +25,21 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element; | ... | @@ -28,47 +25,21 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element; |
| 28 | 25 | ||
| 29 | template <size_t _Ip, class _Tp> | 26 | template <size_t _Ip, class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> { | 27 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> { |
| 31 | typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type; | 28 | typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type; |
| 32 | }; | 29 | }; |
| 33 | 30 | ||
| 34 | template <size_t _Ip, class _Tp> | 31 | template <size_t _Ip, class _Tp> |
| 35 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> { | 32 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> { |
| 36 | typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type; | 33 | typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type; |
| 37 | }; | 34 | }; |
| 38 | 35 | ||
| 39 | template <size_t _Ip, class _Tp> | 36 | template <size_t _Ip, class _Tp> |
| 40 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { | 37 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { |
| 41 | typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type; | 38 | typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type; |
| 42 | }; | 39 | }; |
| 43 | 40 | ||
| 44 | #ifndef _LIBCPP_CXX03_LANG | 41 | #ifndef _LIBCPP_CXX03_LANG |
| 45 | 42 | ||
| 46 | # if !__has_builtin(__type_pack_element) | ||
| 47 | |||
| 48 | namespace __indexer_detail { | ||
| 49 | |||
| 50 | template <size_t _Idx, class _Tp> | ||
| 51 | struct __indexed { | ||
| 52 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 53 | }; | ||
| 54 | |||
| 55 | template <class _Types, class _Indexes> | ||
| 56 | struct __indexer; | ||
| 57 | |||
| 58 | template <class... _Types, size_t... _Idx> | ||
| 59 | struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>> : __indexed<_Idx, _Types>... {}; | ||
| 60 | |||
| 61 | template <size_t _Idx, class _Tp> | ||
| 62 | __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&); | ||
| 63 | |||
| 64 | } // namespace __indexer_detail | ||
| 65 | |||
| 66 | template <size_t _Idx, class... _Types> | ||
| 67 | using __type_pack_element _LIBCPP_NODEBUG = typename decltype(__indexer_detail::__at_index<_Idx>( | ||
| 68 | __indexer_detail::__indexer< __tuple_types<_Types...>, | ||
| 69 | typename __make_tuple_indices<sizeof...(_Types)>::type >{}))::type; | ||
| 70 | # endif | ||
| 71 | |||
| 72 | template <size_t _Ip, class... _Types> | 43 | template <size_t _Ip, class... _Types> |
| 73 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > { | 44 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > { |
| 74 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); | 45 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); |
lib/libcxx/include/__tuple/tuple_like.h+9-18| ... | @@ -10,13 +10,10 @@ | ... | @@ -10,13 +10,10 @@ |
| 10 | #define _LIBCPP___TUPLE_TUPLE_LIKE_H | 10 | #define _LIBCPP___TUPLE_TUPLE_LIKE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__fwd/array.h> | ||
| 14 | #include <__fwd/pair.h> | ||
| 15 | #include <__fwd/subrange.h> | 13 | #include <__fwd/subrange.h> |
| 16 | #include <__fwd/tuple.h> | 14 | #include <__tuple/tuple_like_no_subrange.h> |
| 17 | #include <__type_traits/integral_constant.h> | 15 | #include <__tuple/tuple_size.h> |
| 18 | #include <__type_traits/remove_cvref.h> | 16 | #include <__type_traits/remove_cvref.h> |
| 19 | #include <cstddef> | ||
| 20 | 17 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | # pragma GCC system_header | 19 | # pragma GCC system_header |
| ... | @@ -27,22 +24,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,22 +24,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | #if _LIBCPP_STD_VER >= 20 | 24 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 25 | ||
| 29 | template <class _Tp> | 26 | template <class _Tp> |
| 30 | struct __tuple_like_impl : false_type {}; | 27 | inline constexpr bool __is_ranges_subrange_v = false; |
| 31 | 28 | ||
| 32 | template <class... _Tp> | 29 | template <class _Iter, class _Sent, ranges::subrange_kind _Kind> |
| 33 | struct __tuple_like_impl<tuple<_Tp...> > : true_type {}; | 30 | inline constexpr bool __is_ranges_subrange_v<ranges::subrange<_Iter, _Sent, _Kind>> = true; |
| 34 | |||
| 35 | template <class _T1, class _T2> | ||
| 36 | struct __tuple_like_impl<pair<_T1, _T2> > : true_type {}; | ||
| 37 | |||
| 38 | template <class _Tp, size_t _Size> | ||
| 39 | struct __tuple_like_impl<array<_Tp, _Size> > : true_type {}; | ||
| 40 | |||
| 41 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> | ||
| 42 | struct __tuple_like_impl<ranges::subrange<_Ip, _Sp, _Kp> > : true_type {}; | ||
| 43 | 31 | ||
| 44 | template <class _Tp> | 32 | template <class _Tp> |
| 45 | concept __tuple_like = __tuple_like_impl<remove_cvref_t<_Tp>>::value; | 33 | concept __tuple_like = __tuple_like_no_subrange<_Tp> || __is_ranges_subrange_v<remove_cvref_t<_Tp>>; |
| 34 | |||
| 35 | // As of writing this comment every use of `pair-like` in the standard excludes `ranges::subrange`, so | ||
| 36 | // you most likely want to use `__pair_like_no_subrange` if you're looking for `pair-like`. | ||
| 46 | 37 | ||
| 47 | #endif // _LIBCPP_STD_VER >= 20 | 38 | #endif // _LIBCPP_STD_VER >= 20 |
| 48 | 39 |
lib/libcxx/include/__tuple/tuple_like_no_subrange.h created+61| ... | @@ -0,0 +1,61 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H | ||
| 10 | #define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/array.h> | ||
| 14 | #include <__fwd/complex.h> | ||
| 15 | #include <__fwd/pair.h> | ||
| 16 | #include <__fwd/tuple.h> | ||
| 17 | #include <__tuple/tuple_size.h> | ||
| 18 | #include <__type_traits/remove_cvref.h> | ||
| 19 | #include <cstddef> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | #if _LIBCPP_STD_VER >= 20 | ||
| 28 | |||
| 29 | template <class _Tp> | ||
| 30 | inline constexpr bool __tuple_like_no_subrange_impl = false; | ||
| 31 | |||
| 32 | template <class... _Tp> | ||
| 33 | inline constexpr bool __tuple_like_no_subrange_impl<tuple<_Tp...>> = true; | ||
| 34 | |||
| 35 | template <class _T1, class _T2> | ||
| 36 | inline constexpr bool __tuple_like_no_subrange_impl<pair<_T1, _T2>> = true; | ||
| 37 | |||
| 38 | template <class _Tp, size_t _Size> | ||
| 39 | inline constexpr bool __tuple_like_no_subrange_impl<array<_Tp, _Size>> = true; | ||
| 40 | |||
| 41 | # if _LIBCPP_STD_VER >= 26 | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | inline constexpr bool __tuple_like_no_subrange_impl<complex<_Tp>> = true; | ||
| 45 | |||
| 46 | # endif | ||
| 47 | |||
| 48 | template <class _Tp> | ||
| 49 | concept __tuple_like_no_subrange = __tuple_like_no_subrange_impl<remove_cvref_t<_Tp>>; | ||
| 50 | |||
| 51 | // This is equivalent to the exposition-only type trait `pair-like`, except that it is false for specializations of | ||
| 52 | // `ranges::subrange`. This is more useful than the pair-like concept in the standard because every use of `pair-like` | ||
| 53 | // excludes `ranges::subrange`. | ||
| 54 | template <class _Tp> | ||
| 55 | concept __pair_like_no_subrange = __tuple_like_no_subrange<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2; | ||
| 56 | |||
| 57 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 58 | |||
| 59 | _LIBCPP_END_NAMESPACE_STD | ||
| 60 | |||
| 61 | #endif // _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H | ||
lib/libcxx/include/__tuple/tuple_size.h+6-1| ... | @@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp, | ... | @@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp, |
| 43 | 43 | ||
| 44 | template <class _Tp> | 44 | template <class _Tp> |
| 45 | struct _LIBCPP_TEMPLATE_VIS | 45 | struct _LIBCPP_TEMPLATE_VIS |
| 46 | tuple_size<__enable_if_tuple_size_imp< const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> | 46 | tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> |
| 47 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; | 47 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; |
| 48 | 48 | ||
| 49 | #else | 49 | #else |
| ... | @@ -63,6 +63,11 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constan | ... | @@ -63,6 +63,11 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constan |
| 63 | template <class... _Tp> | 63 | template <class... _Tp> |
| 64 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; | 64 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; |
| 65 | 65 | ||
| 66 | # if _LIBCPP_STD_VER >= 17 | ||
| 67 | template <class _Tp> | ||
| 68 | inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; | ||
| 69 | # endif | ||
| 70 | |||
| 66 | #endif // _LIBCPP_CXX03_LANG | 71 | #endif // _LIBCPP_CXX03_LANG |
| 67 | 72 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | 73 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/add_pointer.h-2| ... | @@ -11,9 +11,7 @@ | ... | @@ -11,9 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_referenceable.h> | 13 | #include <__type_traits/is_referenceable.h> |
| 14 | #include <__type_traits/is_same.h> | ||
| 15 | #include <__type_traits/is_void.h> | 14 | #include <__type_traits/is_void.h> |
| 16 | #include <__type_traits/remove_cv.h> | ||
| 17 | #include <__type_traits/remove_reference.h> | 15 | #include <__type_traits/remove_reference.h> |
| 18 | 16 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__type_traits/apply_cv.h deleted-78| ... | @@ -1,78 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_APPLY_CV_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_APPLY_CV_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/is_const.h> | ||
| 14 | #include <__type_traits/is_volatile.h> | ||
| 15 | #include <__type_traits/remove_reference.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp, | ||
| 24 | bool = is_const<__libcpp_remove_reference_t<_Tp> >::value, | ||
| 25 | bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value> | ||
| 26 | struct __apply_cv_impl { | ||
| 27 | template <class _Up> | ||
| 28 | using __apply _LIBCPP_NODEBUG = _Up; | ||
| 29 | }; | ||
| 30 | |||
| 31 | template <class _Tp> | ||
| 32 | struct __apply_cv_impl<_Tp, true, false> { | ||
| 33 | template <class _Up> | ||
| 34 | using __apply _LIBCPP_NODEBUG = const _Up; | ||
| 35 | }; | ||
| 36 | |||
| 37 | template <class _Tp> | ||
| 38 | struct __apply_cv_impl<_Tp, false, true> { | ||
| 39 | template <class _Up> | ||
| 40 | using __apply _LIBCPP_NODEBUG = volatile _Up; | ||
| 41 | }; | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | struct __apply_cv_impl<_Tp, true, true> { | ||
| 45 | template <class _Up> | ||
| 46 | using __apply _LIBCPP_NODEBUG = const volatile _Up; | ||
| 47 | }; | ||
| 48 | |||
| 49 | template <class _Tp> | ||
| 50 | struct __apply_cv_impl<_Tp&, false, false> { | ||
| 51 | template <class _Up> | ||
| 52 | using __apply _LIBCPP_NODEBUG = _Up&; | ||
| 53 | }; | ||
| 54 | |||
| 55 | template <class _Tp> | ||
| 56 | struct __apply_cv_impl<_Tp&, true, false> { | ||
| 57 | template <class _Up> | ||
| 58 | using __apply _LIBCPP_NODEBUG = const _Up&; | ||
| 59 | }; | ||
| 60 | |||
| 61 | template <class _Tp> | ||
| 62 | struct __apply_cv_impl<_Tp&, false, true> { | ||
| 63 | template <class _Up> | ||
| 64 | using __apply _LIBCPP_NODEBUG = volatile _Up&; | ||
| 65 | }; | ||
| 66 | |||
| 67 | template <class _Tp> | ||
| 68 | struct __apply_cv_impl<_Tp&, true, true> { | ||
| 69 | template <class _Up> | ||
| 70 | using __apply _LIBCPP_NODEBUG = const volatile _Up&; | ||
| 71 | }; | ||
| 72 | |||
| 73 | template <class _Tp, class _Up> | ||
| 74 | using __apply_cv_t _LIBCPP_NODEBUG = typename __apply_cv_impl<_Tp>::template __apply<_Up>; | ||
| 75 | |||
| 76 | _LIBCPP_END_NAMESPACE_STD | ||
| 77 | |||
| 78 | #endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H | ||
lib/libcxx/include/__type_traits/common_type.h+3-3| ... | @@ -82,9 +82,9 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> : public common_type<_Tp, _Tp> {}; | ... | @@ -82,9 +82,9 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> : public common_type<_Tp, _Tp> {}; |
| 82 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." | 82 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." |
| 83 | template <class _Tp, class _Up> | 83 | template <class _Tp, class _Up> |
| 84 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> | 84 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> |
| 85 | : conditional<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value, | 85 | : __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value, |
| 86 | __common_type2_imp<_Tp, _Up>, | 86 | __common_type2_imp<_Tp, _Up>, |
| 87 | common_type<__decay_t<_Tp>, __decay_t<_Up> > >::type {}; | 87 | common_type<__decay_t<_Tp>, __decay_t<_Up> > > {}; |
| 88 | 88 | ||
| 89 | // bullet 4 - sizeof...(Tp) > 2 | 89 | // bullet 4 - sizeof...(Tp) > 2 |
| 90 | 90 |
lib/libcxx/include/__type_traits/conjunction.h+7| ... | @@ -13,6 +13,7 @@ | ... | @@ -13,6 +13,7 @@ |
| 13 | #include <__type_traits/conditional.h> | 13 | #include <__type_traits/conditional.h> |
| 14 | #include <__type_traits/enable_if.h> | 14 | #include <__type_traits/enable_if.h> |
| 15 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 16 | #include <__type_traits/is_same.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 |
| ... | @@ -37,6 +38,12 @@ false_type __and_helper(...); | ... | @@ -37,6 +38,12 @@ false_type __and_helper(...); |
| 37 | template <class... _Pred> | 38 | template <class... _Pred> |
| 38 | using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0)); | 39 | using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0)); |
| 39 | 40 | ||
| 41 | template <bool... _Preds> | ||
| 42 | struct __all_dummy; | ||
| 43 | |||
| 44 | template <bool... _Pred> | ||
| 45 | struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...> > {}; | ||
| 46 | |||
| 40 | #if _LIBCPP_STD_VER >= 17 | 47 | #if _LIBCPP_STD_VER >= 17 |
| 41 | 48 | ||
| 42 | template <class...> | 49 | template <class...> |
lib/libcxx/include/__type_traits/copy_cv.h+16-15| ... | @@ -10,9 +10,6 @@ | ... | @@ -10,9 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_COPY_CV_H | 10 | #define _LIBCPP___TYPE_TRAITS_COPY_CV_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_const.h> | ||
| 14 | #include <__type_traits/add_cv.h> | ||
| 15 | #include <__type_traits/add_volatile.h> | ||
| 16 | 13 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -22,28 +19,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,28 +19,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | ||
| 23 | // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's | 20 | // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's |
| 24 | // top-level cv-qualifiers. | 21 | // top-level cv-qualifiers. |
| 25 | template <class _From, class _To> | 22 | template <class _From> |
| 26 | struct __copy_cv { | 23 | struct __copy_cv { |
| 27 | using type = _To; | 24 | template <class _To> |
| 25 | using __apply = _To; | ||
| 28 | }; | 26 | }; |
| 29 | 27 | ||
| 30 | template <class _From, class _To> | 28 | template <class _From> |
| 31 | struct __copy_cv<const _From, _To> { | 29 | struct __copy_cv<const _From> { |
| 32 | using type = typename add_const<_To>::type; | 30 | template <class _To> |
| 31 | using __apply = const _To; | ||
| 33 | }; | 32 | }; |
| 34 | 33 | ||
| 35 | template <class _From, class _To> | 34 | template <class _From> |
| 36 | struct __copy_cv<volatile _From, _To> { | 35 | struct __copy_cv<volatile _From> { |
| 37 | using type = typename add_volatile<_To>::type; | 36 | template <class _To> |
| 37 | using __apply = volatile _To; | ||
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | template <class _From, class _To> | 40 | template <class _From> |
| 41 | struct __copy_cv<const volatile _From, _To> { | 41 | struct __copy_cv<const volatile _From> { |
| 42 | using type = typename add_cv<_To>::type; | 42 | template <class _To> |
| 43 | using __apply = const volatile _To; | ||
| 43 | }; | 44 | }; |
| 44 | 45 | ||
| 45 | template <class _From, class _To> | 46 | template <class _From, class _To> |
| 46 | using __copy_cv_t = typename __copy_cv<_From, _To>::type; | 47 | using __copy_cv_t = typename __copy_cv<_From>::template __apply<_To>; |
| 47 | 48 | ||
| 48 | _LIBCPP_END_NAMESPACE_STD | 49 | _LIBCPP_END_NAMESPACE_STD |
| 49 | 50 |
lib/libcxx/include/__type_traits/datasizeof.h+24-24| ... | @@ -26,39 +26,39 @@ | ... | @@ -26,39 +26,39 @@ |
| 26 | 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | #if __has_keyword(__datasizeof) || __has_extension(datasizeof) | ||
| 29 | template <class _Tp> | 30 | template <class _Tp> |
| 30 | struct __libcpp_datasizeof { | 31 | inline const size_t __datasizeof_v = __datasizeof(_Tp); |
| 31 | #if __has_extension(datasizeof) | ||
| 32 | static const size_t value = __datasizeof(_Tp); | ||
| 33 | #else | 32 | #else |
| 34 | // NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825 | 33 | // NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825 |
| 35 | # if __has_cpp_attribute(__no_unique_address__) | 34 | # if __has_cpp_attribute(__no_unique_address__) |
| 36 | template <class = char> | 35 | template <class _Tp> |
| 37 | struct _FirstPaddingByte { | 36 | struct _FirstPaddingByte { |
| 38 | [[__no_unique_address__]] _Tp __v_; | 37 | [[__no_unique_address__]] _Tp __v_; |
| 39 | char __first_padding_byte_; | 38 | char __first_padding_byte_; |
| 40 | }; | 39 | }; |
| 41 | # else | 40 | # else |
| 42 | template <bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value> | 41 | template <class _Tp, bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value> |
| 43 | struct _FirstPaddingByte : _Tp { | 42 | struct _FirstPaddingByte : _Tp { |
| 44 | char __first_padding_byte_; | 43 | char __first_padding_byte_; |
| 45 | }; | 44 | }; |
| 46 | 45 | ||
| 47 | template <> | 46 | template <class _Tp> |
| 48 | struct _FirstPaddingByte<true> { | 47 | struct _FirstPaddingByte<_Tp, true> { |
| 49 | _Tp __v_; | 48 | _Tp __v_; |
| 50 | char __first_padding_byte_; | 49 | char __first_padding_byte_; |
| 51 | }; | 50 | }; |
| 52 | # endif // __has_cpp_attribute(__no_unique_address__) | 51 | # endif // __has_cpp_attribute(__no_unique_address__) |
| 53 | 52 | ||
| 54 | // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow | 53 | // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow |
| 55 | // the use as an extension. | 54 | // the use as an extension. |
| 56 | _LIBCPP_DIAGNOSTIC_PUSH | 55 | _LIBCPP_DIAGNOSTIC_PUSH |
| 57 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") | 56 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") |
| 58 | static const size_t value = offsetof(_FirstPaddingByte<>, __first_padding_byte_); | 57 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") |
| 59 | _LIBCPP_DIAGNOSTIC_POP | 58 | template <class _Tp> |
| 59 | inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); | ||
| 60 | _LIBCPP_DIAGNOSTIC_POP | ||
| 60 | #endif // __has_extension(datasizeof) | 61 | #endif // __has_extension(datasizeof) |
| 61 | }; | ||
| 62 | 62 | ||
| 63 | _LIBCPP_END_NAMESPACE_STD | 63 | _LIBCPP_END_NAMESPACE_STD |
| 64 | 64 |
lib/libcxx/include/__type_traits/decay.h+5-5| ... | @@ -43,11 +43,11 @@ struct __decay { | ... | @@ -43,11 +43,11 @@ struct __decay { |
| 43 | template <class _Up> | 43 | template <class _Up> |
| 44 | struct __decay<_Up, true> { | 44 | struct __decay<_Up, true> { |
| 45 | public: | 45 | public: |
| 46 | typedef _LIBCPP_NODEBUG typename conditional< | 46 | typedef _LIBCPP_NODEBUG |
| 47 | is_array<_Up>::value, | 47 | __conditional_t<is_array<_Up>::value, |
| 48 | __add_pointer_t<__remove_extent_t<_Up> >, | 48 | __add_pointer_t<__remove_extent_t<_Up> >, |
| 49 | typename conditional<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> >::type >::type | 49 | __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > > |
| 50 | type; | 50 | type; |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | template <class _Tp> | 53 | template <class _Tp> |
lib/libcxx/include/__type_traits/desugars_to.h created+40| ... | @@ -0,0 +1,40 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | // Tags to represent the canonical operations | ||
| 21 | struct __equal_tag {}; | ||
| 22 | struct __plus_tag {}; | ||
| 23 | struct __less_tag {}; | ||
| 24 | |||
| 25 | // This class template is used to determine whether an operation "desugars" | ||
| 26 | // (or boils down) to a given canonical operation. | ||
| 27 | // | ||
| 28 | // For example, `std::equal_to<>`, our internal `std::__equal_to` helper and | ||
| 29 | // `ranges::equal_to` are all just fancy ways of representing a transparent | ||
| 30 | // equality operation, so they all desugar to `__equal_tag`. | ||
| 31 | // | ||
| 32 | // This is useful to optimize some functions in cases where we know e.g. the | ||
| 33 | // predicate being passed is actually going to call a builtin operator, or has | ||
| 34 | // some specific semantics. | ||
| 35 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 36 | inline const bool __desugars_to_v = false; | ||
| 37 | |||
| 38 | _LIBCPP_END_NAMESPACE_STD | ||
| 39 | |||
| 40 | #endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H | ||
lib/libcxx/include/__type_traits/has_unique_object_representation.h+7-3| ... | @@ -12,7 +12,6 @@ | ... | @@ -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/remove_all_extents.h> | 14 | #include <__type_traits/remove_all_extents.h> |
| 15 | #include <__type_traits/remove_cv.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 |
| ... | @@ -24,10 +23,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,10 +23,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 23 | ||
| 25 | template <class _Tp> | 24 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations | 25 | struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations |
| 27 | : public integral_constant<bool, __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; | 26 | // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents |
| 27 | // even though it should not be necessary. This was reported to the compilers: | ||
| 28 | // - Clang: https://github.com/llvm/llvm-project/issues/95311 | ||
| 29 | // - GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115476 | ||
| 30 | // remove_all_extents_t can be removed once all the compilers we support have fixed this bug. | ||
| 31 | : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {}; | ||
| 28 | 32 | ||
| 29 | template <class _Tp> | 33 | template <class _Tp> |
| 30 | inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value; | 34 | inline constexpr bool has_unique_object_representations_v = __has_unique_object_representations(_Tp); |
| 31 | 35 | ||
| 32 | #endif | 36 | #endif |
| 33 | 37 |
lib/libcxx/include/__type_traits/invoke.h+4-199| ... | @@ -11,21 +11,17 @@ | ... | @@ -11,21 +11,17 @@ |
| 11 | #define _LIBCPP___TYPE_TRAITS_INVOKE_H | 11 | #define _LIBCPP___TYPE_TRAITS_INVOKE_H |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/apply_cv.h> | ||
| 16 | #include <__type_traits/conditional.h> | 14 | #include <__type_traits/conditional.h> |
| 17 | #include <__type_traits/decay.h> | 15 | #include <__type_traits/decay.h> |
| 18 | #include <__type_traits/enable_if.h> | 16 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/integral_constant.h> | 17 | #include <__type_traits/integral_constant.h> |
| 20 | #include <__type_traits/is_base_of.h> | 18 | #include <__type_traits/is_base_of.h> |
| 21 | #include <__type_traits/is_core_convertible.h> | 19 | #include <__type_traits/is_core_convertible.h> |
| 22 | #include <__type_traits/is_member_function_pointer.h> | 20 | #include <__type_traits/is_member_pointer.h> |
| 23 | #include <__type_traits/is_member_object_pointer.h> | ||
| 24 | #include <__type_traits/is_reference_wrapper.h> | 21 | #include <__type_traits/is_reference_wrapper.h> |
| 25 | #include <__type_traits/is_same.h> | 22 | #include <__type_traits/is_same.h> |
| 26 | #include <__type_traits/is_void.h> | 23 | #include <__type_traits/is_void.h> |
| 27 | #include <__type_traits/nat.h> | 24 | #include <__type_traits/nat.h> |
| 28 | #include <__type_traits/remove_cv.h> | ||
| 29 | #include <__utility/declval.h> | 25 | #include <__utility/declval.h> |
| 30 | #include <__utility/forward.h> | 26 | #include <__utility/forward.h> |
| 31 | 27 | ||
| ... | @@ -35,197 +31,6 @@ | ... | @@ -35,197 +31,6 @@ |
| 35 | 31 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 33 | ||
| 38 | struct __any { | ||
| 39 | __any(...); | ||
| 40 | }; | ||
| 41 | |||
| 42 | template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> | ||
| 43 | struct __member_pointer_traits_imp {}; | ||
| 44 | |||
| 45 | template <class _Rp, class _Class, class... _Param> | ||
| 46 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> { | ||
| 47 | typedef _Class _ClassType; | ||
| 48 | typedef _Rp _ReturnType; | ||
| 49 | typedef _Rp(_FnType)(_Param...); | ||
| 50 | }; | ||
| 51 | |||
| 52 | template <class _Rp, class _Class, class... _Param> | ||
| 53 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> { | ||
| 54 | typedef _Class _ClassType; | ||
| 55 | typedef _Rp _ReturnType; | ||
| 56 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 57 | }; | ||
| 58 | |||
| 59 | template <class _Rp, class _Class, class... _Param> | ||
| 60 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> { | ||
| 61 | typedef _Class const _ClassType; | ||
| 62 | typedef _Rp _ReturnType; | ||
| 63 | typedef _Rp(_FnType)(_Param...); | ||
| 64 | }; | ||
| 65 | |||
| 66 | template <class _Rp, class _Class, class... _Param> | ||
| 67 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> { | ||
| 68 | typedef _Class const _ClassType; | ||
| 69 | typedef _Rp _ReturnType; | ||
| 70 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 71 | }; | ||
| 72 | |||
| 73 | template <class _Rp, class _Class, class... _Param> | ||
| 74 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> { | ||
| 75 | typedef _Class volatile _ClassType; | ||
| 76 | typedef _Rp _ReturnType; | ||
| 77 | typedef _Rp(_FnType)(_Param...); | ||
| 78 | }; | ||
| 79 | |||
| 80 | template <class _Rp, class _Class, class... _Param> | ||
| 81 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> { | ||
| 82 | typedef _Class volatile _ClassType; | ||
| 83 | typedef _Rp _ReturnType; | ||
| 84 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 85 | }; | ||
| 86 | |||
| 87 | template <class _Rp, class _Class, class... _Param> | ||
| 88 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> { | ||
| 89 | typedef _Class const volatile _ClassType; | ||
| 90 | typedef _Rp _ReturnType; | ||
| 91 | typedef _Rp(_FnType)(_Param...); | ||
| 92 | }; | ||
| 93 | |||
| 94 | template <class _Rp, class _Class, class... _Param> | ||
| 95 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> { | ||
| 96 | typedef _Class const volatile _ClassType; | ||
| 97 | typedef _Rp _ReturnType; | ||
| 98 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 99 | }; | ||
| 100 | |||
| 101 | template <class _Rp, class _Class, class... _Param> | ||
| 102 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...)&, true, false> { | ||
| 103 | typedef _Class& _ClassType; | ||
| 104 | typedef _Rp _ReturnType; | ||
| 105 | typedef _Rp(_FnType)(_Param...); | ||
| 106 | }; | ||
| 107 | |||
| 108 | template <class _Rp, class _Class, class... _Param> | ||
| 109 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...)&, true, false> { | ||
| 110 | typedef _Class& _ClassType; | ||
| 111 | typedef _Rp _ReturnType; | ||
| 112 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 113 | }; | ||
| 114 | |||
| 115 | template <class _Rp, class _Class, class... _Param> | ||
| 116 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> { | ||
| 117 | typedef _Class const& _ClassType; | ||
| 118 | typedef _Rp _ReturnType; | ||
| 119 | typedef _Rp(_FnType)(_Param...); | ||
| 120 | }; | ||
| 121 | |||
| 122 | template <class _Rp, class _Class, class... _Param> | ||
| 123 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> { | ||
| 124 | typedef _Class const& _ClassType; | ||
| 125 | typedef _Rp _ReturnType; | ||
| 126 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 127 | }; | ||
| 128 | |||
| 129 | template <class _Rp, class _Class, class... _Param> | ||
| 130 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> { | ||
| 131 | typedef _Class volatile& _ClassType; | ||
| 132 | typedef _Rp _ReturnType; | ||
| 133 | typedef _Rp(_FnType)(_Param...); | ||
| 134 | }; | ||
| 135 | |||
| 136 | template <class _Rp, class _Class, class... _Param> | ||
| 137 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> { | ||
| 138 | typedef _Class volatile& _ClassType; | ||
| 139 | typedef _Rp _ReturnType; | ||
| 140 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 141 | }; | ||
| 142 | |||
| 143 | template <class _Rp, class _Class, class... _Param> | ||
| 144 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> { | ||
| 145 | typedef _Class const volatile& _ClassType; | ||
| 146 | typedef _Rp _ReturnType; | ||
| 147 | typedef _Rp(_FnType)(_Param...); | ||
| 148 | }; | ||
| 149 | |||
| 150 | template <class _Rp, class _Class, class... _Param> | ||
| 151 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> { | ||
| 152 | typedef _Class const volatile& _ClassType; | ||
| 153 | typedef _Rp _ReturnType; | ||
| 154 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 155 | }; | ||
| 156 | |||
| 157 | template <class _Rp, class _Class, class... _Param> | ||
| 158 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...)&&, true, false> { | ||
| 159 | typedef _Class&& _ClassType; | ||
| 160 | typedef _Rp _ReturnType; | ||
| 161 | typedef _Rp(_FnType)(_Param...); | ||
| 162 | }; | ||
| 163 | |||
| 164 | template <class _Rp, class _Class, class... _Param> | ||
| 165 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...)&&, true, false> { | ||
| 166 | typedef _Class&& _ClassType; | ||
| 167 | typedef _Rp _ReturnType; | ||
| 168 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 169 | }; | ||
| 170 | |||
| 171 | template <class _Rp, class _Class, class... _Param> | ||
| 172 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> { | ||
| 173 | typedef _Class const&& _ClassType; | ||
| 174 | typedef _Rp _ReturnType; | ||
| 175 | typedef _Rp(_FnType)(_Param...); | ||
| 176 | }; | ||
| 177 | |||
| 178 | template <class _Rp, class _Class, class... _Param> | ||
| 179 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> { | ||
| 180 | typedef _Class const&& _ClassType; | ||
| 181 | typedef _Rp _ReturnType; | ||
| 182 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 183 | }; | ||
| 184 | |||
| 185 | template <class _Rp, class _Class, class... _Param> | ||
| 186 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> { | ||
| 187 | typedef _Class volatile&& _ClassType; | ||
| 188 | typedef _Rp _ReturnType; | ||
| 189 | typedef _Rp(_FnType)(_Param...); | ||
| 190 | }; | ||
| 191 | |||
| 192 | template <class _Rp, class _Class, class... _Param> | ||
| 193 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> { | ||
| 194 | typedef _Class volatile&& _ClassType; | ||
| 195 | typedef _Rp _ReturnType; | ||
| 196 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 197 | }; | ||
| 198 | |||
| 199 | template <class _Rp, class _Class, class... _Param> | ||
| 200 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> { | ||
| 201 | typedef _Class const volatile&& _ClassType; | ||
| 202 | typedef _Rp _ReturnType; | ||
| 203 | typedef _Rp(_FnType)(_Param...); | ||
| 204 | }; | ||
| 205 | |||
| 206 | template <class _Rp, class _Class, class... _Param> | ||
| 207 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> { | ||
| 208 | typedef _Class const volatile&& _ClassType; | ||
| 209 | typedef _Rp _ReturnType; | ||
| 210 | typedef _Rp(_FnType)(_Param..., ...); | ||
| 211 | }; | ||
| 212 | |||
| 213 | template <class _Rp, class _Class> | ||
| 214 | struct __member_pointer_traits_imp<_Rp _Class::*, false, true> { | ||
| 215 | typedef _Class _ClassType; | ||
| 216 | typedef _Rp _ReturnType; | ||
| 217 | }; | ||
| 218 | |||
| 219 | template <class _MP> | ||
| 220 | struct __member_pointer_traits | ||
| 221 | : public __member_pointer_traits_imp<__remove_cv_t<_MP>, | ||
| 222 | is_member_function_pointer<_MP>::value, | ||
| 223 | is_member_object_pointer<_MP>::value> { | ||
| 224 | // typedef ... _ClassType; | ||
| 225 | // typedef ... _ReturnType; | ||
| 226 | // typedef ... _FnType; | ||
| 227 | }; | ||
| 228 | |||
| 229 | template <class _DecayedFp> | 34 | template <class _DecayedFp> |
| 230 | struct __member_pointer_class_type {}; | 35 | struct __member_pointer_class_type {}; |
| 231 | 36 | ||
| ... | @@ -285,7 +90,7 @@ using __enable_if_bullet6 = | ... | @@ -285,7 +90,7 @@ using __enable_if_bullet6 = |
| 285 | // fall back - none of the bullets | 90 | // fall back - none of the bullets |
| 286 | 91 | ||
| 287 | template <class... _Args> | 92 | template <class... _Args> |
| 288 | __nat __invoke(__any, _Args&&... __args); | 93 | __nat __invoke(_Args&&... __args); |
| 289 | 94 | ||
| 290 | // bullets 1, 2 and 3 | 95 | // bullets 1, 2 and 3 |
| 291 | 96 | ||
| ... | @@ -357,8 +162,8 @@ struct __invokable_r { | ... | @@ -357,8 +162,8 @@ struct __invokable_r { |
| 357 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); | 162 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); |
| 358 | 163 | ||
| 359 | using type = __conditional_t<_IsNotSame<_Result, __nat>::value, | 164 | using type = __conditional_t<_IsNotSame<_Result, __nat>::value, |
| 360 | __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >, | 165 | __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >, |
| 361 | false_type>; | 166 | false_type>; |
| 362 | static const bool value = type::value; | 167 | static const bool value = type::value; |
| 363 | }; | 168 | }; |
| 364 | template <class _Fp, class... _Args> | 169 | template <class _Fp, class... _Args> |
lib/libcxx/include/__type_traits/is_array.h+2-3| ... | @@ -19,9 +19,8 @@ | ... | @@ -19,9 +19,8 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | // TODO: Clang incorrectly reports that __is_array is true for T[0]. | 22 | #if __has_builtin(__is_array) && \ |
| 23 | // Re-enable the branch once https://llvm.org/PR54705 is fixed. | 23 | (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900)) |
| 24 | #if __has_builtin(__is_array) && 0 | ||
| 25 | 24 | ||
| 26 | template <class _Tp> | 25 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> {}; | 26 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> {}; |
lib/libcxx/include/__type_traits/is_assignable.h+21| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 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> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 14 | 16 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,6 +28,25 @@ template <class _Tp, class _Arg> | ... | @@ -26,6 +28,25 @@ template <class _Tp, class _Arg> |
| 26 | inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); | 28 | inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); |
| 27 | #endif | 29 | #endif |
| 28 | 30 | ||
| 31 | template <class _Tp> | ||
| 32 | struct _LIBCPP_TEMPLATE_VIS is_copy_assignable | ||
| 33 | : public integral_constant<bool, | ||
| 34 | __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 35 | |||
| 36 | #if _LIBCPP_STD_VER >= 17 | ||
| 37 | template <class _Tp> | ||
| 38 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | ||
| 39 | #endif | ||
| 40 | |||
| 41 | template <class _Tp> | ||
| 42 | struct _LIBCPP_TEMPLATE_VIS is_move_assignable | ||
| 43 | : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 44 | |||
| 45 | #if _LIBCPP_STD_VER >= 17 | ||
| 46 | template <class _Tp> | ||
| 47 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | ||
| 48 | #endif | ||
| 49 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | 50 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 51 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H | 52 | #endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_constructible.h+28| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 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> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 14 | 16 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,6 +28,32 @@ template <class _Tp, class... _Args> | ... | @@ -26,6 +28,32 @@ template <class _Tp, class... _Args> |
| 26 | inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...); | 28 | inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...); |
| 27 | #endif | 29 | #endif |
| 28 | 30 | ||
| 31 | template <class _Tp> | ||
| 32 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible | ||
| 33 | : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 34 | |||
| 35 | #if _LIBCPP_STD_VER >= 17 | ||
| 36 | template <class _Tp> | ||
| 37 | inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | ||
| 38 | #endif | ||
| 39 | |||
| 40 | template <class _Tp> | ||
| 41 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible | ||
| 42 | : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 43 | |||
| 44 | #if _LIBCPP_STD_VER >= 17 | ||
| 45 | template <class _Tp> | ||
| 46 | inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | ||
| 47 | #endif | ||
| 48 | |||
| 49 | template <class _Tp> | ||
| 50 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {}; | ||
| 51 | |||
| 52 | #if _LIBCPP_STD_VER >= 17 | ||
| 53 | template <class _Tp> | ||
| 54 | inline constexpr bool is_default_constructible_v = __is_constructible(_Tp); | ||
| 55 | #endif | ||
| 56 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | 57 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 58 | ||
| 31 | #endif // _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H | 59 | #endif // _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_convertible.h-6| ... | @@ -11,12 +11,6 @@ | ... | @@ -11,12 +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_array.h> | ||
| 15 | #include <__type_traits/is_function.h> | ||
| 16 | #include <__type_traits/is_void.h> | ||
| 17 | #include <__type_traits/remove_reference.h> | ||
| 18 | #include <__utility/declval.h> | ||
| 19 | #include <cstddef> | ||
| 20 | 14 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | # pragma GCC system_header | 16 | # pragma GCC system_header |
lib/libcxx/include/__type_traits/is_copy_assignable.h deleted-36| ... | @@ -1,36 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_const.h> | ||
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_copy_assignable | ||
| 25 | : public integral_constant< | ||
| 26 | bool, | ||
| 27 | __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {}; | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | template <class _Tp> | ||
| 31 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | ||
| 35 | |||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | ||
lib/libcxx/include/__type_traits/is_copy_constructible.h deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_const.h> | ||
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible | ||
| 25 | : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> { | ||
| 26 | }; | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER >= 17 | ||
| 29 | template <class _Tp> | ||
| 30 | inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | ||
| 31 | #endif | ||
| 32 | |||
| 33 | _LIBCPP_END_NAMESPACE_STD | ||
| 34 | |||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_default_constructible.h deleted-31| ... | @@ -1,31 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp> | ||
| 22 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {}; | ||
| 23 | |||
| 24 | #if _LIBCPP_STD_VER >= 17 | ||
| 25 | template <class _Tp> | ||
| 26 | inline constexpr bool is_default_constructible_v = __is_constructible(_Tp); | ||
| 27 | #endif | ||
| 28 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | ||
| 30 | |||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_enum.h+10| ... | @@ -26,6 +26,16 @@ template <class _Tp> | ... | @@ -26,6 +26,16 @@ template <class _Tp> |
| 26 | inline constexpr bool is_enum_v = __is_enum(_Tp); | 26 | inline constexpr bool is_enum_v = __is_enum(_Tp); |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 23 | ||
| 30 | |||
| 31 | template <class _Tp> | ||
| 32 | struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; | ||
| 33 | |||
| 34 | template <class _Tp> | ||
| 35 | inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); | ||
| 36 | |||
| 37 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 38 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | 39 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 40 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H | 41 | #endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H |
lib/libcxx/include/__type_traits/is_equality_comparable.h+2-1| ... | @@ -17,7 +17,6 @@ | ... | @@ -17,7 +17,6 @@ |
| 17 | #include <__type_traits/is_signed.h> | 17 | #include <__type_traits/is_signed.h> |
| 18 | #include <__type_traits/is_void.h> | 18 | #include <__type_traits/is_void.h> |
| 19 | #include <__type_traits/remove_cv.h> | 19 | #include <__type_traits/remove_cv.h> |
| 20 | #include <__type_traits/remove_cvref.h> | ||
| 21 | #include <__type_traits/void_t.h> | 20 | #include <__type_traits/void_t.h> |
| 22 | #include <__utility/declval.h> | 21 | #include <__utility/declval.h> |
| 23 | 22 | ||
| ... | @@ -45,6 +44,8 @@ struct __is_equality_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() | ... | @@ -45,6 +44,8 @@ struct __is_equality_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() |
| 45 | // pointers that don't have the same type (ignoring cv-qualifiers): pointers to virtual bases are equality comparable, | 44 | // pointers that don't have the same type (ignoring cv-qualifiers): pointers to virtual bases are equality comparable, |
| 46 | // but don't have the same bit-pattern. An exception to this is comparing to a void-pointer. There the bit-pattern is | 45 | // but don't have the same bit-pattern. An exception to this is comparing to a void-pointer. There the bit-pattern is |
| 47 | // always compared. | 46 | // always compared. |
| 47 | // objects with padding bytes: since objects with padding bytes may compare equal, even though their object | ||
| 48 | // representation may not be equivalent. | ||
| 48 | 49 | ||
| 49 | template <class _Tp, class _Up, class = void> | 50 | template <class _Tp, class _Up, class = void> |
| 50 | struct __libcpp_is_trivially_equality_comparable_impl : false_type {}; | 51 | struct __libcpp_is_trivially_equality_comparable_impl : false_type {}; |
lib/libcxx/include/__type_traits/is_function.h+1-13| ... | @@ -11,8 +11,6 @@ | ... | @@ -11,8 +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_const.h> | ||
| 15 | #include <__type_traits/is_reference.h> | ||
| 16 | 14 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -20,22 +18,12 @@ | ... | @@ -20,22 +18,12 @@ |
| 20 | 18 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 20 | ||
| 23 | #if __has_builtin(__is_function) | ||
| 24 | |||
| 25 | template <class _Tp> | 21 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {}; | 22 | struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {}; |
| 27 | 23 | ||
| 28 | #else | ||
| 29 | |||
| 30 | template <class _Tp> | ||
| 31 | struct _LIBCPP_TEMPLATE_VIS is_function | ||
| 32 | : public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {}; | ||
| 33 | |||
| 34 | #endif // __has_builtin(__is_function) | ||
| 35 | |||
| 36 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 37 | template <class _Tp> | 25 | template <class _Tp> |
| 38 | inline constexpr bool is_function_v = is_function<_Tp>::value; | 26 | inline constexpr bool is_function_v = __is_function(_Tp); |
| 39 | #endif | 27 | #endif |
| 40 | 28 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_fundamental.h+1-1| ... | @@ -34,7 +34,7 @@ inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); | ... | @@ -34,7 +34,7 @@ inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); |
| 34 | 34 | ||
| 35 | template <class _Tp> | 35 | template <class _Tp> |
| 36 | struct _LIBCPP_TEMPLATE_VIS is_fundamental | 36 | struct _LIBCPP_TEMPLATE_VIS is_fundamental |
| 37 | : public integral_constant<bool, is_void<_Tp>::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; | 37 | : public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {}; |
| 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_implicitly_default_constructible.h+1-1| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 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_default_constructible.h> | 14 | #include <__type_traits/is_constructible.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 |
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 is_literal_type | 23 | struct _LIBCPP_TEMPLATE_VIS |
| 24 | : public integral_constant<bool, __is_literal_type(_Tp)> {}; | 24 | _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type : public 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_function_pointer.h deleted-62| ... | @@ -1,62 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | #include <__type_traits/is_function.h> | ||
| 15 | #include <__type_traits/remove_cv.h> | ||
| 16 | #include <cstddef> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | template <class _Tp> | ||
| 25 | struct __libcpp_is_member_pointer { | ||
| 26 | enum { __is_member = false, __is_func = false, __is_obj = false }; | ||
| 27 | }; | ||
| 28 | template <class _Tp, class _Up> | ||
| 29 | struct __libcpp_is_member_pointer<_Tp _Up::*> { | ||
| 30 | enum { | ||
| 31 | __is_member = true, | ||
| 32 | __is_func = is_function<_Tp>::value, | ||
| 33 | __is_obj = !__is_func, | ||
| 34 | }; | ||
| 35 | }; | ||
| 36 | |||
| 37 | #if __has_builtin(__is_member_function_pointer) | ||
| 38 | |||
| 39 | template <class _Tp> | ||
| 40 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {}; | ||
| 41 | |||
| 42 | # if _LIBCPP_STD_VER >= 17 | ||
| 43 | template <class _Tp> | ||
| 44 | inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); | ||
| 45 | # endif | ||
| 46 | |||
| 47 | #else // __has_builtin(__is_member_function_pointer) | ||
| 48 | |||
| 49 | template <class _Tp> | ||
| 50 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | ||
| 51 | : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_func> {}; | ||
| 52 | |||
| 53 | # if _LIBCPP_STD_VER >= 17 | ||
| 54 | template <class _Tp> | ||
| 55 | inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; | ||
| 56 | # endif | ||
| 57 | |||
| 58 | #endif // __has_builtin(__is_member_function_pointer) | ||
| 59 | |||
| 60 | _LIBCPP_END_NAMESPACE_STD | ||
| 61 | |||
| 62 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H | ||
lib/libcxx/include/__type_traits/is_member_object_pointer.h deleted-46| ... | @@ -1,46 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if __has_builtin(__is_member_object_pointer) | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {}; | ||
| 25 | |||
| 26 | # if _LIBCPP_STD_VER >= 17 | ||
| 27 | template <class _Tp> | ||
| 28 | inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); | ||
| 29 | # endif | ||
| 30 | |||
| 31 | #else // __has_builtin(__is_member_object_pointer) | ||
| 32 | |||
| 33 | template <class _Tp> | ||
| 34 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | ||
| 35 | : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_obj> {}; | ||
| 36 | |||
| 37 | # if _LIBCPP_STD_VER >= 17 | ||
| 38 | template <class _Tp> | ||
| 39 | inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; | ||
| 40 | # endif | ||
| 41 | |||
| 42 | #endif // __has_builtin(__is_member_object_pointer) | ||
| 43 | |||
| 44 | _LIBCPP_END_NAMESPACE_STD | ||
| 45 | |||
| 46 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H | ||
lib/libcxx/include/__type_traits/is_member_pointer.h+8-12| ... | @@ -11,7 +11,6 @@ | ... | @@ -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_member_function_pointer.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,29 +18,26 @@ | ... | @@ -19,29 +18,26 @@ |
| 19 | 18 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 20 | ||
| 22 | #if __has_builtin(__is_member_pointer) | ||
| 23 | |||
| 24 | template <class _Tp> | 21 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; | 22 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; |
| 26 | 23 | ||
| 24 | template <class _Tp> | ||
| 25 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {}; | ||
| 26 | |||
| 27 | template <class _Tp> | ||
| 28 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {}; | ||
| 29 | |||
| 27 | # if _LIBCPP_STD_VER >= 17 | 30 | # if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp> | 31 | template <class _Tp> |
| 29 | inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); | 32 | inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); |
| 30 | # endif | ||
| 31 | |||
| 32 | #else // __has_builtin(__is_member_pointer) | ||
| 33 | 33 | ||
| 34 | template <class _Tp> | 34 | template <class _Tp> |
| 35 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer | 35 | inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); |
| 36 | : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_member> {}; | ||
| 37 | 36 | ||
| 38 | # if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | 37 | template <class _Tp> |
| 40 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; | 38 | inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); |
| 41 | # endif | 39 | # endif |
| 42 | 40 | ||
| 43 | #endif // __has_builtin(__is_member_pointer) | ||
| 44 | |||
| 45 | _LIBCPP_END_NAMESPACE_STD | 41 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 42 | ||
| 47 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H | 43 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H |
lib/libcxx/include/__type_traits/is_move_assignable.h deleted-34| ... | @@ -1,34 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_lvalue_reference.h> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_move_assignable | ||
| 25 | : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 26 | |||
| 27 | #if _LIBCPP_STD_VER >= 17 | ||
| 28 | template <class _Tp> | ||
| 29 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | ||
| 30 | #endif | ||
| 31 | |||
| 32 | _LIBCPP_END_NAMESPACE_STD | ||
| 33 | |||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | ||
lib/libcxx/include/__type_traits/is_move_constructible.h deleted-33| ... | @@ -1,33 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_rvalue_reference.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | template <class _Tp> | ||
| 23 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible | ||
| 24 | : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 25 | |||
| 26 | #if _LIBCPP_STD_VER >= 17 | ||
| 27 | template <class _Tp> | ||
| 28 | inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_END_NAMESPACE_STD | ||
| 32 | |||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+24| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 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> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 14 | 16 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -27,6 +29,28 @@ template <class _Tp, class _Arg> | ... | @@ -27,6 +29,28 @@ template <class _Tp, class _Arg> |
| 27 | inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg); | 29 | inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg); |
| 28 | #endif | 30 | #endif |
| 29 | 31 | ||
| 32 | template <class _Tp> | ||
| 33 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | ||
| 34 | : public integral_constant< | ||
| 35 | bool, | ||
| 36 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 37 | |||
| 38 | #if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | ||
| 40 | inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | ||
| 41 | #endif | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | ||
| 45 | : public integral_constant<bool, | ||
| 46 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> { | ||
| 47 | }; | ||
| 48 | |||
| 49 | #if _LIBCPP_STD_VER >= 17 | ||
| 50 | template <class _Tp> | ||
| 51 | inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | ||
| 52 | #endif | ||
| 53 | |||
| 30 | _LIBCPP_END_NAMESPACE_STD | 54 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 55 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H | 56 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+23-33| ... | @@ -10,11 +10,9 @@ | ... | @@ -10,11 +10,9 @@ |
| 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> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 14 | #include <__type_traits/is_constructible.h> | ||
| 15 | #include <__type_traits/is_reference.h> | ||
| 16 | #include <__utility/declval.h> | ||
| 17 | #include <cstddef> | ||
| 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 |
| ... | @@ -22,48 +20,40 @@ | ... | @@ -22,48 +20,40 @@ |
| 22 | 20 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | ||
| 25 | // GCC is disabled due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 | ||
| 26 | #if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC) | ||
| 27 | |||
| 28 | template < class _Tp, class... _Args> | 23 | template < class _Tp, class... _Args> |
| 29 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | 24 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible |
| 30 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; | 25 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; |
| 31 | #else | ||
| 32 | |||
| 33 | template <bool, bool, class _Tp, class... _Args> | ||
| 34 | struct __libcpp_is_nothrow_constructible; | ||
| 35 | 26 | ||
| 27 | #if _LIBCPP_STD_VER >= 17 | ||
| 36 | template <class _Tp, class... _Args> | 28 | template <class _Tp, class... _Args> |
| 37 | struct __libcpp_is_nothrow_constructible</*is constructible*/ true, /*is reference*/ false, _Tp, _Args...> | 29 | inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; |
| 38 | : public integral_constant<bool, noexcept(_Tp(std::declval<_Args>()...))> {}; | 30 | #endif |
| 39 | 31 | ||
| 40 | template <class _Tp> | 32 | template <class _Tp> |
| 41 | void __implicit_conversion_to(_Tp) noexcept {} | 33 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible |
| 34 | : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 42 | 35 | ||
| 43 | template <class _Tp, class _Arg> | 36 | #if _LIBCPP_STD_VER >= 17 |
| 44 | struct __libcpp_is_nothrow_constructible</*is constructible*/ true, /*is reference*/ true, _Tp, _Arg> | 37 | template <class _Tp> |
| 45 | : public integral_constant<bool, noexcept(std::__implicit_conversion_to<_Tp>(std::declval<_Arg>()))> {}; | 38 | inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; |
| 46 | 39 | #endif | |
| 47 | template <class _Tp, bool _IsReference, class... _Args> | ||
| 48 | struct __libcpp_is_nothrow_constructible</*is constructible*/ false, _IsReference, _Tp, _Args...> : public false_type { | ||
| 49 | }; | ||
| 50 | 40 | ||
| 51 | template <class _Tp, class... _Args> | 41 | template <class _Tp> |
| 52 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | 42 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible |
| 53 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, | 43 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 54 | is_reference<_Tp>::value, | ||
| 55 | _Tp, | ||
| 56 | _Args...> {}; | ||
| 57 | 44 | ||
| 58 | template <class _Tp, size_t _Ns> | 45 | #if _LIBCPP_STD_VER >= 17 |
| 59 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> | 46 | template <class _Tp> |
| 60 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> {}; | 47 | inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; |
| 48 | #endif | ||
| 61 | 49 | ||
| 62 | #endif // __has_builtin(__is_nothrow_constructible) | 50 | template <class _Tp> |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | ||
| 52 | : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {}; | ||
| 63 | 53 | ||
| 64 | #if _LIBCPP_STD_VER >= 17 | 54 | #if _LIBCPP_STD_VER >= 17 |
| 65 | template <class _Tp, class... _Args> | 55 | template <class _Tp> |
| 66 | inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; | 56 | inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp); |
| 67 | #endif | 57 | #endif |
| 68 | 58 | ||
| 69 | _LIBCPP_END_NAMESPACE_STD | 59 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_nothrow_convertible.h+12| ... | @@ -26,6 +26,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,6 +26,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | #if _LIBCPP_STD_VER >= 20 | 27 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 28 | ||
| 29 | # if __has_builtin(__is_nothrow_convertible) | ||
| 30 | |||
| 31 | template <class _Tp, class _Up> | ||
| 32 | struct is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {}; | ||
| 33 | |||
| 34 | template <class _Tp, class _Up> | ||
| 35 | inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up); | ||
| 36 | |||
| 37 | # else // __has_builtin(__is_nothrow_convertible) | ||
| 38 | |||
| 29 | template <typename _Tp> | 39 | template <typename _Tp> |
| 30 | void __test_noexcept(_Tp) noexcept; | 40 | void __test_noexcept(_Tp) noexcept; |
| 31 | 41 | ||
| ... | @@ -43,6 +53,8 @@ struct is_nothrow_convertible | ... | @@ -43,6 +53,8 @@ struct is_nothrow_convertible |
| 43 | template <typename _Fm, typename _To> | 53 | template <typename _Fm, typename _To> |
| 44 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; | 54 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; |
| 45 | 55 | ||
| 56 | # endif // __has_builtin(__is_nothrow_convertible) | ||
| 57 | |||
| 46 | #endif // _LIBCPP_STD_VER >= 20 | 58 | #endif // _LIBCPP_STD_VER >= 20 |
| 47 | 59 | ||
| 48 | _LIBCPP_END_NAMESPACE_STD | 60 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.h deleted-36| ... | @@ -1,36 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_const.h> | ||
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | ||
| 25 | : public integral_constant<bool, | ||
| 26 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, | ||
| 27 | __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {}; | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | template <class _Tp> | ||
| 31 | inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | ||
| 35 | |||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H | ||
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h deleted-48| ... | @@ -1,48 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_const.h> | ||
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | #include <__type_traits/is_nothrow_constructible.h> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | // TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed | ||
| 25 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 26 | |||
| 27 | template <class _Tp> | ||
| 28 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible | ||
| 29 | : public is_nothrow_constructible<_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type> > {}; | ||
| 30 | |||
| 31 | #else // _LIBCPP_COMPILER_GCC | ||
| 32 | |||
| 33 | template <class _Tp> | ||
| 34 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible | ||
| 35 | : public integral_constant< | ||
| 36 | bool, | ||
| 37 | __is_nothrow_constructible(_Tp, typename add_lvalue_reference<typename add_const<_Tp>::type>::type)> {}; | ||
| 38 | |||
| 39 | #endif // _LIBCPP_COMPILER_GCC | ||
| 40 | |||
| 41 | #if _LIBCPP_STD_VER >= 17 | ||
| 42 | template <class _Tp> | ||
| 43 | inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; | ||
| 44 | #endif | ||
| 45 | |||
| 46 | _LIBCPP_END_NAMESPACE_STD | ||
| 47 | |||
| 48 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.h deleted-32| ... | @@ -1,32 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp> | ||
| 22 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | ||
| 23 | : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {}; | ||
| 24 | |||
| 25 | #if _LIBCPP_STD_VER >= 17 | ||
| 26 | template <class _Tp> | ||
| 27 | inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp); | ||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_END_NAMESPACE_STD | ||
| 31 | |||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+7-18| ... | @@ -12,9 +12,6 @@ | ... | @@ -12,9 +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_destructible.h> | 14 | #include <__type_traits/is_destructible.h> |
| 15 | #include <__type_traits/is_reference.h> | ||
| 16 | #include <__type_traits/is_scalar.h> | ||
| 17 | #include <__type_traits/remove_all_extents.h> | ||
| 18 | #include <__utility/declval.h> | 15 | #include <__utility/declval.h> |
| 19 | #include <cstddef> | 16 | #include <cstddef> |
| 20 | 17 | ||
| ... | @@ -24,7 +21,12 @@ | ... | @@ -24,7 +21,12 @@ |
| 24 | 21 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | ||
| 27 | #if !defined(_LIBCPP_CXX03_LANG) | 24 | #if __has_builtin(__is_nothrow_destructible) |
| 25 | |||
| 26 | template <class _Tp> | ||
| 27 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {}; | ||
| 28 | |||
| 29 | #else | ||
| 28 | 30 | ||
| 29 | template <bool, class _Tp> | 31 | template <bool, class _Tp> |
| 30 | struct __libcpp_is_nothrow_destructible; | 32 | struct __libcpp_is_nothrow_destructible; |
| ... | @@ -49,20 +51,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {}; | ... | @@ -49,20 +51,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {}; |
| 49 | template <class _Tp> | 51 | template <class _Tp> |
| 50 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {}; | 52 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {}; |
| 51 | 53 | ||
| 52 | #else | 54 | #endif // __has_builtin(__is_nothrow_destructible) |
| 53 | |||
| 54 | template <class _Tp> | ||
| 55 | struct __libcpp_nothrow_destructor : public integral_constant<bool, is_scalar<_Tp>::value || is_reference<_Tp>::value> { | ||
| 56 | }; | ||
| 57 | |||
| 58 | template <class _Tp> | ||
| 59 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : public __libcpp_nothrow_destructor<__remove_all_extents_t<_Tp> > { | ||
| 60 | }; | ||
| 61 | |||
| 62 | template <class _Tp> | ||
| 63 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> : public false_type {}; | ||
| 64 | |||
| 65 | #endif | ||
| 66 | 55 | ||
| 67 | #if _LIBCPP_STD_VER >= 17 | 56 | #if _LIBCPP_STD_VER >= 17 |
| 68 | template <class _Tp> | 57 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.h deleted-36| ... | @@ -1,36 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_lvalue_reference.h> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | ||
| 25 | : public integral_constant<bool, | ||
| 26 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> { | ||
| 27 | }; | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | template <class _Tp> | ||
| 31 | inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | ||
| 35 | |||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H | ||
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.h deleted-45| ... | @@ -1,45 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_rvalue_reference.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | #include <__type_traits/is_nothrow_constructible.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | // TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed | ||
| 24 | #ifndef _LIBCPP_COMPILER_GCC | ||
| 25 | |||
| 26 | template <class _Tp> | ||
| 27 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible | ||
| 28 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 29 | |||
| 30 | #else // _LIBCPP_COMPILER_GCC | ||
| 31 | |||
| 32 | template <class _Tp> | ||
| 33 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible | ||
| 34 | : public is_nothrow_constructible<_Tp, __add_rvalue_reference_t<_Tp> > {}; | ||
| 35 | |||
| 36 | #endif // _LIBCPP_COMPILER_GCC | ||
| 37 | |||
| 38 | #if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | ||
| 40 | inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; | ||
| 41 | #endif | ||
| 42 | |||
| 43 | _LIBCPP_END_NAMESPACE_STD | ||
| 44 | |||
| 45 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_null_pointer.h+3-9| ... | @@ -11,7 +11,6 @@ | ... | @@ -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 | #include <cstddef> | 14 | #include <cstddef> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -21,20 +20,15 @@ | ... | @@ -21,20 +20,15 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | template <class _Tp> | 22 | template <class _Tp> |
| 24 | struct __is_nullptr_t_impl : public false_type {}; | 23 | inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); |
| 25 | template <> | ||
| 26 | struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; | ||
| 27 | |||
| 28 | template <class _Tp> | ||
| 29 | struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {}; | ||
| 30 | 24 | ||
| 31 | #if _LIBCPP_STD_VER >= 14 | 25 | #if _LIBCPP_STD_VER >= 14 |
| 32 | template <class _Tp> | 26 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS is_null_pointer : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {}; | 27 | struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {}; |
| 34 | 28 | ||
| 35 | # if _LIBCPP_STD_VER >= 17 | 29 | # if _LIBCPP_STD_VER >= 17 |
| 36 | template <class _Tp> | 30 | template <class _Tp> |
| 37 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; | 31 | inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>; |
| 38 | # endif | 32 | # endif |
| 39 | #endif // _LIBCPP_STD_VER >= 14 | 33 | #endif // _LIBCPP_STD_VER >= 14 |
| 40 | 34 |
lib/libcxx/include/__type_traits/is_object.h+2-23| ... | @@ -11,10 +11,6 @@ | ... | @@ -11,10 +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_array.h> | ||
| 15 | #include <__type_traits/is_class.h> | ||
| 16 | #include <__type_traits/is_scalar.h> | ||
| 17 | #include <__type_traits/is_union.h> | ||
| 18 | 14 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -22,30 +18,13 @@ | ... | @@ -22,30 +18,13 @@ |
| 22 | 18 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 20 | ||
| 25 | #if __has_builtin(__is_object) | ||
| 26 | |||
| 27 | template <class _Tp> | 21 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {}; | 22 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {}; |
| 29 | 23 | ||
| 30 | # if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 31 | template <class _Tp> | 25 | template <class _Tp> |
| 32 | inline constexpr bool is_object_v = __is_object(_Tp); | 26 | inline constexpr bool is_object_v = __is_object(_Tp); |
| 33 | # endif | 27 | #endif |
| 34 | |||
| 35 | #else // __has_builtin(__is_object) | ||
| 36 | |||
| 37 | template <class _Tp> | ||
| 38 | struct _LIBCPP_TEMPLATE_VIS is_object | ||
| 39 | : public integral_constant<bool, | ||
| 40 | is_scalar<_Tp>::value || is_array<_Tp>::value || is_union<_Tp>::value || | ||
| 41 | is_class<_Tp>::value > {}; | ||
| 42 | |||
| 43 | # if _LIBCPP_STD_VER >= 17 | ||
| 44 | template <class _Tp> | ||
| 45 | inline constexpr bool is_object_v = is_object<_Tp>::value; | ||
| 46 | # endif | ||
| 47 | |||
| 48 | #endif // __has_builtin(__is_object) | ||
| 49 | 28 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 51 | 30 |
lib/libcxx/include/__type_traits/is_reference.h+11-18| ... | @@ -18,27 +18,30 @@ | ... | @@ -18,27 +18,30 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference) | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {}; | ||
| 22 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | ||
| 23 | template <class _Tp> | 25 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; | 26 | inline constexpr bool is_reference_v = __is_reference(_Tp); |
| 27 | #endif | ||
| 28 | |||
| 29 | #if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) | ||
| 25 | 30 | ||
| 26 | template <class _Tp> | 31 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {}; | 32 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; |
| 28 | 33 | ||
| 29 | template <class _Tp> | 34 | template <class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {}; | 35 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {}; |
| 31 | 36 | ||
| 32 | # if _LIBCPP_STD_VER >= 17 | 37 | # if _LIBCPP_STD_VER >= 17 |
| 33 | template <class _Tp> | 38 | template <class _Tp> |
| 34 | inline constexpr bool is_reference_v = __is_reference(_Tp); | ||
| 35 | template <class _Tp> | ||
| 36 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | 39 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); |
| 37 | template <class _Tp> | 40 | template <class _Tp> |
| 38 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | 41 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); |
| 39 | # endif | 42 | # endif |
| 40 | 43 | ||
| 41 | #else // __has_builtin(__is_lvalue_reference) && etc... | 44 | #else // __has_builtin(__is_lvalue_reference) |
| 42 | 45 | ||
| 43 | template <class _Tp> | 46 | template <class _Tp> |
| 44 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; | 47 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; |
| ... | @@ -50,17 +53,7 @@ struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; | ... | @@ -50,17 +53,7 @@ struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; |
| 50 | template <class _Tp> | 53 | template <class _Tp> |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; | 54 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; |
| 52 | 55 | ||
| 53 | template <class _Tp> | ||
| 54 | struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; | ||
| 55 | template <class _Tp> | ||
| 56 | struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; | ||
| 57 | template <class _Tp> | ||
| 58 | struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; | ||
| 59 | |||
| 60 | # if _LIBCPP_STD_VER >= 17 | 56 | # if _LIBCPP_STD_VER >= 17 |
| 61 | template <class _Tp> | ||
| 62 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; | ||
| 63 | |||
| 64 | template <class _Tp> | 57 | template <class _Tp> |
| 65 | inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; | 58 | inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; |
| 66 | 59 | ||
| ... | @@ -68,7 +61,7 @@ template <class _Tp> | ... | @@ -68,7 +61,7 @@ template <class _Tp> |
| 68 | inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; | 61 | inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; |
| 69 | # endif | 62 | # endif |
| 70 | 63 | ||
| 71 | #endif // __has_builtin(__is_lvalue_reference) && etc... | 64 | #endif // __has_builtin(__is_lvalue_reference) |
| 72 | 65 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | 66 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 67 |
lib/libcxx/include/__type_traits/is_reference_wrapper.h+1-3| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__fwd/functional.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <__type_traits/remove_cv.h> | 15 | #include <__type_traits/remove_cv.h> |
| 15 | 16 | ||
| ... | @@ -19,9 +20,6 @@ | ... | @@ -19,9 +20,6 @@ |
| 19 | 20 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 22 | ||
| 22 | template <class _Tp> | ||
| 23 | class _LIBCPP_TEMPLATE_VIS reference_wrapper; | ||
| 24 | |||
| 25 | template <class _Tp> | 23 | template <class _Tp> |
| 26 | struct __is_reference_wrapper_impl : public false_type {}; | 24 | struct __is_reference_wrapper_impl : public false_type {}; |
| 27 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_scalar.h+1-1| ... | @@ -49,7 +49,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar | ... | @@ -49,7 +49,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar |
| 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 || |
| 52 | __is_nullptr_t<_Tp>::value || | 52 | __is_null_pointer_v<_Tp> || |
| 53 | __is_block<_Tp>::value || | 53 | __is_block<_Tp>::value || |
| 54 | is_enum<_Tp>::value> {}; | 54 | is_enum<_Tp>::value> {}; |
| 55 | // clang-format on | 55 | // clang-format on |
lib/libcxx/include/__type_traits/is_scoped_enum.h deleted-40| ... | @@ -1,40 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | #include <__type_traits/is_convertible.h> | ||
| 15 | #include <__type_traits/is_enum.h> | ||
| 16 | #include <__type_traits/underlying_type.h> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | #if _LIBCPP_STD_VER >= 23 | ||
| 25 | template <class _Tp, bool = is_enum_v<_Tp> > | ||
| 26 | struct __is_scoped_enum_helper : false_type {}; | ||
| 27 | |||
| 28 | template <class _Tp> | ||
| 29 | struct __is_scoped_enum_helper<_Tp, true> : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {}; | ||
| 30 | |||
| 31 | template <class _Tp> | ||
| 32 | struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : public __is_scoped_enum_helper<_Tp> {}; | ||
| 33 | |||
| 34 | template <class _Tp> | ||
| 35 | inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; | ||
| 36 | #endif | ||
| 37 | |||
| 38 | _LIBCPP_END_NAMESPACE_STD | ||
| 39 | |||
| 40 | #endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H | ||
lib/libcxx/include/__type_traits/is_swappable.h+39-69| ... | @@ -11,16 +11,12 @@ | ... | @@ -11,16 +11,12 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_lvalue_reference.h> |
| 14 | #include <__type_traits/conditional.h> | ||
| 15 | #include <__type_traits/enable_if.h> | 14 | #include <__type_traits/enable_if.h> |
| 16 | #include <__type_traits/is_move_assignable.h> | 15 | #include <__type_traits/is_assignable.h> |
| 17 | #include <__type_traits/is_move_constructible.h> | 16 | #include <__type_traits/is_constructible.h> |
| 18 | #include <__type_traits/is_nothrow_move_assignable.h> | 17 | #include <__type_traits/is_nothrow_assignable.h> |
| 19 | #include <__type_traits/is_nothrow_move_constructible.h> | 18 | #include <__type_traits/is_nothrow_constructible.h> |
| 20 | #include <__type_traits/is_referenceable.h> | 19 | #include <__type_traits/void_t.h> |
| 21 | #include <__type_traits/is_same.h> | ||
| 22 | #include <__type_traits/is_void.h> | ||
| 23 | #include <__type_traits/nat.h> | ||
| 24 | #include <__utility/declval.h> | 20 | #include <__utility/declval.h> |
| 25 | #include <cstddef> | 21 | #include <cstddef> |
| 26 | 22 | ||
| ... | @@ -30,10 +26,17 @@ | ... | @@ -30,10 +26,17 @@ |
| 30 | 26 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 28 | ||
| 29 | template <class _Tp, class _Up, class = void> | ||
| 30 | inline const bool __is_swappable_with_v = false; | ||
| 31 | |||
| 33 | template <class _Tp> | 32 | template <class _Tp> |
| 34 | struct __is_swappable; | 33 | inline const bool __is_swappable_v = __is_swappable_with_v<_Tp&, _Tp&>; |
| 34 | |||
| 35 | template <class _Tp, class _Up, bool = __is_swappable_with_v<_Tp, _Up> > | ||
| 36 | inline const bool __is_nothrow_swappable_with_v = false; | ||
| 37 | |||
| 35 | template <class _Tp> | 38 | template <class _Tp> |
| 36 | struct __is_nothrow_swappable; | 39 | inline const bool __is_nothrow_swappable_v = __is_nothrow_swappable_with_v<_Tp&, _Tp&>; |
| 37 | 40 | ||
| 38 | #ifndef _LIBCPP_CXX03_LANG | 41 | #ifndef _LIBCPP_CXX03_LANG |
| 39 | template <class _Tp> | 42 | template <class _Tp> |
| ... | @@ -47,85 +50,52 @@ template <class _Tp> | ... | @@ -47,85 +50,52 @@ template <class _Tp> |
| 47 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y) | 50 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y) |
| 48 | _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value); | 51 | _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value); |
| 49 | 52 | ||
| 50 | template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> = 0> | 53 | template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> = 0> |
| 51 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) | 54 | inline _LIBCPP_HIDE_FROM_ABI |
| 52 | _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); | 55 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>); |
| 53 | 56 | ||
| 54 | namespace __detail { | ||
| 55 | // ALL generic swap overloads MUST already have a declaration available at this point. | 57 | // ALL generic swap overloads MUST already have a declaration available at this point. |
| 56 | 58 | ||
| 57 | template <class _Tp, class _Up = _Tp, bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value> | 59 | template <class _Tp, class _Up> |
| 58 | struct __swappable_with { | 60 | inline const bool __is_swappable_with_v<_Tp, |
| 59 | template <class _LHS, class _RHS> | 61 | _Up, |
| 60 | static decltype(swap(std::declval<_LHS>(), std::declval<_RHS>())) __test_swap(int); | 62 | __void_t<decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), |
| 61 | template <class, class> | 63 | decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> > = true; |
| 62 | static __nat __test_swap(long); | ||
| 63 | |||
| 64 | // Extra parens are needed for the C++03 definition of decltype. | ||
| 65 | typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1; | ||
| 66 | typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2; | ||
| 67 | |||
| 68 | static const bool value = _IsNotSame<__swap1, __nat>::value && _IsNotSame<__swap2, __nat>::value; | ||
| 69 | }; | ||
| 70 | 64 | ||
| 65 | #ifndef _LIBCPP_CXX03_LANG // C++03 doesn't have noexcept, so things are never nothrow swappable | ||
| 71 | template <class _Tp, class _Up> | 66 | template <class _Tp, class _Up> |
| 72 | struct __swappable_with<_Tp, _Up, false> : false_type {}; | 67 | inline const bool __is_nothrow_swappable_with_v<_Tp, _Up, true> = |
| 73 | 68 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) && | |
| 74 | template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value> | 69 | noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())); |
| 75 | struct __nothrow_swappable_with { | ||
| 76 | static const bool value = | ||
| 77 | #ifndef _LIBCPP_HAS_NO_NOEXCEPT | ||
| 78 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))&& noexcept( | ||
| 79 | swap(std::declval<_Up>(), std::declval<_Tp>())); | ||
| 80 | #else | ||
| 81 | false; | ||
| 82 | #endif | 70 | #endif |
| 83 | }; | ||
| 84 | 71 | ||
| 85 | template <class _Tp, class _Up> | 72 | #if _LIBCPP_STD_VER >= 17 |
| 86 | struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; | ||
| 87 | 73 | ||
| 88 | } // namespace __detail | 74 | template <class _Tp, class _Up> |
| 75 | inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>; | ||
| 89 | 76 | ||
| 90 | template <class _Tp> | 77 | template <class _Tp, class _Up> |
| 91 | struct __is_swappable : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> {}; | 78 | struct _LIBCPP_TEMPLATE_VIS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {}; |
| 92 | 79 | ||
| 93 | template <class _Tp> | 80 | template <class _Tp> |
| 94 | struct __is_nothrow_swappable : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> {}; | 81 | inline constexpr bool is_swappable_v = |
| 95 | 82 | is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; | |
| 96 | #if _LIBCPP_STD_VER >= 17 | ||
| 97 | |||
| 98 | template <class _Tp, class _Up> | ||
| 99 | struct _LIBCPP_TEMPLATE_VIS is_swappable_with | ||
| 100 | : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> {}; | ||
| 101 | 83 | ||
| 102 | template <class _Tp> | 84 | template <class _Tp> |
| 103 | struct _LIBCPP_TEMPLATE_VIS is_swappable | 85 | struct _LIBCPP_TEMPLATE_VIS is_swappable : bool_constant<is_swappable_v<_Tp>> {}; |
| 104 | : public __conditional_t<__libcpp_is_referenceable<_Tp>::value, | ||
| 105 | is_swappable_with<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp> >, | ||
| 106 | false_type> {}; | ||
| 107 | 86 | ||
| 108 | template <class _Tp, class _Up> | 87 | template <class _Tp, class _Up> |
| 109 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with | 88 | inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>; |
| 110 | : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> {}; | ||
| 111 | |||
| 112 | template <class _Tp> | ||
| 113 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable | ||
| 114 | : public __conditional_t<__libcpp_is_referenceable<_Tp>::value, | ||
| 115 | is_nothrow_swappable_with<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp> >, | ||
| 116 | false_type> {}; | ||
| 117 | 89 | ||
| 118 | template <class _Tp, class _Up> | 90 | template <class _Tp, class _Up> |
| 119 | inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; | 91 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {}; |
| 120 | 92 | ||
| 121 | template <class _Tp> | 93 | template <class _Tp> |
| 122 | inline constexpr bool is_swappable_v = is_swappable<_Tp>::value; | 94 | inline constexpr bool is_nothrow_swappable_v = |
| 123 | 95 | is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; | |
| 124 | template <class _Tp, class _Up> | ||
| 125 | inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value; | ||
| 126 | 96 | ||
| 127 | template <class _Tp> | 97 | template <class _Tp> |
| 128 | inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; | 98 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {}; |
| 129 | 99 | ||
| 130 | #endif // _LIBCPP_STD_VER >= 17 | 100 | #endif // _LIBCPP_STD_VER >= 17 |
| 131 | 101 |
lib/libcxx/include/__type_traits/is_trivially_assignable.h+25| ... | @@ -10,6 +10,9 @@ | ... | @@ -10,6 +10,9 @@ |
| 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_const.h> | ||
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/add_rvalue_reference.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 16 | #include <__type_traits/integral_constant.h> |
| 14 | 17 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,6 +29,28 @@ template <class _Tp, class _Arg> | ... | @@ -26,6 +29,28 @@ template <class _Tp, class _Arg> |
| 26 | inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg); | 29 | inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg); |
| 27 | #endif | 30 | #endif |
| 28 | 31 | ||
| 32 | template <class _Tp> | ||
| 33 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable | ||
| 34 | : public integral_constant< | ||
| 35 | bool, | ||
| 36 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 37 | |||
| 38 | #if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | ||
| 40 | inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; | ||
| 41 | #endif | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable | ||
| 45 | : public integral_constant< | ||
| 46 | bool, | ||
| 47 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 48 | |||
| 49 | #if _LIBCPP_STD_VER >= 17 | ||
| 50 | template <class _Tp> | ||
| 51 | inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; | ||
| 52 | #endif | ||
| 53 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | 54 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 55 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H | 56 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_trivially_constructible.h+29| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 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> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 13 | #include <__type_traits/integral_constant.h> | 15 | #include <__type_traits/integral_constant.h> |
| 14 | 16 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -27,6 +29,33 @@ template <class _Tp, class... _Args> | ... | @@ -27,6 +29,33 @@ template <class _Tp, class... _Args> |
| 27 | inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...); | 29 | inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...); |
| 28 | #endif | 30 | #endif |
| 29 | 31 | ||
| 32 | template <class _Tp> | ||
| 33 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible | ||
| 34 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 35 | |||
| 36 | #if _LIBCPP_STD_VER >= 17 | ||
| 37 | template <class _Tp> | ||
| 38 | inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; | ||
| 39 | #endif | ||
| 40 | |||
| 41 | template <class _Tp> | ||
| 42 | struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible | ||
| 43 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 44 | |||
| 45 | #if _LIBCPP_STD_VER >= 17 | ||
| 46 | template <class _Tp> | ||
| 47 | inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; | ||
| 48 | #endif | ||
| 49 | |||
| 50 | template <class _Tp> | ||
| 51 | struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible | ||
| 52 | : public integral_constant<bool, __is_trivially_constructible(_Tp)> {}; | ||
| 53 | |||
| 54 | #if _LIBCPP_STD_VER >= 17 | ||
| 55 | template <class _Tp> | ||
| 56 | inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp); | ||
| 57 | #endif | ||
| 58 | |||
| 30 | _LIBCPP_END_NAMESPACE_STD | 59 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 60 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H | 61 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.h deleted-36| ... | @@ -1,36 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_const.h> | ||
| 14 | #include <__type_traits/add_lvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable | ||
| 25 | : public integral_constant<bool, | ||
| 26 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, | ||
| 27 | __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {}; | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | template <class _Tp> | ||
| 31 | inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | ||
| 35 | |||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H | ||
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.h deleted-33| ... | @@ -1,33 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_lvalue_reference.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | template <class _Tp> | ||
| 23 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible | ||
| 24 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 25 | |||
| 26 | #if _LIBCPP_STD_VER >= 17 | ||
| 27 | template <class _Tp> | ||
| 28 | inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_END_NAMESPACE_STD | ||
| 32 | |||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_trivially_default_constructible.h deleted-32| ... | @@ -1,32 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | template <class _Tp> | ||
| 22 | struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible | ||
| 23 | : public integral_constant<bool, __is_trivially_constructible(_Tp)> {}; | ||
| 24 | |||
| 25 | #if _LIBCPP_STD_VER >= 17 | ||
| 26 | template <class _Tp> | ||
| 27 | inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp); | ||
| 28 | #endif | ||
| 29 | |||
| 30 | _LIBCPP_END_NAMESPACE_STD | ||
| 31 | |||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_trivially_move_assignable.h deleted-36| ... | @@ -1,36 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_lvalue_reference.h> | ||
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable | ||
| 25 | : public integral_constant< | ||
| 26 | bool, | ||
| 27 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | template <class _Tp> | ||
| 31 | inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | ||
| 35 | |||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H | ||
lib/libcxx/include/__type_traits/is_trivially_move_constructible.h deleted-33| ... | @@ -1,33 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/add_rvalue_reference.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | template <class _Tp> | ||
| 23 | struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible | ||
| 24 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 25 | |||
| 26 | #if _LIBCPP_STD_VER >= 17 | ||
| 27 | template <class _Tp> | ||
| 28 | inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_END_NAMESPACE_STD | ||
| 32 | |||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H | ||
lib/libcxx/include/__type_traits/is_trivially_relocatable.h created+42| ... | @@ -0,0 +1,42 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/enable_if.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | #include <__type_traits/is_same.h> | ||
| 16 | #include <__type_traits/is_trivially_copyable.h> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | // A type is trivially relocatable if a move construct + destroy of the original object is equivalent to | ||
| 25 | // `memcpy(dst, src, sizeof(T))`. | ||
| 26 | |||
| 27 | #if __has_builtin(__is_trivially_relocatable) | ||
| 28 | template <class _Tp, class = void> | ||
| 29 | struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {}; | ||
| 30 | #else | ||
| 31 | template <class _Tp, class = void> | ||
| 32 | struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {}; | ||
| 33 | #endif | ||
| 34 | |||
| 35 | template <class _Tp> | ||
| 36 | struct __libcpp_is_trivially_relocatable<_Tp, | ||
| 37 | __enable_if_t<is_same<_Tp, typename _Tp::__trivially_relocatable>::value> > | ||
| 38 | : true_type {}; | ||
| 39 | |||
| 40 | _LIBCPP_END_NAMESPACE_STD | ||
| 41 | |||
| 42 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H | ||
lib/libcxx/include/__type_traits/is_void.h+2-18| ... | @@ -11,8 +11,6 @@ | ... | @@ -11,8 +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_same.h> | ||
| 15 | #include <__type_traits/remove_cv.h> | ||
| 16 | 14 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -20,28 +18,14 @@ | ... | @@ -20,28 +18,14 @@ |
| 20 | 18 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 20 | ||
| 23 | #if __has_builtin(__is_void) | ||
| 24 | |||
| 25 | template <class _Tp> | 21 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> {}; | 22 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; |
| 27 | 23 | ||
| 28 | # if _LIBCPP_STD_VER >= 17 | 24 | # if _LIBCPP_STD_VER >= 17 |
| 29 | template <class _Tp> | 25 | template <class _Tp> |
| 30 | inline constexpr bool is_void_v = __is_void(_Tp); | 26 | inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void); |
| 31 | # endif | 27 | # endif |
| 32 | 28 | ||
| 33 | #else | ||
| 34 | |||
| 35 | template <class _Tp> | ||
| 36 | struct _LIBCPP_TEMPLATE_VIS is_void : public is_same<__remove_cv_t<_Tp>, void> {}; | ||
| 37 | |||
| 38 | # if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | ||
| 40 | inline constexpr bool is_void_v = is_void<_Tp>::value; | ||
| 41 | # endif | ||
| 42 | |||
| 43 | #endif // __has_builtin(__is_void) | ||
| 44 | |||
| 45 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 30 | ||
| 47 | #endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H | 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H |
lib/libcxx/include/__type_traits/make_signed.h+2-2| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H | 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/apply_cv.h> | 13 | #include <__type_traits/copy_cv.h> |
| 14 | #include <__type_traits/is_enum.h> | 14 | #include <__type_traits/is_enum.h> |
| 15 | #include <__type_traits/is_integral.h> | 15 | #include <__type_traits/is_integral.h> |
| 16 | #include <__type_traits/nat.h> | 16 | #include <__type_traits/nat.h> |
| ... | @@ -70,7 +70,7 @@ template <> struct __make_signed<__uint128_t, true> {typedef __int128_t t | ... | @@ -70,7 +70,7 @@ template <> struct __make_signed<__uint128_t, true> {typedef __int128_t t |
| 70 | // clang-format on | 70 | // clang-format on |
| 71 | 71 | ||
| 72 | template <class _Tp> | 72 | template <class _Tp> |
| 73 | using __make_signed_t = __apply_cv_t<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>; | 73 | using __make_signed_t = __copy_cv_t<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>; |
| 74 | 74 | ||
| 75 | #endif // __has_builtin(__make_signed) | 75 | #endif // __has_builtin(__make_signed) |
| 76 | 76 |
lib/libcxx/include/__type_traits/make_unsigned.h+2-2| ... | @@ -10,8 +10,8 @@ | ... | @@ -10,8 +10,8 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H | 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/apply_cv.h> | ||
| 14 | #include <__type_traits/conditional.h> | 13 | #include <__type_traits/conditional.h> |
| 14 | #include <__type_traits/copy_cv.h> | ||
| 15 | #include <__type_traits/is_enum.h> | 15 | #include <__type_traits/is_enum.h> |
| 16 | #include <__type_traits/is_integral.h> | 16 | #include <__type_traits/is_integral.h> |
| 17 | #include <__type_traits/is_unsigned.h> | 17 | #include <__type_traits/is_unsigned.h> |
| ... | @@ -72,7 +72,7 @@ template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_ | ... | @@ -72,7 +72,7 @@ template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_ |
| 72 | // clang-format on | 72 | // clang-format on |
| 73 | 73 | ||
| 74 | template <class _Tp> | 74 | template <class _Tp> |
| 75 | using __make_unsigned_t = __apply_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>; | 75 | using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>; |
| 76 | 76 | ||
| 77 | #endif // __has_builtin(__make_unsigned) | 77 | #endif // __has_builtin(__make_unsigned) |
| 78 | 78 |
lib/libcxx/include/__type_traits/noexcept_move_assign_container.h+1-1| ... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__memory/allocator_traits.h> | 13 | #include <__memory/allocator_traits.h> |
| 14 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 15 | #include <__type_traits/is_nothrow_move_assignable.h> | 15 | #include <__type_traits/is_nothrow_assignable.h> |
| 16 | 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 18 | # pragma GCC system_header |
lib/libcxx/include/__type_traits/operation_traits.h deleted-40| ... | @@ -1,40 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_OPERATION_TRAITS_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_OPERATION_TRAITS_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | // Tags to represent the canonical operations | ||
| 22 | struct __equal_tag {}; | ||
| 23 | struct __plus_tag {}; | ||
| 24 | |||
| 25 | // This class template is used to determine whether an operation "desugars" | ||
| 26 | // (or boils down) to a given canonical operation. | ||
| 27 | // | ||
| 28 | // For example, `std::equal_to<>`, our internal `std::__equal_to` helper and | ||
| 29 | // `ranges::equal_to` are all just fancy ways of representing a transparent | ||
| 30 | // equality operation, so they all desugar to `__equal_tag`. | ||
| 31 | // | ||
| 32 | // This is useful to optimize some functions in cases where we know e.g. the | ||
| 33 | // predicate being passed is actually going to call a builtin operator, or has | ||
| 34 | // some specific semantics. | ||
| 35 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 36 | struct __desugars_to : false_type {}; | ||
| 37 | |||
| 38 | _LIBCPP_END_NAMESPACE_STD | ||
| 39 | |||
| 40 | #endif // _LIBCPP___TYPE_TRAITS_OPERATION_TRAITS_H | ||
lib/libcxx/include/__type_traits/promote.h+38-4| ... | @@ -11,8 +11,12 @@ | ... | @@ -11,8 +11,12 @@ |
| 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_same.h> | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | #include <__utility/declval.h> | 15 | |
| 16 | #if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER == 1700 | ||
| 17 | # include <__type_traits/is_same.h> | ||
| 18 | # include <__utility/declval.h> | ||
| 19 | #endif | ||
| 16 | 20 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -20,6 +24,34 @@ | ... | @@ -20,6 +24,34 @@ |
| 20 | 24 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 26 | ||
| 27 | // TODO(LLVM-20): Remove this workaround | ||
| 28 | #if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700 | ||
| 29 | |||
| 30 | template <class... _Args> | ||
| 31 | class __promote { | ||
| 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ||
| 33 | |||
| 34 | static float __test(float); | ||
| 35 | static double __test(char); | ||
| 36 | static double __test(int); | ||
| 37 | static double __test(unsigned); | ||
| 38 | static double __test(long); | ||
| 39 | static double __test(unsigned long); | ||
| 40 | static double __test(long long); | ||
| 41 | static double __test(unsigned long long); | ||
| 42 | # ifndef _LIBCPP_HAS_NO_INT128 | ||
| 43 | static double __test(__int128_t); | ||
| 44 | static double __test(__uint128_t); | ||
| 45 | # endif | ||
| 46 | static double __test(double); | ||
| 47 | static long double __test(long double); | ||
| 48 | |||
| 49 | public: | ||
| 50 | using type = decltype((__test(_Args()) + ...)); | ||
| 51 | }; | ||
| 52 | |||
| 53 | #else | ||
| 54 | |||
| 23 | template <class _Tp> | 55 | template <class _Tp> |
| 24 | struct __numeric_type { | 56 | struct __numeric_type { |
| 25 | static void __test(...); | 57 | static void __test(...); |
| ... | @@ -31,10 +63,10 @@ struct __numeric_type { | ... | @@ -31,10 +63,10 @@ struct __numeric_type { |
| 31 | static double __test(unsigned long); | 63 | static double __test(unsigned long); |
| 32 | static double __test(long long); | 64 | static double __test(long long); |
| 33 | static double __test(unsigned long long); | 65 | static double __test(unsigned long long); |
| 34 | #ifndef _LIBCPP_HAS_NO_INT128 | 66 | # ifndef _LIBCPP_HAS_NO_INT128 |
| 35 | static double __test(__int128_t); | 67 | static double __test(__int128_t); |
| 36 | static double __test(__uint128_t); | 68 | static double __test(__uint128_t); |
| 37 | #endif | 69 | # endif |
| 38 | static double __test(double); | 70 | static double __test(double); |
| 39 | static long double __test(long double); | 71 | static long double __test(long double); |
| 40 | 72 | ||
| ... | @@ -89,6 +121,8 @@ public: | ... | @@ -89,6 +121,8 @@ public: |
| 89 | template <class _A1, class _A2 = void, class _A3 = void> | 121 | template <class _A1, class _A2 = void, class _A3 = void> |
| 90 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; | 122 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; |
| 91 | 123 | ||
| 124 | #endif // !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1700 | ||
| 125 | |||
| 92 | _LIBCPP_END_NAMESPACE_STD | 126 | _LIBCPP_END_NAMESPACE_STD |
| 93 | 127 | ||
| 94 | #endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H | 128 | #endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H |
lib/libcxx/include/__type_traits/remove_pointer.h+5| ... | @@ -23,8 +23,13 @@ struct remove_pointer { | ... | @@ -23,8 +23,13 @@ struct remove_pointer { |
| 23 | using type _LIBCPP_NODEBUG = __remove_pointer(_Tp); | 23 | using type _LIBCPP_NODEBUG = __remove_pointer(_Tp); |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | # ifdef _LIBCPP_COMPILER_GCC | ||
| 27 | template <class _Tp> | ||
| 28 | using __remove_pointer_t = typename remove_pointer<_Tp>::type; | ||
| 29 | # else | ||
| 26 | template <class _Tp> | 30 | template <class _Tp> |
| 27 | using __remove_pointer_t = __remove_pointer(_Tp); | 31 | using __remove_pointer_t = __remove_pointer(_Tp); |
| 32 | # endif | ||
| 28 | #else | 33 | #else |
| 29 | // clang-format off | 34 | // clang-format off |
| 30 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; | 35 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; |
lib/libcxx/include/__type_traits/remove_reference.h+7-7| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <cstddef> | ||
| 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 |
| ... | @@ -26,15 +25,16 @@ struct remove_reference { | ... | @@ -26,15 +25,16 @@ struct remove_reference { |
| 26 | 25 | ||
| 27 | template <class _Tp> | 26 | template <class _Tp> |
| 28 | using __libcpp_remove_reference_t = __remove_reference_t(_Tp); | 27 | using __libcpp_remove_reference_t = __remove_reference_t(_Tp); |
| 29 | #else | 28 | #elif __has_builtin(__remove_reference) |
| 30 | // clang-format off | 29 | template <class _Tp> |
| 31 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;}; | 30 | struct remove_reference { |
| 32 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;}; | 31 | using type _LIBCPP_NODEBUG = __remove_reference(_Tp); |
| 33 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;}; | 32 | }; |
| 34 | // clang-format on | ||
| 35 | 33 | ||
| 36 | template <class _Tp> | 34 | template <class _Tp> |
| 37 | using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type; | 35 | using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type; |
| 36 | #else | ||
| 37 | # error "remove_reference not implemented!" | ||
| 38 | #endif // __has_builtin(__remove_reference_t) | 38 | #endif // __has_builtin(__remove_reference_t) |
| 39 | 39 | ||
| 40 | #if _LIBCPP_STD_VER >= 14 | 40 | #if _LIBCPP_STD_VER >= 14 |
lib/libcxx/include/__type_traits/unwrap_ref.h+1-6| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H | 10 | #define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__fwd/functional.h> | ||
| 13 | #include <__type_traits/decay.h> | 14 | #include <__type_traits/decay.h> |
| 14 | 15 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -23,17 +24,11 @@ struct __unwrap_reference { | ... | @@ -23,17 +24,11 @@ struct __unwrap_reference { |
| 23 | typedef _LIBCPP_NODEBUG _Tp type; | 24 | typedef _LIBCPP_NODEBUG _Tp type; |
| 24 | }; | 25 | }; |
| 25 | 26 | ||
| 26 | template <class _Tp> | ||
| 27 | class reference_wrapper; | ||
| 28 | |||
| 29 | template <class _Tp> | 27 | template <class _Tp> |
| 30 | struct __unwrap_reference<reference_wrapper<_Tp> > { | 28 | struct __unwrap_reference<reference_wrapper<_Tp> > { |
| 31 | typedef _LIBCPP_NODEBUG _Tp& type; | 29 | typedef _LIBCPP_NODEBUG _Tp& type; |
| 32 | }; | 30 | }; |
| 33 | 31 | ||
| 34 | template <class _Tp> | ||
| 35 | struct decay; | ||
| 36 | |||
| 37 | #if _LIBCPP_STD_VER >= 20 | 32 | #if _LIBCPP_STD_VER >= 20 |
| 38 | template <class _Tp> | 33 | template <class _Tp> |
| 39 | struct unwrap_reference : __unwrap_reference<_Tp> {}; | 34 | struct unwrap_reference : __unwrap_reference<_Tp> {}; |
lib/libcxx/include/__utility/as_const.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #if _LIBCPP_STD_VER >= 17 | 23 | #if _LIBCPP_STD_VER >= 17 |
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| 25 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { |
| 26 | return __t; | 26 | return __t; |
| 27 | } | 27 | } |
| 28 | 28 |
lib/libcxx/include/__utility/exception_guard.h+3-3| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__assert> | 12 | #include <__assert> |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/is_nothrow_move_constructible.h> | 14 | #include <__type_traits/is_nothrow_constructible.h> |
| 15 | #include <__utility/exchange.h> | 15 | #include <__utility/exchange.h> |
| 16 | #include <__utility/move.h> | 16 | #include <__utility/move.h> |
| 17 | 17 | ||
| ... | @@ -96,8 +96,8 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions); | ... | @@ -96,8 +96,8 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions); |
| 96 | template <class _Rollback> | 96 | template <class _Rollback> |
| 97 | struct __exception_guard_noexceptions { | 97 | struct __exception_guard_noexceptions { |
| 98 | __exception_guard_noexceptions() = delete; | 98 | __exception_guard_noexceptions() = delete; |
| 99 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 99 | _LIBCPP_HIDE_FROM_ABI |
| 100 | _LIBCPP_NODEBUG explicit __exception_guard_noexceptions(_Rollback) {} | 100 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG explicit __exception_guard_noexceptions(_Rollback) {} |
| 101 | 101 | ||
| 102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG | 102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG |
| 103 | __exception_guard_noexceptions(__exception_guard_noexceptions&& __other) | 103 | __exception_guard_noexceptions(__exception_guard_noexceptions&& __other) |
lib/libcxx/include/__utility/exchange.h+1-1| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_nothrow_assignable.h> | 13 | #include <__type_traits/is_nothrow_assignable.h> |
| 14 | #include <__type_traits/is_nothrow_move_constructible.h> | 14 | #include <__type_traits/is_nothrow_constructible.h> |
| 15 | #include <__utility/forward.h> | 15 | #include <__utility/forward.h> |
| 16 | #include <__utility/move.h> | 16 | #include <__utility/move.h> |
| 17 | 17 |
lib/libcxx/include/__utility/forward.h+2-2| ... | @@ -21,13 +21,13 @@ | ... | @@ -21,13 +21,13 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | template <class _Tp> | 23 | template <class _Tp> |
| 24 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& | 24 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& |
| 25 | forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT { | 25 | forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT { |
| 26 | return static_cast<_Tp&&>(__t); | 26 | return static_cast<_Tp&&>(__t); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| 30 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& | 30 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& |
| 31 | forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT { | 31 | forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT { |
| 32 | static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue"); | 32 | static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue"); |
| 33 | return static_cast<_Tp&&>(__t); | 33 | return static_cast<_Tp&&>(__t); |
lib/libcxx/include/__utility/forward_like.h+2-2| ... | @@ -34,8 +34,8 @@ template <class _Ap, class _Bp> | ... | @@ -34,8 +34,8 @@ template <class _Ap, class _Bp> |
| 34 | using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>; | 34 | using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>; |
| 35 | 35 | ||
| 36 | template <class _Tp, class _Up> | 36 | template <class _Tp, class _Up> |
| 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept | 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 38 | -> _ForwardLike<_Tp, _Up> { | 38 | forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> { |
| 39 | return static_cast<_ForwardLike<_Tp, _Up>>(__ux); | 39 | return static_cast<_ForwardLike<_Tp, _Up>>(__ux); |
| 40 | } | 40 | } |
| 41 | 41 |
lib/libcxx/include/__utility/integer_sequence.h+12-75| ... | @@ -31,65 +31,16 @@ struct __integer_sequence { | ... | @@ -31,65 +31,16 @@ struct __integer_sequence { |
| 31 | using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>; | 31 | using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>; |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | #if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) | ||
| 35 | |||
| 36 | namespace __detail { | ||
| 37 | |||
| 38 | template <typename _Tp, size_t... _Extra> | ||
| 39 | struct __repeat; | ||
| 40 | template <typename _Tp, _Tp... _Np, size_t... _Extra> | ||
| 41 | struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> { | ||
| 42 | typedef _LIBCPP_NODEBUG __integer_sequence< | ||
| 43 | _Tp, | ||
| 44 | _Np..., | ||
| 45 | sizeof...(_Np) + _Np..., | ||
| 46 | 2 * sizeof...(_Np) + _Np..., | ||
| 47 | 3 * sizeof...(_Np) + _Np..., | ||
| 48 | 4 * sizeof...(_Np) + _Np..., | ||
| 49 | 5 * sizeof...(_Np) + _Np..., | ||
| 50 | 6 * sizeof...(_Np) + _Np..., | ||
| 51 | 7 * sizeof...(_Np) + _Np..., | ||
| 52 | _Extra...> | ||
| 53 | type; | ||
| 54 | }; | ||
| 55 | |||
| 56 | template <size_t _Np> | ||
| 57 | struct __parity; | ||
| 58 | template <size_t _Np> | ||
| 59 | struct __make : __parity<_Np % 8>::template __pmake<_Np> {}; | ||
| 60 | |||
| 61 | // clang-format off | ||
| 62 | template<> struct __make<0> { typedef __integer_sequence<size_t> type; }; | ||
| 63 | template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; }; | ||
| 64 | template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; }; | ||
| 65 | template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; }; | ||
| 66 | template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; }; | ||
| 67 | template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; }; | ||
| 68 | template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; }; | ||
| 69 | template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; }; | ||
| 70 | |||
| 71 | template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; }; | ||
| 72 | template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; }; | ||
| 73 | template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; }; | ||
| 74 | template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; }; | ||
| 75 | template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; | ||
| 76 | template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; | ||
| 77 | template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; | ||
| 78 | template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; | ||
| 79 | // clang-format on | ||
| 80 | |||
| 81 | } // namespace __detail | ||
| 82 | |||
| 83 | #endif | ||
| 84 | |||
| 85 | #if __has_builtin(__make_integer_seq) | 34 | #if __has_builtin(__make_integer_seq) |
| 86 | template <size_t _Ep, size_t _Sp> | 35 | template <size_t _Ep, size_t _Sp> |
| 87 | using __make_indices_imp = | 36 | using __make_indices_imp = |
| 88 | typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>; | 37 | typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>; |
| 89 | #else | 38 | #elif __has_builtin(__integer_pack) |
| 90 | template <size_t _Ep, size_t _Sp> | 39 | template <size_t _Ep, size_t _Sp> |
| 91 | using __make_indices_imp = typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>; | 40 | using __make_indices_imp = |
| 92 | 41 | typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>; | |
| 42 | #else | ||
| 43 | # error "No known way to get an integer pack from the compiler" | ||
| 93 | #endif | 44 | #endif |
| 94 | 45 | ||
| 95 | #if _LIBCPP_STD_VER >= 14 | 46 | #if _LIBCPP_STD_VER >= 14 |
| ... | @@ -104,34 +55,20 @@ struct _LIBCPP_TEMPLATE_VIS integer_sequence { | ... | @@ -104,34 +55,20 @@ struct _LIBCPP_TEMPLATE_VIS integer_sequence { |
| 104 | template <size_t... _Ip> | 55 | template <size_t... _Ip> |
| 105 | using index_sequence = integer_sequence<size_t, _Ip...>; | 56 | using index_sequence = integer_sequence<size_t, _Ip...>; |
| 106 | 57 | ||
| 107 | # if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) | 58 | # if __has_builtin(__make_integer_seq) |
| 108 | 59 | ||
| 109 | template <class _Tp, _Tp _Ep> | 60 | template <class _Tp, _Tp _Ep> |
| 110 | using __make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>; | 61 | using make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>; |
| 111 | |||
| 112 | # else | ||
| 113 | 62 | ||
| 114 | template <typename _Tp, _Tp _Np> | 63 | # elif __has_builtin(__integer_pack) |
| 115 | using __make_integer_sequence_unchecked _LIBCPP_NODEBUG = | ||
| 116 | typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>; | ||
| 117 | 64 | ||
| 118 | template <class _Tp, _Tp _Ep> | 65 | template <class _Tp, _Tp _SequenceSize> |
| 119 | struct __make_integer_sequence_checked { | 66 | using make_integer_sequence _LIBCPP_NODEBUG = integer_sequence<_Tp, __integer_pack(_SequenceSize)...>; |
| 120 | static_assert(is_integral<_Tp>::value, "std::make_integer_sequence can only be instantiated with an integral type"); | ||
| 121 | static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length"); | ||
| 122 | // Workaround GCC bug by preventing bad installations when 0 <= _Ep | ||
| 123 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929 | ||
| 124 | typedef _LIBCPP_NODEBUG __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type; | ||
| 125 | }; | ||
| 126 | |||
| 127 | template <class _Tp, _Tp _Ep> | ||
| 128 | using __make_integer_sequence _LIBCPP_NODEBUG = typename __make_integer_sequence_checked<_Tp, _Ep>::type; | ||
| 129 | 67 | ||
| 68 | # else | ||
| 69 | # error "No known way to get an integer pack from the compiler" | ||
| 130 | # endif | 70 | # endif |
| 131 | 71 | ||
| 132 | template <class _Tp, _Tp _Np> | ||
| 133 | using make_integer_sequence = __make_integer_sequence<_Tp, _Np>; | ||
| 134 | |||
| 135 | template <size_t _Np> | 72 | template <size_t _Np> |
| 136 | using make_index_sequence = make_integer_sequence<size_t, _Np>; | 73 | using make_index_sequence = make_integer_sequence<size_t, _Np>; |
| 137 | 74 |
lib/libcxx/include/__utility/is_pointer_in_range.h+7-7| ... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
| 17 | #include <__type_traits/is_constant_evaluated.h> | 17 | #include <__type_traits/is_constant_evaluated.h> |
| 18 | #include <__type_traits/void_t.h> | 18 | #include <__type_traits/void_t.h> |
| 19 | #include <__utility/declval.h> | 19 | #include <__utility/declval.h> |
| 20 | #include <__utility/is_valid_range.h> | ||
| 20 | 21 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | # pragma GCC system_header | 23 | # pragma GCC system_header |
| ... | @@ -32,24 +33,23 @@ struct __is_less_than_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() | ... | @@ -32,24 +33,23 @@ struct __is_less_than_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() |
| 32 | }; | 33 | }; |
| 33 | 34 | ||
| 34 | template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0> | 35 | template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0> |
| 35 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool __is_pointer_in_range( | 36 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool |
| 36 | const _Tp* __begin, const _Tp* __end, const _Up* __ptr) { | 37 | __is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) { |
| 37 | if (__libcpp_is_constant_evaluated()) { | 38 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__begin, __end), "[__begin, __end) is not a valid range"); |
| 38 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__builtin_constant_p(__begin <= __end), "__begin and __end do not form a range"); | ||
| 39 | 39 | ||
| 40 | if (__libcpp_is_constant_evaluated()) { | ||
| 40 | // If this is not a constant during constant evaluation we know that __ptr is not part of the allocation where | 41 | // If this is not a constant during constant evaluation we know that __ptr is not part of the allocation where |
| 41 | // [__begin, __end) is. | 42 | // [__begin, __end) is. |
| 42 | if (!__builtin_constant_p(__begin <= __ptr && __ptr < __end)) | 43 | if (!__builtin_constant_p(__begin <= __ptr && __ptr < __end)) |
| 43 | return false; | 44 | return false; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | // Checking this for unrelated pointers is technically UB, but no compiler optimizes based on it (currently). | ||
| 47 | return !__less<>()(__ptr, __begin) && __less<>()(__ptr, __end); | 47 | return !__less<>()(__ptr, __begin) && __less<>()(__ptr, __end); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | template <class _Tp, class _Up, __enable_if_t<!__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0> | 50 | template <class _Tp, class _Up, __enable_if_t<!__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0> |
| 51 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool __is_pointer_in_range( | 51 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool |
| 52 | const _Tp* __begin, const _Tp* __end, const _Up* __ptr) { | 52 | __is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) { |
| 53 | if (__libcpp_is_constant_evaluated()) | 53 | if (__libcpp_is_constant_evaluated()) |
| 54 | return false; | 54 | return false; |
| 55 | 55 |
lib/libcxx/include/__utility/is_valid_range.h created+37| ... | @@ -0,0 +1,37 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___UTILITY_IS_VALID_RANGE_H | ||
| 10 | #define _LIBCPP___UTILITY_IS_VALID_RANGE_H | ||
| 11 | |||
| 12 | #include <__algorithm/comp.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__type_traits/is_constant_evaluated.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | template <class _Tp> | ||
| 23 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool | ||
| 24 | __is_valid_range(const _Tp* __first, const _Tp* __last) { | ||
| 25 | if (__libcpp_is_constant_evaluated()) { | ||
| 26 | // If this is not a constant during constant evaluation, that is because __first and __last are not | ||
| 27 | // part of the same allocation. If they are part of the same allocation, we must still make sure they | ||
| 28 | // are ordered properly. | ||
| 29 | return __builtin_constant_p(__first <= __last) && __first <= __last; | ||
| 30 | } | ||
| 31 | |||
| 32 | return !__less<>()(__last, __first); | ||
| 33 | } | ||
| 34 | |||
| 35 | _LIBCPP_END_NAMESPACE_STD | ||
| 36 | |||
| 37 | #endif // _LIBCPP___UTILITY_IS_VALID_RANGE_H | ||
lib/libcxx/include/__utility/move.h+4-4| ... | @@ -12,8 +12,8 @@ | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/conditional.h> | 14 | #include <__type_traits/conditional.h> |
| 15 | #include <__type_traits/is_copy_constructible.h> | 15 | #include <__type_traits/is_constructible.h> |
| 16 | #include <__type_traits/is_nothrow_move_constructible.h> | 16 | #include <__type_traits/is_nothrow_constructible.h> |
| 17 | #include <__type_traits/remove_reference.h> | 17 | #include <__type_traits/remove_reference.h> |
| 18 | 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -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 _Tp> | 28 | template <class _Tp> |
| 29 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&& | 29 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&& |
| 30 | move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT { | 30 | move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT { |
| 31 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up; | 31 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up; |
| 32 | return static_cast<_Up&&>(__t); | 32 | return static_cast<_Up&&>(__t); |
| ... | @@ -37,7 +37,7 @@ using __move_if_noexcept_result_t = | ... | @@ -37,7 +37,7 @@ using __move_if_noexcept_result_t = |
| 37 | __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>; | 37 | __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>; |
| 38 | 38 | ||
| 39 | template <class _Tp> | 39 | template <class _Tp> |
| 40 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp> | 40 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp> |
| 41 | move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT { | 41 | move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT { |
| 42 | return std::move(__x); | 42 | return std::move(__x); |
| 43 | } | 43 | } |
lib/libcxx/include/__utility/no_destroy.h+10-19| ... | @@ -12,6 +12,7 @@ | ... | @@ -12,6 +12,7 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_constant_evaluated.h> | 13 | #include <__type_traits/is_constant_evaluated.h> |
| 14 | #include <__utility/forward.h> | 14 | #include <__utility/forward.h> |
| 15 | #include <new> | ||
| 15 | 16 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 18 | # pragma GCC system_header |
| ... | @@ -29,33 +30,23 @@ struct __uninitialized_tag {}; | ... | @@ -29,33 +30,23 @@ struct __uninitialized_tag {}; |
| 29 | // initialization using __emplace. | 30 | // initialization using __emplace. |
| 30 | template <class _Tp> | 31 | template <class _Tp> |
| 31 | struct __no_destroy { | 32 | struct __no_destroy { |
| 32 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(__uninitialized_tag) : __dummy_() { | 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __no_destroy(__uninitialized_tag) : __obj_() {} |
| 33 | if (__libcpp_is_constant_evaluated()) { | ||
| 34 | __dummy_ = char(); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | _LIBCPP_HIDE_FROM_ABI ~__no_destroy() { | ||
| 38 | // nothing | ||
| 39 | } | ||
| 40 | 34 | ||
| 41 | template <class... _Args> | 35 | template <class... _Args> |
| 42 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args) | 36 | _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args) { |
| 43 | : __obj_(std::forward<_Args>(__args)...) {} | 37 | ::new ((void*)__obj_) _Tp(std::forward<_Args>(__args)...); |
| 38 | } | ||
| 44 | 39 | ||
| 45 | template <class... _Args> | 40 | template <class... _Args> |
| 46 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp& __emplace(_Args&&... __args) { | 41 | _LIBCPP_HIDE_FROM_ABI _Tp& __emplace(_Args&&... __args) { |
| 47 | new (&__obj_) _Tp(std::forward<_Args>(__args)...); | 42 | return *(::new ((void*)__obj_) _Tp(std::forward<_Args>(__args)...)); |
| 48 | return __obj_; | ||
| 49 | } | 43 | } |
| 50 | 44 | ||
| 51 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp& __get() { return __obj_; } | 45 | _LIBCPP_HIDE_FROM_ABI _Tp& __get() { return *reinterpret_cast<_Tp*>(__obj_); } |
| 52 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp const& __get() const { return __obj_; } | 46 | _LIBCPP_HIDE_FROM_ABI _Tp const& __get() const { return *reinterpret_cast<const _Tp*>(__obj_); } |
| 53 | 47 | ||
| 54 | private: | 48 | private: |
| 55 | union { | 49 | _ALIGNAS_TYPE(_Tp) char __obj_[sizeof(_Tp)]; |
| 56 | _Tp __obj_; | ||
| 57 | char __dummy_; // so we can initialize a member even with __uninitialized_tag for constexpr-friendliness | ||
| 58 | }; | ||
| 59 | }; | 50 | }; |
| 60 | 51 | ||
| 61 | _LIBCPP_END_NAMESPACE_STD | 52 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__utility/pair.h+143-167| ... | @@ -14,14 +14,12 @@ | ... | @@ -14,14 +14,12 @@ |
| 14 | #include <__concepts/different_from.h> | 14 | #include <__concepts/different_from.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__fwd/array.h> | 16 | #include <__fwd/array.h> |
| 17 | #include <__fwd/get.h> | ||
| 18 | #include <__fwd/pair.h> | 17 | #include <__fwd/pair.h> |
| 19 | #include <__fwd/subrange.h> | ||
| 20 | #include <__fwd/tuple.h> | 18 | #include <__fwd/tuple.h> |
| 21 | #include <__tuple/pair_like.h> | ||
| 22 | #include <__tuple/sfinae_helpers.h> | 19 | #include <__tuple/sfinae_helpers.h> |
| 23 | #include <__tuple/tuple_element.h> | 20 | #include <__tuple/tuple_element.h> |
| 24 | #include <__tuple/tuple_indices.h> | 21 | #include <__tuple/tuple_indices.h> |
| 22 | #include <__tuple/tuple_like_no_subrange.h> | ||
| 25 | #include <__tuple/tuple_size.h> | 23 | #include <__tuple/tuple_size.h> |
| 26 | #include <__type_traits/common_reference.h> | 24 | #include <__type_traits/common_reference.h> |
| 27 | #include <__type_traits/common_type.h> | 25 | #include <__type_traits/common_type.h> |
| ... | @@ -31,18 +29,13 @@ | ... | @@ -31,18 +29,13 @@ |
| 31 | #include <__type_traits/is_assignable.h> | 29 | #include <__type_traits/is_assignable.h> |
| 32 | #include <__type_traits/is_constructible.h> | 30 | #include <__type_traits/is_constructible.h> |
| 33 | #include <__type_traits/is_convertible.h> | 31 | #include <__type_traits/is_convertible.h> |
| 34 | #include <__type_traits/is_copy_assignable.h> | ||
| 35 | #include <__type_traits/is_default_constructible.h> | ||
| 36 | #include <__type_traits/is_implicitly_default_constructible.h> | 32 | #include <__type_traits/is_implicitly_default_constructible.h> |
| 37 | #include <__type_traits/is_move_assignable.h> | ||
| 38 | #include <__type_traits/is_nothrow_assignable.h> | 33 | #include <__type_traits/is_nothrow_assignable.h> |
| 39 | #include <__type_traits/is_nothrow_constructible.h> | 34 | #include <__type_traits/is_nothrow_constructible.h> |
| 40 | #include <__type_traits/is_nothrow_copy_assignable.h> | 35 | #include <__type_traits/is_reference.h> |
| 41 | #include <__type_traits/is_nothrow_copy_constructible.h> | ||
| 42 | #include <__type_traits/is_nothrow_default_constructible.h> | ||
| 43 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 44 | #include <__type_traits/is_same.h> | 36 | #include <__type_traits/is_same.h> |
| 45 | #include <__type_traits/is_swappable.h> | 37 | #include <__type_traits/is_swappable.h> |
| 38 | #include <__type_traits/is_trivially_relocatable.h> | ||
| 46 | #include <__type_traits/nat.h> | 39 | #include <__type_traits/nat.h> |
| 47 | #include <__type_traits/remove_cvref.h> | 40 | #include <__type_traits/remove_cvref.h> |
| 48 | #include <__type_traits/unwrap_ref.h> | 41 | #include <__type_traits/unwrap_ref.h> |
| ... | @@ -68,14 +61,6 @@ struct __non_trivially_copyable_base { | ... | @@ -68,14 +61,6 @@ struct __non_trivially_copyable_base { |
| 68 | __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} | 61 | __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} |
| 69 | }; | 62 | }; |
| 70 | 63 | ||
| 71 | #if _LIBCPP_STD_VER >= 23 | ||
| 72 | template <class _Tp> | ||
| 73 | struct __is_specialization_of_subrange : false_type {}; | ||
| 74 | |||
| 75 | template <class _Iter, class _Sent, ranges::subrange_kind _Kind> | ||
| 76 | struct __is_specialization_of_subrange<ranges::subrange<_Iter, _Sent, _Kind>> : true_type {}; | ||
| 77 | #endif | ||
| 78 | |||
| 79 | template <class _T1, class _T2> | 64 | template <class _T1, class _T2> |
| 80 | struct _LIBCPP_TEMPLATE_VIS pair | 65 | struct _LIBCPP_TEMPLATE_VIS pair |
| 81 | #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) | 66 | #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) |
| ... | @@ -88,9 +73,46 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -88,9 +73,46 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 88 | _T1 first; | 73 | _T1 first; |
| 89 | _T2 second; | 74 | _T2 second; |
| 90 | 75 | ||
| 76 | using __trivially_relocatable = | ||
| 77 | __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value, | ||
| 78 | pair, | ||
| 79 | void>; | ||
| 80 | |||
| 91 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; | 81 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; |
| 92 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; | 82 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; |
| 93 | 83 | ||
| 84 | // When we are requested for pair to be trivially copyable by the ABI macro, we use defaulted members | ||
| 85 | // if it is both legal to do it (i.e. no references) and we have a way to actually implement it, which requires | ||
| 86 | // the __enable_if__ attribute before C++20. | ||
| 87 | #ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR | ||
| 88 | // FIXME: This should really just be a static constexpr variable. It's in a struct to avoid gdb printing the value | ||
| 89 | // when printing a pair | ||
| 90 | struct __has_defaulted_members { | ||
| 91 | static const bool value = !is_reference<first_type>::value && !is_reference<second_type>::value; | ||
| 92 | }; | ||
| 93 | # if _LIBCPP_STD_VER >= 20 | ||
| 94 | _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(const pair&) | ||
| 95 | requires __has_defaulted_members::value | ||
| 96 | = default; | ||
| 97 | |||
| 98 | _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(pair&&) | ||
| 99 | requires __has_defaulted_members::value | ||
| 100 | = default; | ||
| 101 | # elif __has_attribute(__enable_if__) | ||
| 102 | _LIBCPP_HIDE_FROM_ABI pair& operator=(const pair&) | ||
| 103 | __attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default; | ||
| 104 | |||
| 105 | _LIBCPP_HIDE_FROM_ABI pair& operator=(pair&&) | ||
| 106 | __attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default; | ||
| 107 | # else | ||
| 108 | # error "_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR isn't supported with this compiler" | ||
| 109 | # endif | ||
| 110 | #else | ||
| 111 | struct __has_defaulted_members { | ||
| 112 | static const bool value = false; | ||
| 113 | }; | ||
| 114 | #endif // defined(_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR) && __has_attribute(__enable_if__) | ||
| 115 | |||
| 94 | #ifdef _LIBCPP_CXX03_LANG | 116 | #ifdef _LIBCPP_CXX03_LANG |
| 95 | _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {} | 117 | _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {} |
| 96 | 118 | ||
| ... | @@ -108,10 +130,11 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -108,10 +130,11 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 108 | // Extension: This is provided in C++03 because it allows properly handling the | 130 | // Extension: This is provided in C++03 because it allows properly handling the |
| 109 | // assignment to a pair containing references, which would be a hard | 131 | // assignment to a pair containing references, which would be a hard |
| 110 | // error otherwise. | 132 | // error otherwise. |
| 111 | template <class _U1, | 133 | template < |
| 112 | class _U2, | 134 | class _U1, |
| 113 | class = __enable_if_t< is_assignable<first_type&, _U1 const&>::value && | 135 | class _U2, |
| 114 | is_assignable<second_type&, _U2 const&>::value > > | 136 | __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value, |
| 137 | int> = 0> | ||
| 115 | _LIBCPP_HIDE_FROM_ABI pair& operator=(pair<_U1, _U2> const& __p) { | 138 | _LIBCPP_HIDE_FROM_ABI pair& operator=(pair<_U1, _U2> const& __p) { |
| 116 | first = __p.first; | 139 | first = __p.first; |
| 117 | second = __p.second; | 140 | second = __p.second; |
| ... | @@ -120,14 +143,13 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -120,14 +143,13 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 120 | #else | 143 | #else |
| 121 | struct _CheckArgs { | 144 | struct _CheckArgs { |
| 122 | template <int&...> | 145 | template <int&...> |
| 123 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() { | 146 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { |
| 124 | return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value && | 147 | return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value; |
| 125 | !__enable_implicit_default<>(); | ||
| 126 | } | 148 | } |
| 127 | 149 | ||
| 128 | template <int&...> | 150 | template <int&...> |
| 129 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { | 151 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() { |
| 130 | return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value; | 152 | return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value; |
| 131 | } | 153 | } |
| 132 | 154 | ||
| 133 | template <class _U1, class _U2> | 155 | template <class _U1, class _U2> |
| ... | @@ -139,42 +161,23 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -139,42 +161,23 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 139 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() { | 161 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() { |
| 140 | return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value; | 162 | return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value; |
| 141 | } | 163 | } |
| 142 | |||
| 143 | template <class _U1, class _U2> | ||
| 144 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit() { | ||
| 145 | return __is_pair_constructible<_U1, _U2>() && !__is_implicit<_U1, _U2>(); | ||
| 146 | } | ||
| 147 | |||
| 148 | template <class _U1, class _U2> | ||
| 149 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit() { | ||
| 150 | return __is_pair_constructible<_U1, _U2>() && __is_implicit<_U1, _U2>(); | ||
| 151 | } | ||
| 152 | }; | 164 | }; |
| 153 | 165 | ||
| 154 | template <bool _MaybeEnable> | 166 | template <bool _MaybeEnable> |
| 155 | using _CheckArgsDep _LIBCPP_NODEBUG = | 167 | using _CheckArgsDep _LIBCPP_NODEBUG = |
| 156 | typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; | 168 | typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; |
| 157 | 169 | ||
| 158 | template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_explicit_default(), int> = 0> | 170 | template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0> |
| 159 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair() _NOEXCEPT_( | 171 | explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept( |
| 160 | is_nothrow_default_constructible<first_type>::value&& is_nothrow_default_constructible<second_type>::value) | 172 | is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value) |
| 161 | : first(), second() {} | ||
| 162 | |||
| 163 | template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_implicit_default(), int> = 0> | ||
| 164 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair() _NOEXCEPT_( | ||
| 165 | is_nothrow_default_constructible<first_type>::value&& is_nothrow_default_constructible<second_type>::value) | ||
| 166 | : first(), second() {} | 173 | : first(), second() {} |
| 167 | 174 | ||
| 168 | template <bool _Dummy = true, | 175 | template <bool _Dummy = true, |
| 169 | __enable_if_t<_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>(), int> = 0> | 176 | __enable_if_t<_CheckArgsDep<_Dummy>::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0> |
| 170 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(_T1 const& __t1, _T2 const& __t2) | 177 | _LIBCPP_HIDE_FROM_ABI |
| 171 | _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value&& is_nothrow_copy_constructible<second_type>::value) | 178 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep<_Dummy>::template __is_implicit<_T1 const&, _T2 const&>()) |
| 172 | : first(__t1), second(__t2) {} | 179 | pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value && |
| 173 | 180 | is_nothrow_copy_constructible<second_type>::value) | |
| 174 | template <bool _Dummy = true, | ||
| 175 | __enable_if_t<_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>(), int> = 0> | ||
| 176 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(_T1 const& __t1, _T2 const& __t2) | ||
| 177 | _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value&& is_nothrow_copy_constructible<second_type>::value) | ||
| 178 | : first(__t1), second(__t2) {} | 181 | : first(__t1), second(__t2) {} |
| 179 | 182 | ||
| 180 | template < | 183 | template < |
| ... | @@ -185,32 +188,15 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -185,32 +188,15 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 185 | class _U1, | 188 | class _U1, |
| 186 | class _U2, | 189 | class _U2, |
| 187 | # endif | 190 | # endif |
| 188 | __enable_if_t<_CheckArgs::template __enable_explicit<_U1, _U2>(), int> = 0 > | 191 | __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0 > |
| 189 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(_U1&& __u1, _U2&& __u2) | 192 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>()) |
| 190 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && | 193 | pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value && |
| 191 | is_nothrow_constructible<second_type, _U2>::value)) | 194 | is_nothrow_constructible<second_type, _U2>::value) |
| 192 | : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) { | ||
| 193 | } | ||
| 194 | |||
| 195 | template < | ||
| 196 | # if _LIBCPP_STD_VER >= 23 // http://wg21.link/P1951 | ||
| 197 | class _U1 = _T1, | ||
| 198 | class _U2 = _T2, | ||
| 199 | # else | ||
| 200 | class _U1, | ||
| 201 | class _U2, | ||
| 202 | # endif | ||
| 203 | __enable_if_t<_CheckArgs::template __enable_implicit<_U1, _U2>(), int> = 0 > | ||
| 204 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(_U1&& __u1, _U2&& __u2) | ||
| 205 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && | ||
| 206 | is_nothrow_constructible<second_type, _U2>::value)) | ||
| 207 | : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) { | 195 | : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) { |
| 208 | } | 196 | } |
| 209 | 197 | ||
| 210 | # if _LIBCPP_STD_VER >= 23 | 198 | # if _LIBCPP_STD_VER >= 23 |
| 211 | template <class _U1, | 199 | template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1&, _U2&>(), int> = 0> |
| 212 | class _U2, | ||
| 213 | __enable_if_t< _CheckArgs::template __is_pair_constructible<_U1&, _U2&>() >* = nullptr> | ||
| 214 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) | 200 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) |
| 215 | pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value && | 201 | pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value && |
| 216 | is_nothrow_constructible<second_type, _U2&>::value)) | 202 | is_nothrow_constructible<second_type, _U2&>::value)) |
| ... | @@ -219,36 +205,23 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -219,36 +205,23 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 219 | 205 | ||
| 220 | template <class _U1, | 206 | template <class _U1, |
| 221 | class _U2, | 207 | class _U2, |
| 222 | __enable_if_t<_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>(), int> = 0> | 208 | __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1 const&, _U2 const&>(), int> = 0> |
| 223 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2> const& __p) | 209 | _LIBCPP_HIDE_FROM_ABI |
| 224 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && | 210 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1 const&, _U2 const&>()) |
| 225 | is_nothrow_constructible<second_type, _U2 const&>::value)) | 211 | pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value && |
| 226 | : first(__p.first), second(__p.second) {} | 212 | is_nothrow_constructible<second_type, _U2 const&>::value) |
| 227 | |||
| 228 | template <class _U1, | ||
| 229 | class _U2, | ||
| 230 | __enable_if_t<_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>(), int> = 0> | ||
| 231 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(pair<_U1, _U2> const& __p) | ||
| 232 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && | ||
| 233 | is_nothrow_constructible<second_type, _U2 const&>::value)) | ||
| 234 | : first(__p.first), second(__p.second) {} | 213 | : first(__p.first), second(__p.second) {} |
| 235 | 214 | ||
| 236 | template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_explicit<_U1, _U2>(), int> = 0> | 215 | template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0> |
| 237 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2>&& __p) | 216 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>()) |
| 238 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && | 217 | pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value && |
| 239 | is_nothrow_constructible<second_type, _U2&&>::value)) | 218 | is_nothrow_constructible<second_type, _U2&&>::value) |
| 240 | : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {} | ||
| 241 | |||
| 242 | template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_implicit<_U1, _U2>(), int> = 0> | ||
| 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(pair<_U1, _U2>&& __p) | ||
| 244 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && | ||
| 245 | is_nothrow_constructible<second_type, _U2&&>::value)) | ||
| 246 | : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {} | 219 | : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {} |
| 247 | 220 | ||
| 248 | # if _LIBCPP_STD_VER >= 23 | 221 | # if _LIBCPP_STD_VER >= 23 |
| 249 | template <class _U1, | 222 | template <class _U1, |
| 250 | class _U2, | 223 | class _U2, |
| 251 | __enable_if_t< _CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>() >* = nullptr> | 224 | __enable_if_t<_CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>(), int> = 0> |
| 252 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>()) | 225 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>()) |
| 253 | pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value && | 226 | pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value && |
| 254 | is_nothrow_constructible<second_type, const _U2&&>::value) | 227 | is_nothrow_constructible<second_type, const _U2&&>::value) |
| ... | @@ -256,19 +229,19 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -256,19 +229,19 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 256 | # endif | 229 | # endif |
| 257 | 230 | ||
| 258 | # if _LIBCPP_STD_VER >= 23 | 231 | # if _LIBCPP_STD_VER >= 23 |
| 232 | // TODO: Remove this workaround in LLVM 20. The bug got fixed in Clang 18. | ||
| 259 | // This is a workaround for http://llvm.org/PR60710. We should be able to remove it once Clang is fixed. | 233 | // This is a workaround for http://llvm.org/PR60710. We should be able to remove it once Clang is fixed. |
| 260 | template <class _PairLike> | 234 | template <class _PairLike> |
| 261 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __pair_like_explicit_wknd() { | 235 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __pair_like_explicit_wknd() { |
| 262 | if constexpr (__pair_like<_PairLike>) { | 236 | if constexpr (__pair_like_no_subrange<_PairLike>) { |
| 263 | return !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> || | 237 | return !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> || |
| 264 | !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>; | 238 | !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>; |
| 265 | } | 239 | } |
| 266 | return false; | 240 | return false; |
| 267 | } | 241 | } |
| 268 | 242 | ||
| 269 | template <__pair_like _PairLike> | 243 | template <__pair_like_no_subrange _PairLike> |
| 270 | requires(!__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value && | 244 | requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> && |
| 271 | is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> && | ||
| 272 | is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>) | 245 | is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>) |
| 273 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p) | 246 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p) |
| 274 | : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {} | 247 | : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {} |
| ... | @@ -276,9 +249,8 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -276,9 +249,8 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 276 | 249 | ||
| 277 | template <class... _Args1, class... _Args2> | 250 | template <class... _Args1, class... _Args2> |
| 278 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 251 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 279 | pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) | 252 | pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept( |
| 280 | _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value && | 253 | is_nothrow_constructible<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value) |
| 281 | is_nothrow_constructible<second_type, _Args2...>::value)) | ||
| 282 | : pair(__pc, | 254 | : pair(__pc, |
| 283 | __first_args, | 255 | __first_args, |
| 284 | __second_args, | 256 | __second_args, |
| ... | @@ -286,38 +258,41 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -286,38 +258,41 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 286 | typename __make_tuple_indices<sizeof...(_Args2) >::type()) {} | 258 | typename __make_tuple_indices<sizeof...(_Args2) >::type()) {} |
| 287 | 259 | ||
| 288 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& | 260 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& |
| 289 | operator=(__conditional_t< is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value, | 261 | operator=(__conditional_t<!__has_defaulted_members::value && is_copy_assignable<first_type>::value && |
| 290 | pair, | 262 | is_copy_assignable<second_type>::value, |
| 291 | __nat> const& __p) | 263 | pair, |
| 292 | _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value&& is_nothrow_copy_assignable<second_type>::value) { | 264 | __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value && |
| 265 | is_nothrow_copy_assignable<second_type>::value) { | ||
| 293 | first = __p.first; | 266 | first = __p.first; |
| 294 | second = __p.second; | 267 | second = __p.second; |
| 295 | return *this; | 268 | return *this; |
| 296 | } | 269 | } |
| 297 | 270 | ||
| 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=( | 271 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& |
| 299 | __conditional_t< is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&& | 272 | operator=(__conditional_t<!__has_defaulted_members::value && is_move_assignable<first_type>::value && |
| 300 | __p) | 273 | is_move_assignable<second_type>::value, |
| 301 | _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value&& is_nothrow_move_assignable<second_type>::value) { | 274 | pair, |
| 275 | __nat>&& __p) noexcept(is_nothrow_move_assignable<first_type>::value && | ||
| 276 | is_nothrow_move_assignable<second_type>::value) { | ||
| 302 | first = std::forward<first_type>(__p.first); | 277 | first = std::forward<first_type>(__p.first); |
| 303 | second = std::forward<second_type>(__p.second); | 278 | second = std::forward<second_type>(__p.second); |
| 304 | return *this; | 279 | return *this; |
| 305 | } | 280 | } |
| 306 | 281 | ||
| 307 | template <class _U1, | 282 | template < |
| 308 | class _U2, | 283 | class _U1, |
| 309 | __enable_if_t< is_assignable<first_type&, _U1 const&>::value && | 284 | class _U2, |
| 310 | is_assignable<second_type&, _U2 const&>::value >* = nullptr> | 285 | __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value, |
| 286 | int> = 0> | ||
| 311 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) { | 287 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) { |
| 312 | first = __p.first; | 288 | first = __p.first; |
| 313 | second = __p.second; | 289 | second = __p.second; |
| 314 | return *this; | 290 | return *this; |
| 315 | } | 291 | } |
| 316 | 292 | ||
| 317 | template < | 293 | template <class _U1, |
| 318 | class _U1, | 294 | class _U2, |
| 319 | class _U2, | 295 | __enable_if_t<is_assignable<first_type&, _U1>::value && is_assignable<second_type&, _U2>::value, int> = 0> |
| 320 | __enable_if_t< is_assignable<first_type&, _U1>::value && is_assignable<second_type&, _U2>::value >* = nullptr> | ||
| 321 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2>&& __p) { | 296 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2>&& __p) { |
| 322 | first = std::forward<_U1>(__p.first); | 297 | first = std::forward<_U1>(__p.first); |
| 323 | second = std::forward<_U2>(__p.second); | 298 | second = std::forward<_U2>(__p.second); |
| ... | @@ -325,6 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -325,6 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 325 | } | 300 | } |
| 326 | 301 | ||
| 327 | # if _LIBCPP_STD_VER >= 23 | 302 | # if _LIBCPP_STD_VER >= 23 |
| 303 | template <class = void> | ||
| 328 | _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair const& __p) const | 304 | _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair const& __p) const |
| 329 | noexcept(is_nothrow_copy_assignable_v<const first_type> && is_nothrow_copy_assignable_v<const second_type>) | 305 | noexcept(is_nothrow_copy_assignable_v<const first_type> && is_nothrow_copy_assignable_v<const second_type>) |
| 330 | requires(is_copy_assignable_v<const first_type> && is_copy_assignable_v<const second_type>) | 306 | requires(is_copy_assignable_v<const first_type> && is_copy_assignable_v<const second_type>) |
| ... | @@ -334,6 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -334,6 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 334 | return *this; | 310 | return *this; |
| 335 | } | 311 | } |
| 336 | 312 | ||
| 313 | template <class = void> | ||
| 337 | _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair&& __p) const | 314 | _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair&& __p) const |
| 338 | noexcept(is_nothrow_assignable_v<const first_type&, first_type> && | 315 | noexcept(is_nothrow_assignable_v<const first_type&, first_type> && |
| 339 | is_nothrow_assignable_v<const second_type&, second_type>) | 316 | is_nothrow_assignable_v<const second_type&, second_type>) |
| ... | @@ -362,8 +339,8 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -362,8 +339,8 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 362 | return *this; | 339 | return *this; |
| 363 | } | 340 | } |
| 364 | 341 | ||
| 365 | template <__pair_like _PairLike> | 342 | template <__pair_like_no_subrange _PairLike> |
| 366 | requires(__different_from<_PairLike, pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value && | 343 | requires(__different_from<_PairLike, pair> && |
| 367 | is_assignable_v<first_type&, decltype(std::get<0>(std::declval<_PairLike>()))> && | 344 | is_assignable_v<first_type&, decltype(std::get<0>(std::declval<_PairLike>()))> && |
| 368 | is_assignable_v<second_type&, decltype(std::get<1>(std::declval<_PairLike>()))>) | 345 | is_assignable_v<second_type&, decltype(std::get<1>(std::declval<_PairLike>()))>) |
| 369 | _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(_PairLike&& __p) { | 346 | _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(_PairLike&& __p) { |
| ... | @@ -372,8 +349,8 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -372,8 +349,8 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 372 | return *this; | 349 | return *this; |
| 373 | } | 350 | } |
| 374 | 351 | ||
| 375 | template <__pair_like _PairLike> | 352 | template <__pair_like_no_subrange _PairLike> |
| 376 | requires(__different_from<_PairLike, pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value && | 353 | requires(__different_from<_PairLike, pair> && |
| 377 | is_assignable_v<first_type const&, decltype(std::get<0>(std::declval<_PairLike>()))> && | 354 | is_assignable_v<first_type const&, decltype(std::get<0>(std::declval<_PairLike>()))> && |
| 378 | is_assignable_v<second_type const&, decltype(std::get<1>(std::declval<_PairLike>()))>) | 355 | is_assignable_v<second_type const&, decltype(std::get<1>(std::declval<_PairLike>()))>) |
| 379 | _LIBCPP_HIDE_FROM_ABI constexpr pair const& operator=(_PairLike&& __p) const { | 356 | _LIBCPP_HIDE_FROM_ABI constexpr pair const& operator=(_PairLike&& __p) const { |
| ... | @@ -387,38 +364,36 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -387,38 +364,36 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 387 | // pair-like types. This was historically provided as an extension. | 364 | // pair-like types. This was historically provided as an extension. |
| 388 | # if _LIBCPP_STD_VER < 23 | 365 | # if _LIBCPP_STD_VER < 23 |
| 389 | // from std::tuple | 366 | // from std::tuple |
| 390 | template < | 367 | template <class _U1, |
| 391 | class _U1, | 368 | class _U2, |
| 392 | class _U2, | 369 | __enable_if_t<is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value, int> = 0> |
| 393 | __enable_if_t< is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value >* = nullptr> | ||
| 394 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2> const& __p) | 370 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2> const& __p) |
| 395 | : first(std::get<0>(__p)), second(std::get<1>(__p)) {} | 371 | : first(std::get<0>(__p)), second(std::get<1>(__p)) {} |
| 396 | 372 | ||
| 397 | template < | 373 | template < class _U1, |
| 398 | class _U1, | 374 | class _U2, |
| 399 | class _U2, | 375 | __enable_if_t<is_constructible<_T1, _U1 const&>::value && is_constructible<_T2, _U2 const&>::value && |
| 400 | __enable_if_t< is_constructible<_T1, _U1 const&>::value && is_constructible<_T2, _U2 const&>::value && | 376 | !(is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value), |
| 401 | !(is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value) >* = nullptr> | 377 | int> = 0> |
| 402 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2> const& __p) | 378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2> const& __p) |
| 403 | : first(std::get<0>(__p)), second(std::get<1>(__p)) {} | 379 | : first(std::get<0>(__p)), second(std::get<1>(__p)) {} |
| 404 | 380 | ||
| 405 | template <class _U1, | 381 | template <class _U1, |
| 406 | class _U2, | 382 | class _U2, |
| 407 | __enable_if_t< is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value >* = nullptr> | 383 | __enable_if_t<is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value, int> = 0> |
| 408 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2>&& __p) | 384 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2>&& __p) |
| 409 | : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {} | 385 | : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {} |
| 410 | 386 | ||
| 411 | template <class _U1, | 387 | template <class _U1, |
| 412 | class _U2, | 388 | class _U2, |
| 413 | __enable_if_t< is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value && | 389 | __enable_if_t<is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value && |
| 414 | !(is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value) >* = nullptr> | 390 | !(is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value) > = 0> |
| 415 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2>&& __p) | 391 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2>&& __p) |
| 416 | : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {} | 392 | : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {} |
| 417 | 393 | ||
| 418 | template < | 394 | template <class _U1, |
| 419 | class _U1, | 395 | class _U2, |
| 420 | class _U2, | 396 | __enable_if_t<is_assignable<_T1&, _U1 const&>::value && is_assignable<_T2&, _U2 const&>::value, int> = 0> |
| 421 | __enable_if_t< is_assignable<_T1&, _U1 const&>::value && is_assignable<_T2&, _U2 const&>::value >* = nullptr> | ||
| 422 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2> const& __p) { | 397 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2> const& __p) { |
| 423 | first = std::get<0>(__p); | 398 | first = std::get<0>(__p); |
| 424 | second = std::get<1>(__p); | 399 | second = std::get<1>(__p); |
| ... | @@ -427,7 +402,7 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -427,7 +402,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 427 | 402 | ||
| 428 | template <class _U1, | 403 | template <class _U1, |
| 429 | class _U2, | 404 | class _U2, |
| 430 | __enable_if_t< is_assignable<_T1&, _U1&&>::value && is_assignable<_T2&, _U2&&>::value >* = nullptr> | 405 | __enable_if_t<is_assignable<_T1&, _U1&&>::value && is_assignable<_T2&, _U2&&>::value, int> = 0> |
| 431 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2>&& __p) { | 406 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2>&& __p) { |
| 432 | first = std::get<0>(std::move(__p)); | 407 | first = std::get<0>(std::move(__p)); |
| 433 | second = std::get<1>(std::move(__p)); | 408 | second = std::get<1>(std::move(__p)); |
| ... | @@ -435,38 +410,37 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -435,38 +410,37 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 435 | } | 410 | } |
| 436 | 411 | ||
| 437 | // from std::array | 412 | // from std::array |
| 438 | template < | 413 | template <class _Up, |
| 439 | class _Up, | 414 | __enable_if_t<is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value, int> = 0> |
| 440 | __enable_if_t< is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value >* = nullptr> | ||
| 441 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {} | 415 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {} |
| 442 | 416 | ||
| 443 | template < | 417 | template <class _Up, |
| 444 | class _Up, | 418 | __enable_if_t<is_constructible<_T1, _Up const&>::value && is_constructible<_T2, _Up const&>::value && |
| 445 | __enable_if_t< is_constructible<_T1, _Up const&>::value && is_constructible<_T2, _Up const&>::value && | 419 | !(is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value), |
| 446 | !(is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value) >* = nullptr> | 420 | int> = 0> |
| 447 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2> const& __p) | 421 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2> const& __p) |
| 448 | : first(__p[0]), second(__p[1]) {} | 422 | : first(__p[0]), second(__p[1]) {} |
| 449 | 423 | ||
| 450 | template <class _Up, __enable_if_t< is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value >* = nullptr> | 424 | template <class _Up, __enable_if_t< is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value, int> = 0> |
| 451 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2>&& __p) | 425 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2>&& __p) |
| 452 | : first(std::move(__p)[0]), second(std::move(__p)[1]) {} | 426 | : first(std::move(__p)[0]), second(std::move(__p)[1]) {} |
| 453 | 427 | ||
| 454 | template <class _Up, | 428 | template <class _Up, |
| 455 | __enable_if_t< is_constructible<_T1, _Up>::value && is_constructible<_T2, _Up>::value && | 429 | __enable_if_t<is_constructible<_T1, _Up>::value && is_constructible<_T2, _Up>::value && |
| 456 | !(is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value) >* = nullptr> | 430 | !(is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value), |
| 431 | int> = 0> | ||
| 457 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2>&& __p) | 432 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2>&& __p) |
| 458 | : first(std::move(__p)[0]), second(std::move(__p)[1]) {} | 433 | : first(std::move(__p)[0]), second(std::move(__p)[1]) {} |
| 459 | 434 | ||
| 460 | template < | 435 | template <class _Up, |
| 461 | class _Up, | 436 | __enable_if_t<is_assignable<_T1&, _Up const&>::value && is_assignable<_T2&, _Up const&>::value, int> = 0> |
| 462 | __enable_if_t< is_assignable<_T1&, _Up const&>::value && is_assignable<_T2&, _Up const&>::value >* = nullptr> | ||
| 463 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2> const& __p) { | 437 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2> const& __p) { |
| 464 | first = std::get<0>(__p); | 438 | first = std::get<0>(__p); |
| 465 | second = std::get<1>(__p); | 439 | second = std::get<1>(__p); |
| 466 | return *this; | 440 | return *this; |
| 467 | } | 441 | } |
| 468 | 442 | ||
| 469 | template <class _Up, __enable_if_t< is_assignable<_T1&, _Up>::value && is_assignable<_T2&, _Up>::value >* = nullptr> | 443 | template <class _Up, __enable_if_t<is_assignable<_T1&, _Up>::value && is_assignable<_T2&, _Up>::value, int> = 0> |
| 470 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2>&& __p) { | 444 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2>&& __p) { |
| 471 | first = std::get<0>(std::move(__p)); | 445 | first = std::get<0>(std::move(__p)); |
| 472 | second = std::get<1>(std::move(__p)); | 446 | second = std::get<1>(std::move(__p)); |
| ... | @@ -476,7 +450,7 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -476,7 +450,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 476 | #endif // _LIBCPP_CXX03_LANG | 450 | #endif // _LIBCPP_CXX03_LANG |
| 477 | 451 | ||
| 478 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p) | 452 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p) |
| 479 | _NOEXCEPT_(__is_nothrow_swappable<first_type>::value&& __is_nothrow_swappable<second_type>::value) { | 453 | _NOEXCEPT_(__is_nothrow_swappable_v<first_type>&& __is_nothrow_swappable_v<second_type>) { |
| 480 | using std::swap; | 454 | using std::swap; |
| 481 | swap(first, __p.first); | 455 | swap(first, __p.first); |
| 482 | swap(second, __p.second); | 456 | swap(second, __p.second); |
| ... | @@ -484,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -484,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 484 | 458 | ||
| 485 | #if _LIBCPP_STD_VER >= 23 | 459 | #if _LIBCPP_STD_VER >= 23 |
| 486 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const pair& __p) const | 460 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const pair& __p) const |
| 487 | noexcept(__is_nothrow_swappable<const first_type>::value && __is_nothrow_swappable<const second_type>::value) { | 461 | noexcept(__is_nothrow_swappable_v<const first_type> && __is_nothrow_swappable_v<const second_type>) { |
| 488 | using std::swap; | 462 | using std::swap; |
| 489 | swap(first, __p.first); | 463 | swap(first, __p.first); |
| 490 | swap(second, __p.second); | 464 | swap(second, __p.second); |
| ... | @@ -499,7 +473,9 @@ private: | ... | @@ -499,7 +473,9 @@ private: |
| 499 | tuple<_Args1...>& __first_args, | 473 | tuple<_Args1...>& __first_args, |
| 500 | tuple<_Args2...>& __second_args, | 474 | tuple<_Args2...>& __second_args, |
| 501 | __tuple_indices<_I1...>, | 475 | __tuple_indices<_I1...>, |
| 502 | __tuple_indices<_I2...>); | 476 | __tuple_indices<_I2...>) |
| 477 | : first(std::forward<_Args1>(std::get<_I1>(__first_args))...), | ||
| 478 | second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {} | ||
| 503 | #endif | 479 | #endif |
| 504 | }; | 480 | }; |
| 505 | 481 | ||
| ... | @@ -578,15 +554,15 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { | ... | @@ -578,15 +554,15 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { |
| 578 | }; | 554 | }; |
| 579 | #endif // _LIBCPP_STD_VER >= 23 | 555 | #endif // _LIBCPP_STD_VER >= 23 |
| 580 | 556 | ||
| 581 | template <class _T1, class _T2, __enable_if_t<__is_swappable<_T1>::value && __is_swappable<_T2>::value, int> = 0> | 557 | template <class _T1, class _T2, __enable_if_t<__is_swappable_v<_T1> && __is_swappable_v<_T2>, int> = 0> |
| 582 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | 558 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) |
| 583 | _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value)) { | 559 | _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { |
| 584 | __x.swap(__y); | 560 | __x.swap(__y); |
| 585 | } | 561 | } |
| 586 | 562 | ||
| 587 | #if _LIBCPP_STD_VER >= 23 | 563 | #if _LIBCPP_STD_VER >= 23 |
| 588 | template <class _T1, class _T2> | 564 | template <class _T1, class _T2> |
| 589 | requires(__is_swappable<const _T1>::value && __is_swappable<const _T2>::value) | 565 | requires(__is_swappable_v<const _T1> && __is_swappable_v<const _T2>) |
| 590 | _LIBCPP_HIDE_FROM_ABI constexpr void | 566 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 591 | swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) { | 567 | swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) { |
| 592 | __x.swap(__y); | 568 | __x.swap(__y); |
| ... | @@ -594,9 +570,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x | ... | @@ -594,9 +570,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x |
| 594 | #endif | 570 | #endif |
| 595 | 571 | ||
| 596 | template <class _T1, class _T2> | 572 | template <class _T1, class _T2> |
| 597 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 573 | inline _LIBCPP_HIDE_FROM_ABI |
| 598 | pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> | 574 | _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> |
| 599 | make_pair(_T1&& __t1, _T2&& __t2) { | 575 | make_pair(_T1&& __t1, _T2&& __t2) { |
| 600 | return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>( | 576 | return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>( |
| 601 | std::forward<_T1>(__t1), std::forward<_T2>(__t2)); | 577 | std::forward<_T1>(__t1), std::forward<_T2>(__t2)); |
| 602 | } | 578 | } |
lib/libcxx/include/__utility/private_constructor_tag.h created+28| ... | @@ -0,0 +1,28 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H | ||
| 11 | #define _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | // This tag allows defining non-standard exposition-only constructors while | ||
| 22 | // preventing users from being able to use them, since this reserved-name tag | ||
| 23 | // needs to be used. | ||
| 24 | struct __private_constructor_tag {}; | ||
| 25 | |||
| 26 | _LIBCPP_END_NAMESPACE_STD | ||
| 27 | |||
| 28 | #endif // _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H | ||
lib/libcxx/include/__utility/rel_ops.h+4-4| ... | @@ -20,22 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,22 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | namespace rel_ops { | 20 | namespace rel_ops { |
| 21 | 21 | ||
| 22 | template <class _Tp> | 22 | template <class _Tp> |
| 23 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) { | 23 | inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) { |
| 24 | return !(__x == __y); | 24 | return !(__x == __y); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | inline _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) { | 28 | inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) { |
| 29 | return __y < __x; | 29 | return __y < __x; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | template <class _Tp> | 32 | template <class _Tp> |
| 33 | inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) { | 33 | inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) { |
| 34 | return !(__y < __x); | 34 | return !(__y < __x); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | template <class _Tp> | 37 | template <class _Tp> |
| 38 | inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) { | 38 | inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) { |
| 39 | return !(__x < __y); | 39 | return !(__x < __y); |
| 40 | } | 40 | } |
| 41 | 41 |
lib/libcxx/include/__utility/small_buffer.h+1-1| ... | @@ -12,8 +12,8 @@ | ... | @@ -12,8 +12,8 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__memory/construct_at.h> | 13 | #include <__memory/construct_at.h> |
| 14 | #include <__type_traits/decay.h> | 14 | #include <__type_traits/decay.h> |
| 15 | #include <__type_traits/is_trivially_constructible.h> | ||
| 15 | #include <__type_traits/is_trivially_destructible.h> | 16 | #include <__type_traits/is_trivially_destructible.h> |
| 16 | #include <__type_traits/is_trivially_move_constructible.h> | ||
| 17 | #include <__utility/exception_guard.h> | 17 | #include <__utility/exception_guard.h> |
| 18 | #include <__utility/forward.h> | 18 | #include <__utility/forward.h> |
| 19 | #include <cstddef> | 19 | #include <cstddef> |
lib/libcxx/include/__utility/swap.h+6-6| ... | @@ -10,10 +10,10 @@ | ... | @@ -10,10 +10,10 @@ |
| 10 | #define _LIBCPP___UTILITY_SWAP_H | 10 | #define _LIBCPP___UTILITY_SWAP_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_move_assignable.h> | 13 | #include <__type_traits/is_assignable.h> |
| 14 | #include <__type_traits/is_move_constructible.h> | 14 | #include <__type_traits/is_constructible.h> |
| 15 | #include <__type_traits/is_nothrow_move_assignable.h> | 15 | #include <__type_traits/is_nothrow_assignable.h> |
| 16 | #include <__type_traits/is_nothrow_move_constructible.h> | 16 | #include <__type_traits/is_nothrow_constructible.h> |
| 17 | #include <__type_traits/is_swappable.h> | 17 | #include <__type_traits/is_swappable.h> |
| 18 | #include <__utility/declval.h> | 18 | #include <__utility/declval.h> |
| 19 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| ... | @@ -44,9 +44,9 @@ inline _LIBCPP_HIDE_FROM_ABI __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20 | ... | @@ -44,9 +44,9 @@ inline _LIBCPP_HIDE_FROM_ABI __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 44 | __y = std::move(__t); | 44 | __y = std::move(__t); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> > | 47 | template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> > |
| 48 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) | 48 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) |
| 49 | _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { | 49 | _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) { |
| 50 | for (size_t __i = 0; __i != _Np; ++__i) { | 50 | for (size_t __i = 0; __i != _Np; ++__i) { |
| 51 | swap(__a[__i], __b[__i]); | 51 | swap(__a[__i], __b[__i]); |
| 52 | } | 52 | } |
lib/libcxx/include/__utility/to_underlying.h+1-1| ... | @@ -28,7 +28,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underly | ... | @@ -28,7 +28,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underly |
| 28 | 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 23 | 29 | #if _LIBCPP_STD_VER >= 23 |
| 30 | template <class _Tp> | 30 | template <class _Tp> |
| 31 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr underlying_type_t<_Tp> to_underlying(_Tp __val) noexcept { | 31 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr underlying_type_t<_Tp> to_underlying(_Tp __val) noexcept { |
| 32 | return std::__to_underlying(__val); | 32 | return std::__to_underlying(__val); |
| 33 | } | 33 | } |
| 34 | #endif | 34 | #endif |
lib/libcxx/include/__verbose_abort+1-2| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___VERBOSE_ABORT | 10 | #ifndef _LIBCPP___VERBOSE_ABORT |
| 11 | #define _LIBCPP___VERBOSE_ABORT | 11 | #define _LIBCPP___VERBOSE_ABORT |
| 12 | 12 | ||
| 13 | #include <__availability> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | // 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 |
| 23 | // the _LIBCPP_VERBOSE_ABORT macro. | 22 | // the _LIBCPP_VERBOSE_ABORT macro. |
| 24 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS | 23 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS |
| 25 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...); | 24 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...); |
| 26 | 25 | ||
| 27 | // _LIBCPP_VERBOSE_ABORT(format, args...) | 26 | // _LIBCPP_VERBOSE_ABORT(format, args...) |
| 28 | // | 27 | // |
lib/libcxx/include/algorithm+158-125| ... | @@ -102,6 +102,31 @@ namespace ranges { | ... | @@ -102,6 +102,31 @@ namespace ranges { |
| 102 | constexpr borrowed_iterator_t<R> | 102 | constexpr borrowed_iterator_t<R> |
| 103 | find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 | 103 | find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 |
| 104 | 104 | ||
| 105 | template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity> | ||
| 106 | requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> | ||
| 107 | constexpr subrange<I> find_last(I first, S last, const T& value, Proj proj = {}); // since C++23 | ||
| 108 | |||
| 109 | template<forward_range R, class T, class Proj = identity> | ||
| 110 | requires | ||
| 111 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> | ||
| 112 | constexpr borrowed_subrange_t<R> find_last(R&& r, const T& value, Proj proj = {}); // since C++23 | ||
| 113 | |||
| 114 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | ||
| 115 | indirect_unary_predicate<projected<I, Proj>> Pred> | ||
| 116 | constexpr subrange<I> find_last_if(I first, S last, Pred pred, Proj proj = {}); // since C++23 | ||
| 117 | |||
| 118 | template<forward_range R, class Proj = identity, | ||
| 119 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | ||
| 120 | constexpr borrowed_subrange_t<R> find_last_if(R&& r, Pred pred, Proj proj = {}); // since C++23 | ||
| 121 | |||
| 122 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | ||
| 123 | indirect_unary_predicate<projected<I, Proj>> Pred> | ||
| 124 | constexpr subrange<I> find_last_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++23 | ||
| 125 | |||
| 126 | template<forward_range R, class Proj = identity, | ||
| 127 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | ||
| 128 | constexpr borrowed_subrange_t<R> find_last_if_not(R&& r, Pred pred, Proj proj = {}); // since C++23 | ||
| 129 | |||
| 105 | template<class T, class Proj = identity, | 130 | template<class T, class Proj = identity, |
| 106 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | 131 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> |
| 107 | constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 | 132 | constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 |
| ... | @@ -217,6 +242,19 @@ namespace ranges { | ... | @@ -217,6 +242,19 @@ namespace ranges { |
| 217 | constexpr ranges::minmax_element_result<borrowed_iterator_t<R>> | 242 | constexpr ranges::minmax_element_result<borrowed_iterator_t<R>> |
| 218 | minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | 243 | minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 |
| 219 | 244 | ||
| 245 | template<forward_iterator I1, sentinel_for<I1> S1, | ||
| 246 | forward_iterator I2, sentinel_for<I2> S2, | ||
| 247 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | ||
| 248 | requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> | ||
| 249 | constexpr bool contains_subrange(I1 first1, S1 last1, I2 first2, S2 last2, | ||
| 250 | Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 | ||
| 251 | |||
| 252 | template<forward_range R1, forward_range R2, | ||
| 253 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | ||
| 254 | requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> | ||
| 255 | constexpr bool contains_subrange(R1&& r1, R2&& r2, Pred pred = {}, | ||
| 256 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 | ||
| 257 | |||
| 220 | template<class I, class O> | 258 | template<class I, class O> |
| 221 | using copy_result = in_out_result<I, O>; // since C++20 | 259 | using copy_result = in_out_result<I, O>; // since C++20 |
| 222 | 260 | ||
| ... | @@ -1780,17 +1818,12 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1780,17 +1818,12 @@ template <class BidirectionalIterator, class Compare> |
| 1780 | 1818 | ||
| 1781 | */ | 1819 | */ |
| 1782 | 1820 | ||
| 1783 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 1784 | #include <__config> | 1821 | #include <__config> |
| 1785 | #include <version> | ||
| 1786 | 1822 | ||
| 1787 | #include <__algorithm/adjacent_find.h> | 1823 | #include <__algorithm/adjacent_find.h> |
| 1788 | #include <__algorithm/all_of.h> | 1824 | #include <__algorithm/all_of.h> |
| 1789 | #include <__algorithm/any_of.h> | 1825 | #include <__algorithm/any_of.h> |
| 1790 | #include <__algorithm/binary_search.h> | 1826 | #include <__algorithm/binary_search.h> |
| 1791 | #include <__algorithm/clamp.h> | ||
| 1792 | #include <__algorithm/comp.h> | ||
| 1793 | #include <__algorithm/comp_ref_type.h> | ||
| 1794 | #include <__algorithm/copy.h> | 1827 | #include <__algorithm/copy.h> |
| 1795 | #include <__algorithm/copy_backward.h> | 1828 | #include <__algorithm/copy_backward.h> |
| 1796 | #include <__algorithm/copy_if.h> | 1829 | #include <__algorithm/copy_if.h> |
| ... | @@ -1806,18 +1839,9 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1806,18 +1839,9 @@ template <class BidirectionalIterator, class Compare> |
| 1806 | #include <__algorithm/find_first_of.h> | 1839 | #include <__algorithm/find_first_of.h> |
| 1807 | #include <__algorithm/find_if.h> | 1840 | #include <__algorithm/find_if.h> |
| 1808 | #include <__algorithm/find_if_not.h> | 1841 | #include <__algorithm/find_if_not.h> |
| 1809 | #include <__algorithm/fold.h> | ||
| 1810 | #include <__algorithm/for_each.h> | 1842 | #include <__algorithm/for_each.h> |
| 1811 | #include <__algorithm/for_each_n.h> | ||
| 1812 | #include <__algorithm/generate.h> | 1843 | #include <__algorithm/generate.h> |
| 1813 | #include <__algorithm/generate_n.h> | 1844 | #include <__algorithm/generate_n.h> |
| 1814 | #include <__algorithm/half_positive.h> | ||
| 1815 | #include <__algorithm/in_found_result.h> | ||
| 1816 | #include <__algorithm/in_fun_result.h> | ||
| 1817 | #include <__algorithm/in_in_out_result.h> | ||
| 1818 | #include <__algorithm/in_in_result.h> | ||
| 1819 | #include <__algorithm/in_out_out_result.h> | ||
| 1820 | #include <__algorithm/in_out_result.h> | ||
| 1821 | #include <__algorithm/includes.h> | 1845 | #include <__algorithm/includes.h> |
| 1822 | #include <__algorithm/inplace_merge.h> | 1846 | #include <__algorithm/inplace_merge.h> |
| 1823 | #include <__algorithm/is_heap.h> | 1847 | #include <__algorithm/is_heap.h> |
| ... | @@ -1828,7 +1852,6 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1828,7 +1852,6 @@ template <class BidirectionalIterator, class Compare> |
| 1828 | #include <__algorithm/is_sorted_until.h> | 1852 | #include <__algorithm/is_sorted_until.h> |
| 1829 | #include <__algorithm/iter_swap.h> | 1853 | #include <__algorithm/iter_swap.h> |
| 1830 | #include <__algorithm/lexicographical_compare.h> | 1854 | #include <__algorithm/lexicographical_compare.h> |
| 1831 | #include <__algorithm/lexicographical_compare_three_way.h> | ||
| 1832 | #include <__algorithm/lower_bound.h> | 1855 | #include <__algorithm/lower_bound.h> |
| 1833 | #include <__algorithm/make_heap.h> | 1856 | #include <__algorithm/make_heap.h> |
| 1834 | #include <__algorithm/max.h> | 1857 | #include <__algorithm/max.h> |
| ... | @@ -1836,7 +1859,6 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1836,7 +1859,6 @@ template <class BidirectionalIterator, class Compare> |
| 1836 | #include <__algorithm/merge.h> | 1859 | #include <__algorithm/merge.h> |
| 1837 | #include <__algorithm/min.h> | 1860 | #include <__algorithm/min.h> |
| 1838 | #include <__algorithm/min_element.h> | 1861 | #include <__algorithm/min_element.h> |
| 1839 | #include <__algorithm/min_max_result.h> | ||
| 1840 | #include <__algorithm/minmax.h> | 1862 | #include <__algorithm/minmax.h> |
| 1841 | #include <__algorithm/minmax_element.h> | 1863 | #include <__algorithm/minmax_element.h> |
| 1842 | #include <__algorithm/mismatch.h> | 1864 | #include <__algorithm/mismatch.h> |
| ... | @@ -1852,111 +1874,7 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1852,111 +1874,7 @@ template <class BidirectionalIterator, class Compare> |
| 1852 | #include <__algorithm/partition_point.h> | 1874 | #include <__algorithm/partition_point.h> |
| 1853 | #include <__algorithm/pop_heap.h> | 1875 | #include <__algorithm/pop_heap.h> |
| 1854 | #include <__algorithm/prev_permutation.h> | 1876 | #include <__algorithm/prev_permutation.h> |
| 1855 | #include <__algorithm/pstl_any_all_none_of.h> | ||
| 1856 | #include <__algorithm/pstl_copy.h> | ||
| 1857 | #include <__algorithm/pstl_count.h> | ||
| 1858 | #include <__algorithm/pstl_equal.h> | ||
| 1859 | #include <__algorithm/pstl_fill.h> | ||
| 1860 | #include <__algorithm/pstl_find.h> | ||
| 1861 | #include <__algorithm/pstl_for_each.h> | ||
| 1862 | #include <__algorithm/pstl_generate.h> | ||
| 1863 | #include <__algorithm/pstl_is_partitioned.h> | ||
| 1864 | #include <__algorithm/pstl_merge.h> | ||
| 1865 | #include <__algorithm/pstl_move.h> | ||
| 1866 | #include <__algorithm/pstl_replace.h> | ||
| 1867 | #include <__algorithm/pstl_rotate_copy.h> | ||
| 1868 | #include <__algorithm/pstl_sort.h> | ||
| 1869 | #include <__algorithm/pstl_stable_sort.h> | ||
| 1870 | #include <__algorithm/pstl_transform.h> | ||
| 1871 | #include <__algorithm/push_heap.h> | 1877 | #include <__algorithm/push_heap.h> |
| 1872 | #include <__algorithm/ranges_adjacent_find.h> | ||
| 1873 | #include <__algorithm/ranges_all_of.h> | ||
| 1874 | #include <__algorithm/ranges_any_of.h> | ||
| 1875 | #include <__algorithm/ranges_binary_search.h> | ||
| 1876 | #include <__algorithm/ranges_clamp.h> | ||
| 1877 | #include <__algorithm/ranges_contains.h> | ||
| 1878 | #include <__algorithm/ranges_copy.h> | ||
| 1879 | #include <__algorithm/ranges_copy_backward.h> | ||
| 1880 | #include <__algorithm/ranges_copy_if.h> | ||
| 1881 | #include <__algorithm/ranges_copy_n.h> | ||
| 1882 | #include <__algorithm/ranges_count.h> | ||
| 1883 | #include <__algorithm/ranges_count_if.h> | ||
| 1884 | #include <__algorithm/ranges_ends_with.h> | ||
| 1885 | #include <__algorithm/ranges_equal.h> | ||
| 1886 | #include <__algorithm/ranges_equal_range.h> | ||
| 1887 | #include <__algorithm/ranges_fill.h> | ||
| 1888 | #include <__algorithm/ranges_fill_n.h> | ||
| 1889 | #include <__algorithm/ranges_find.h> | ||
| 1890 | #include <__algorithm/ranges_find_end.h> | ||
| 1891 | #include <__algorithm/ranges_find_first_of.h> | ||
| 1892 | #include <__algorithm/ranges_find_if.h> | ||
| 1893 | #include <__algorithm/ranges_find_if_not.h> | ||
| 1894 | #include <__algorithm/ranges_for_each.h> | ||
| 1895 | #include <__algorithm/ranges_for_each_n.h> | ||
| 1896 | #include <__algorithm/ranges_generate.h> | ||
| 1897 | #include <__algorithm/ranges_generate_n.h> | ||
| 1898 | #include <__algorithm/ranges_includes.h> | ||
| 1899 | #include <__algorithm/ranges_inplace_merge.h> | ||
| 1900 | #include <__algorithm/ranges_is_heap.h> | ||
| 1901 | #include <__algorithm/ranges_is_heap_until.h> | ||
| 1902 | #include <__algorithm/ranges_is_partitioned.h> | ||
| 1903 | #include <__algorithm/ranges_is_permutation.h> | ||
| 1904 | #include <__algorithm/ranges_is_sorted.h> | ||
| 1905 | #include <__algorithm/ranges_is_sorted_until.h> | ||
| 1906 | #include <__algorithm/ranges_lexicographical_compare.h> | ||
| 1907 | #include <__algorithm/ranges_lower_bound.h> | ||
| 1908 | #include <__algorithm/ranges_make_heap.h> | ||
| 1909 | #include <__algorithm/ranges_max.h> | ||
| 1910 | #include <__algorithm/ranges_max_element.h> | ||
| 1911 | #include <__algorithm/ranges_merge.h> | ||
| 1912 | #include <__algorithm/ranges_min.h> | ||
| 1913 | #include <__algorithm/ranges_min_element.h> | ||
| 1914 | #include <__algorithm/ranges_minmax.h> | ||
| 1915 | #include <__algorithm/ranges_minmax_element.h> | ||
| 1916 | #include <__algorithm/ranges_mismatch.h> | ||
| 1917 | #include <__algorithm/ranges_move.h> | ||
| 1918 | #include <__algorithm/ranges_move_backward.h> | ||
| 1919 | #include <__algorithm/ranges_next_permutation.h> | ||
| 1920 | #include <__algorithm/ranges_none_of.h> | ||
| 1921 | #include <__algorithm/ranges_nth_element.h> | ||
| 1922 | #include <__algorithm/ranges_partial_sort.h> | ||
| 1923 | #include <__algorithm/ranges_partial_sort_copy.h> | ||
| 1924 | #include <__algorithm/ranges_partition.h> | ||
| 1925 | #include <__algorithm/ranges_partition_copy.h> | ||
| 1926 | #include <__algorithm/ranges_partition_point.h> | ||
| 1927 | #include <__algorithm/ranges_pop_heap.h> | ||
| 1928 | #include <__algorithm/ranges_prev_permutation.h> | ||
| 1929 | #include <__algorithm/ranges_push_heap.h> | ||
| 1930 | #include <__algorithm/ranges_remove.h> | ||
| 1931 | #include <__algorithm/ranges_remove_copy.h> | ||
| 1932 | #include <__algorithm/ranges_remove_copy_if.h> | ||
| 1933 | #include <__algorithm/ranges_remove_if.h> | ||
| 1934 | #include <__algorithm/ranges_replace.h> | ||
| 1935 | #include <__algorithm/ranges_replace_copy.h> | ||
| 1936 | #include <__algorithm/ranges_replace_copy_if.h> | ||
| 1937 | #include <__algorithm/ranges_replace_if.h> | ||
| 1938 | #include <__algorithm/ranges_reverse.h> | ||
| 1939 | #include <__algorithm/ranges_reverse_copy.h> | ||
| 1940 | #include <__algorithm/ranges_rotate.h> | ||
| 1941 | #include <__algorithm/ranges_rotate_copy.h> | ||
| 1942 | #include <__algorithm/ranges_sample.h> | ||
| 1943 | #include <__algorithm/ranges_search.h> | ||
| 1944 | #include <__algorithm/ranges_search_n.h> | ||
| 1945 | #include <__algorithm/ranges_set_difference.h> | ||
| 1946 | #include <__algorithm/ranges_set_intersection.h> | ||
| 1947 | #include <__algorithm/ranges_set_symmetric_difference.h> | ||
| 1948 | #include <__algorithm/ranges_set_union.h> | ||
| 1949 | #include <__algorithm/ranges_shuffle.h> | ||
| 1950 | #include <__algorithm/ranges_sort.h> | ||
| 1951 | #include <__algorithm/ranges_sort_heap.h> | ||
| 1952 | #include <__algorithm/ranges_stable_partition.h> | ||
| 1953 | #include <__algorithm/ranges_stable_sort.h> | ||
| 1954 | #include <__algorithm/ranges_starts_with.h> | ||
| 1955 | #include <__algorithm/ranges_swap_ranges.h> | ||
| 1956 | #include <__algorithm/ranges_transform.h> | ||
| 1957 | #include <__algorithm/ranges_unique.h> | ||
| 1958 | #include <__algorithm/ranges_unique_copy.h> | ||
| 1959 | #include <__algorithm/ranges_upper_bound.h> | ||
| 1960 | #include <__algorithm/remove.h> | 1878 | #include <__algorithm/remove.h> |
| 1961 | #include <__algorithm/remove_copy.h> | 1879 | #include <__algorithm/remove_copy.h> |
| 1962 | #include <__algorithm/remove_copy_if.h> | 1880 | #include <__algorithm/remove_copy_if.h> |
| ... | @@ -1969,17 +1887,13 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1969,17 +1887,13 @@ template <class BidirectionalIterator, class Compare> |
| 1969 | #include <__algorithm/reverse_copy.h> | 1887 | #include <__algorithm/reverse_copy.h> |
| 1970 | #include <__algorithm/rotate.h> | 1888 | #include <__algorithm/rotate.h> |
| 1971 | #include <__algorithm/rotate_copy.h> | 1889 | #include <__algorithm/rotate_copy.h> |
| 1972 | #include <__algorithm/sample.h> | ||
| 1973 | #include <__algorithm/search.h> | 1890 | #include <__algorithm/search.h> |
| 1974 | #include <__algorithm/search_n.h> | 1891 | #include <__algorithm/search_n.h> |
| 1975 | #include <__algorithm/set_difference.h> | 1892 | #include <__algorithm/set_difference.h> |
| 1976 | #include <__algorithm/set_intersection.h> | 1893 | #include <__algorithm/set_intersection.h> |
| 1977 | #include <__algorithm/set_symmetric_difference.h> | 1894 | #include <__algorithm/set_symmetric_difference.h> |
| 1978 | #include <__algorithm/set_union.h> | 1895 | #include <__algorithm/set_union.h> |
| 1979 | #include <__algorithm/shift_left.h> | ||
| 1980 | #include <__algorithm/shift_right.h> | ||
| 1981 | #include <__algorithm/shuffle.h> | 1896 | #include <__algorithm/shuffle.h> |
| 1982 | #include <__algorithm/sift_down.h> | ||
| 1983 | #include <__algorithm/sort.h> | 1897 | #include <__algorithm/sort.h> |
| 1984 | #include <__algorithm/sort_heap.h> | 1898 | #include <__algorithm/sort_heap.h> |
| 1985 | #include <__algorithm/stable_partition.h> | 1899 | #include <__algorithm/stable_partition.h> |
| ... | @@ -1988,9 +1902,124 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1988,9 +1902,124 @@ template <class BidirectionalIterator, class Compare> |
| 1988 | #include <__algorithm/transform.h> | 1902 | #include <__algorithm/transform.h> |
| 1989 | #include <__algorithm/unique.h> | 1903 | #include <__algorithm/unique.h> |
| 1990 | #include <__algorithm/unique_copy.h> | 1904 | #include <__algorithm/unique_copy.h> |
| 1991 | #include <__algorithm/unwrap_iter.h> | ||
| 1992 | #include <__algorithm/upper_bound.h> | 1905 | #include <__algorithm/upper_bound.h> |
| 1993 | 1906 | ||
| 1907 | #if _LIBCPP_STD_VER >= 17 | ||
| 1908 | # include <__algorithm/clamp.h> | ||
| 1909 | # include <__algorithm/for_each_n.h> | ||
| 1910 | # include <__algorithm/pstl.h> | ||
| 1911 | # include <__algorithm/sample.h> | ||
| 1912 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 1913 | |||
| 1914 | #if _LIBCPP_STD_VER >= 20 | ||
| 1915 | # include <__algorithm/in_found_result.h> | ||
| 1916 | # include <__algorithm/in_fun_result.h> | ||
| 1917 | # include <__algorithm/in_in_out_result.h> | ||
| 1918 | # include <__algorithm/in_in_result.h> | ||
| 1919 | # include <__algorithm/in_out_out_result.h> | ||
| 1920 | # include <__algorithm/in_out_result.h> | ||
| 1921 | # include <__algorithm/lexicographical_compare_three_way.h> | ||
| 1922 | # include <__algorithm/min_max_result.h> | ||
| 1923 | # include <__algorithm/ranges_adjacent_find.h> | ||
| 1924 | # include <__algorithm/ranges_all_of.h> | ||
| 1925 | # include <__algorithm/ranges_any_of.h> | ||
| 1926 | # include <__algorithm/ranges_binary_search.h> | ||
| 1927 | # include <__algorithm/ranges_clamp.h> | ||
| 1928 | # include <__algorithm/ranges_contains.h> | ||
| 1929 | # include <__algorithm/ranges_copy.h> | ||
| 1930 | # include <__algorithm/ranges_copy_backward.h> | ||
| 1931 | # include <__algorithm/ranges_copy_if.h> | ||
| 1932 | # include <__algorithm/ranges_copy_n.h> | ||
| 1933 | # include <__algorithm/ranges_count.h> | ||
| 1934 | # include <__algorithm/ranges_count_if.h> | ||
| 1935 | # include <__algorithm/ranges_equal.h> | ||
| 1936 | # include <__algorithm/ranges_equal_range.h> | ||
| 1937 | # include <__algorithm/ranges_fill.h> | ||
| 1938 | # include <__algorithm/ranges_fill_n.h> | ||
| 1939 | # include <__algorithm/ranges_find.h> | ||
| 1940 | # include <__algorithm/ranges_find_end.h> | ||
| 1941 | # include <__algorithm/ranges_find_first_of.h> | ||
| 1942 | # include <__algorithm/ranges_find_if.h> | ||
| 1943 | # include <__algorithm/ranges_find_if_not.h> | ||
| 1944 | # include <__algorithm/ranges_for_each.h> | ||
| 1945 | # include <__algorithm/ranges_for_each_n.h> | ||
| 1946 | # include <__algorithm/ranges_generate.h> | ||
| 1947 | # include <__algorithm/ranges_generate_n.h> | ||
| 1948 | # include <__algorithm/ranges_includes.h> | ||
| 1949 | # include <__algorithm/ranges_inplace_merge.h> | ||
| 1950 | # include <__algorithm/ranges_is_heap.h> | ||
| 1951 | # include <__algorithm/ranges_is_heap_until.h> | ||
| 1952 | # include <__algorithm/ranges_is_partitioned.h> | ||
| 1953 | # include <__algorithm/ranges_is_permutation.h> | ||
| 1954 | # include <__algorithm/ranges_is_sorted.h> | ||
| 1955 | # include <__algorithm/ranges_is_sorted_until.h> | ||
| 1956 | # include <__algorithm/ranges_lexicographical_compare.h> | ||
| 1957 | # include <__algorithm/ranges_lower_bound.h> | ||
| 1958 | # include <__algorithm/ranges_make_heap.h> | ||
| 1959 | # include <__algorithm/ranges_max.h> | ||
| 1960 | # include <__algorithm/ranges_max_element.h> | ||
| 1961 | # include <__algorithm/ranges_merge.h> | ||
| 1962 | # include <__algorithm/ranges_min.h> | ||
| 1963 | # include <__algorithm/ranges_min_element.h> | ||
| 1964 | # include <__algorithm/ranges_minmax.h> | ||
| 1965 | # include <__algorithm/ranges_minmax_element.h> | ||
| 1966 | # include <__algorithm/ranges_mismatch.h> | ||
| 1967 | # include <__algorithm/ranges_move.h> | ||
| 1968 | # include <__algorithm/ranges_move_backward.h> | ||
| 1969 | # include <__algorithm/ranges_next_permutation.h> | ||
| 1970 | # include <__algorithm/ranges_none_of.h> | ||
| 1971 | # include <__algorithm/ranges_nth_element.h> | ||
| 1972 | # include <__algorithm/ranges_partial_sort.h> | ||
| 1973 | # include <__algorithm/ranges_partial_sort_copy.h> | ||
| 1974 | # include <__algorithm/ranges_partition.h> | ||
| 1975 | # include <__algorithm/ranges_partition_copy.h> | ||
| 1976 | # include <__algorithm/ranges_partition_point.h> | ||
| 1977 | # include <__algorithm/ranges_pop_heap.h> | ||
| 1978 | # include <__algorithm/ranges_prev_permutation.h> | ||
| 1979 | # include <__algorithm/ranges_push_heap.h> | ||
| 1980 | # include <__algorithm/ranges_remove.h> | ||
| 1981 | # include <__algorithm/ranges_remove_copy.h> | ||
| 1982 | # include <__algorithm/ranges_remove_copy_if.h> | ||
| 1983 | # include <__algorithm/ranges_remove_if.h> | ||
| 1984 | # include <__algorithm/ranges_replace.h> | ||
| 1985 | # include <__algorithm/ranges_replace_copy.h> | ||
| 1986 | # include <__algorithm/ranges_replace_copy_if.h> | ||
| 1987 | # include <__algorithm/ranges_replace_if.h> | ||
| 1988 | # include <__algorithm/ranges_reverse.h> | ||
| 1989 | # include <__algorithm/ranges_reverse_copy.h> | ||
| 1990 | # include <__algorithm/ranges_rotate.h> | ||
| 1991 | # include <__algorithm/ranges_rotate_copy.h> | ||
| 1992 | # include <__algorithm/ranges_sample.h> | ||
| 1993 | # include <__algorithm/ranges_search.h> | ||
| 1994 | # include <__algorithm/ranges_search_n.h> | ||
| 1995 | # include <__algorithm/ranges_set_difference.h> | ||
| 1996 | # include <__algorithm/ranges_set_intersection.h> | ||
| 1997 | # include <__algorithm/ranges_set_symmetric_difference.h> | ||
| 1998 | # include <__algorithm/ranges_set_union.h> | ||
| 1999 | # include <__algorithm/ranges_shuffle.h> | ||
| 2000 | # include <__algorithm/ranges_sort.h> | ||
| 2001 | # include <__algorithm/ranges_sort_heap.h> | ||
| 2002 | # include <__algorithm/ranges_stable_partition.h> | ||
| 2003 | # include <__algorithm/ranges_stable_sort.h> | ||
| 2004 | # include <__algorithm/ranges_swap_ranges.h> | ||
| 2005 | # include <__algorithm/ranges_transform.h> | ||
| 2006 | # include <__algorithm/ranges_unique.h> | ||
| 2007 | # include <__algorithm/ranges_unique_copy.h> | ||
| 2008 | # include <__algorithm/ranges_upper_bound.h> | ||
| 2009 | # include <__algorithm/shift_left.h> | ||
| 2010 | # include <__algorithm/shift_right.h> | ||
| 2011 | #endif | ||
| 2012 | |||
| 2013 | #if _LIBCPP_STD_VER >= 23 | ||
| 2014 | # include <__algorithm/fold.h> | ||
| 2015 | # include <__algorithm/ranges_contains_subrange.h> | ||
| 2016 | # include <__algorithm/ranges_ends_with.h> | ||
| 2017 | # include <__algorithm/ranges_find_last.h> | ||
| 2018 | # include <__algorithm/ranges_starts_with.h> | ||
| 2019 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 2020 | |||
| 2021 | #include <version> | ||
| 2022 | |||
| 1994 | // standard-mandated includes | 2023 | // standard-mandated includes |
| 1995 | 2024 | ||
| 1996 | // [algorithm.syn] | 2025 | // [algorithm.syn] |
| ... | @@ -2000,6 +2029,10 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -2000,6 +2029,10 @@ template <class BidirectionalIterator, class Compare> |
| 2000 | # pragma GCC system_header | 2029 | # pragma GCC system_header |
| 2001 | #endif | 2030 | #endif |
| 2002 | 2031 | ||
| 2032 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14 | ||
| 2033 | # include <execution> | ||
| 2034 | #endif | ||
| 2035 | |||
| 2003 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 2036 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 2004 | # include <atomic> | 2037 | # include <atomic> |
| 2005 | # include <bit> | 2038 | # include <bit> |
lib/libcxx/include/any+4-7| ... | @@ -80,8 +80,6 @@ namespace std { | ... | @@ -80,8 +80,6 @@ namespace std { |
| 80 | 80 | ||
| 81 | */ | 81 | */ |
| 82 | 82 | ||
| 83 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 84 | #include <__availability> | ||
| 85 | #include <__config> | 83 | #include <__config> |
| 86 | #include <__memory/allocator.h> | 84 | #include <__memory/allocator.h> |
| 87 | #include <__memory/allocator_destructor.h> | 85 | #include <__memory/allocator_destructor.h> |
| ... | @@ -93,9 +91,8 @@ namespace std { | ... | @@ -93,9 +91,8 @@ namespace std { |
| 93 | #include <__type_traits/conditional.h> | 91 | #include <__type_traits/conditional.h> |
| 94 | #include <__type_traits/decay.h> | 92 | #include <__type_traits/decay.h> |
| 95 | #include <__type_traits/is_constructible.h> | 93 | #include <__type_traits/is_constructible.h> |
| 96 | #include <__type_traits/is_copy_constructible.h> | ||
| 97 | #include <__type_traits/is_function.h> | 94 | #include <__type_traits/is_function.h> |
| 98 | #include <__type_traits/is_nothrow_move_constructible.h> | 95 | #include <__type_traits/is_nothrow_constructible.h> |
| 99 | #include <__type_traits/is_reference.h> | 96 | #include <__type_traits/is_reference.h> |
| 100 | #include <__type_traits/is_same.h> | 97 | #include <__type_traits/is_same.h> |
| 101 | #include <__type_traits/is_void.h> | 98 | #include <__type_traits/is_void.h> |
| ... | @@ -208,7 +205,7 @@ public: | ... | @@ -208,7 +205,7 @@ public: |
| 208 | template < class _ValueType, | 205 | template < class _ValueType, |
| 209 | class _Tp = decay_t<_ValueType>, | 206 | class _Tp = decay_t<_ValueType>, |
| 210 | class = enable_if_t< !is_same<_Tp, any>::value && !__is_inplace_type<_ValueType>::value && | 207 | class = enable_if_t< !is_same<_Tp, any>::value && !__is_inplace_type<_ValueType>::value && |
| 211 | is_copy_constructible<_Tp>::value> > | 208 | is_copy_constructible<_Tp>::value> > |
| 212 | _LIBCPP_HIDE_FROM_ABI any(_ValueType&& __value); | 209 | _LIBCPP_HIDE_FROM_ABI any(_ValueType&& __value); |
| 213 | 210 | ||
| 214 | template <class _ValueType, | 211 | template <class _ValueType, |
| ... | @@ -222,7 +219,7 @@ public: | ... | @@ -222,7 +219,7 @@ public: |
| 222 | class... _Args, | 219 | class... _Args, |
| 223 | class _Tp = decay_t<_ValueType>, | 220 | class _Tp = decay_t<_ValueType>, |
| 224 | class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value && | 221 | class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value && |
| 225 | is_copy_constructible<_Tp>::value> > | 222 | is_copy_constructible<_Tp>::value> > |
| 226 | _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args); | 223 | _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args); |
| 227 | 224 | ||
| 228 | _LIBCPP_HIDE_FROM_ABI ~any() { this->reset(); } | 225 | _LIBCPP_HIDE_FROM_ABI ~any() { this->reset(); } |
| ... | @@ -254,7 +251,7 @@ public: | ... | @@ -254,7 +251,7 @@ public: |
| 254 | class... _Args, | 251 | class... _Args, |
| 255 | class _Tp = decay_t<_ValueType>, | 252 | class _Tp = decay_t<_ValueType>, |
| 256 | class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value && | 253 | class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value && |
| 257 | is_copy_constructible<_Tp>::value> > | 254 | is_copy_constructible<_Tp>::value> > |
| 258 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up>, _Args&&...); | 255 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up>, _Args&&...); |
| 259 | 256 | ||
| 260 | // 6.3.3 any modifiers | 257 | // 6.3.3 any modifiers |
lib/libcxx/include/array+24-19| ... | @@ -116,20 +116,21 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce | ... | @@ -116,20 +116,21 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce |
| 116 | #include <__algorithm/lexicographical_compare.h> | 116 | #include <__algorithm/lexicographical_compare.h> |
| 117 | #include <__algorithm/lexicographical_compare_three_way.h> | 117 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 118 | #include <__algorithm/swap_ranges.h> | 118 | #include <__algorithm/swap_ranges.h> |
| 119 | #include <__assert> // all public C++ headers provide the assertion handler | 119 | #include <__assert> |
| 120 | #include <__config> | 120 | #include <__config> |
| 121 | #include <__fwd/array.h> | 121 | #include <__fwd/array.h> |
| 122 | #include <__iterator/reverse_iterator.h> | 122 | #include <__iterator/reverse_iterator.h> |
| 123 | #include <__iterator/wrap_iter.h> | ||
| 123 | #include <__tuple/sfinae_helpers.h> | 124 | #include <__tuple/sfinae_helpers.h> |
| 124 | #include <__type_traits/conditional.h> | 125 | #include <__type_traits/conditional.h> |
| 126 | #include <__type_traits/conjunction.h> | ||
| 125 | #include <__type_traits/is_array.h> | 127 | #include <__type_traits/is_array.h> |
| 126 | #include <__type_traits/is_const.h> | 128 | #include <__type_traits/is_const.h> |
| 127 | #include <__type_traits/is_constructible.h> | 129 | #include <__type_traits/is_constructible.h> |
| 128 | #include <__type_traits/is_move_constructible.h> | ||
| 129 | #include <__type_traits/is_nothrow_constructible.h> | 130 | #include <__type_traits/is_nothrow_constructible.h> |
| 130 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 131 | #include <__type_traits/is_same.h> | 131 | #include <__type_traits/is_same.h> |
| 132 | #include <__type_traits/is_swappable.h> | 132 | #include <__type_traits/is_swappable.h> |
| 133 | #include <__type_traits/is_trivially_relocatable.h> | ||
| 133 | #include <__type_traits/remove_cv.h> | 134 | #include <__type_traits/remove_cv.h> |
| 134 | #include <__utility/empty.h> | 135 | #include <__utility/empty.h> |
| 135 | #include <__utility/integer_sequence.h> | 136 | #include <__utility/integer_sequence.h> |
| ... | @@ -166,15 +167,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -166,15 +167,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 166 | 167 | ||
| 167 | template <class _Tp, size_t _Size> | 168 | template <class _Tp, size_t _Size> |
| 168 | struct _LIBCPP_TEMPLATE_VIS array { | 169 | struct _LIBCPP_TEMPLATE_VIS array { |
| 170 | using __trivially_relocatable = __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; | ||
| 171 | |||
| 169 | // types: | 172 | // types: |
| 170 | using __self = array; | 173 | using __self = array; |
| 171 | using value_type = _Tp; | 174 | using value_type = _Tp; |
| 172 | using reference = value_type&; | 175 | using reference = value_type&; |
| 173 | using const_reference = const value_type&; | 176 | using const_reference = const value_type&; |
| 174 | using iterator = value_type*; | 177 | using pointer = value_type*; |
| 175 | using const_iterator = const value_type*; | 178 | using const_pointer = const value_type*; |
| 176 | using pointer = value_type*; | 179 | #if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) |
| 177 | using const_pointer = const value_type*; | 180 | using iterator = __wrap_iter<pointer>; |
| 181 | using const_iterator = __wrap_iter<const_pointer>; | ||
| 182 | #else | ||
| 183 | using iterator = pointer; | ||
| 184 | using const_iterator = const_pointer; | ||
| 185 | #endif | ||
| 178 | using size_type = size_t; | 186 | using size_type = size_t; |
| 179 | using difference_type = ptrdiff_t; | 187 | using difference_type = ptrdiff_t; |
| 180 | using reverse_iterator = std::reverse_iterator<iterator>; | 188 | using reverse_iterator = std::reverse_iterator<iterator>; |
| ... | @@ -187,8 +195,7 @@ struct _LIBCPP_TEMPLATE_VIS array { | ... | @@ -187,8 +195,7 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 187 | std::fill_n(data(), _Size, __u); | 195 | std::fill_n(data(), _Size, __u); |
| 188 | } | 196 | } |
| 189 | 197 | ||
| 190 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a) | 198 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) { |
| 191 | _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { | ||
| 192 | std::swap_ranges(data(), data() + _Size, __a.data()); | 199 | std::swap_ranges(data(), data() + _Size, __a.data()); |
| 193 | } | 200 | } |
| 194 | 201 | ||
| ... | @@ -225,9 +232,7 @@ struct _LIBCPP_TEMPLATE_VIS array { | ... | @@ -225,9 +232,7 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 225 | // capacity: | 232 | // capacity: |
| 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; } | 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; } |
| 227 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; } | 234 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; } |
| 228 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { | 235 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } |
| 229 | return _Size == 0; | ||
| 230 | } | ||
| 231 | 236 | ||
| 232 | // element access: | 237 | // element access: |
| 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT { | 238 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT { |
| ... | @@ -330,7 +335,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { | ... | @@ -330,7 +335,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { |
| 330 | // capacity: | 335 | // capacity: |
| 331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; } | 336 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; } |
| 332 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; } | 337 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; } |
| 333 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } | 338 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } |
| 334 | 339 | ||
| 335 | // element access: | 340 | // element access: |
| 336 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT { | 341 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT { |
| ... | @@ -418,12 +423,12 @@ template <class _Tp, size_t _Size> | ... | @@ -418,12 +423,12 @@ template <class _Tp, size_t _Size> |
| 418 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> | 423 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> |
| 419 | operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { | 424 | operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { |
| 420 | return std::lexicographical_compare_three_way( | 425 | return std::lexicographical_compare_three_way( |
| 421 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>); | 426 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 422 | } | 427 | } |
| 423 | 428 | ||
| 424 | #endif // _LIBCPP_STD_VER <= 17 | 429 | #endif // _LIBCPP_STD_VER <= 17 |
| 425 | 430 | ||
| 426 | template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, int> = 0> | 431 | template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0> |
| 427 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) | 432 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) |
| 428 | _NOEXCEPT_(noexcept(__x.swap(__y))) { | 433 | _NOEXCEPT_(noexcept(__x.swap(__y))) { |
| 429 | __x.swap(__y); | 434 | __x.swap(__y); |
lib/libcxx/include/atomic+11-6| ... | @@ -587,7 +587,12 @@ template <class T> | ... | @@ -587,7 +587,12 @@ template <class T> |
| 587 | 587 | ||
| 588 | */ | 588 | */ |
| 589 | 589 | ||
| 590 | #include <__assert> // all public C++ headers provide the assertion handler | 590 | #include <__config> |
| 591 | |||
| 592 | #if _LIBCPP_STD_VER < 23 && defined(_LIBCPP_STDATOMIC_H) | ||
| 593 | # error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23. | ||
| 594 | #endif | ||
| 595 | |||
| 591 | #include <__atomic/aliases.h> | 596 | #include <__atomic/aliases.h> |
| 592 | #include <__atomic/atomic.h> | 597 | #include <__atomic/atomic.h> |
| 593 | #include <__atomic/atomic_base.h> | 598 | #include <__atomic/atomic_base.h> |
| ... | @@ -602,9 +607,12 @@ template <class T> | ... | @@ -602,9 +607,12 @@ template <class T> |
| 602 | #include <__atomic/is_always_lock_free.h> | 607 | #include <__atomic/is_always_lock_free.h> |
| 603 | #include <__atomic/kill_dependency.h> | 608 | #include <__atomic/kill_dependency.h> |
| 604 | #include <__atomic/memory_order.h> | 609 | #include <__atomic/memory_order.h> |
| 605 | #include <__config> | ||
| 606 | #include <version> | 610 | #include <version> |
| 607 | 611 | ||
| 612 | #if _LIBCPP_STD_VER >= 20 | ||
| 613 | # include <__atomic/atomic_ref.h> | ||
| 614 | #endif | ||
| 615 | |||
| 608 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 616 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 609 | # pragma GCC system_header | 617 | # pragma GCC system_header |
| 610 | #endif | 618 | #endif |
| ... | @@ -613,13 +621,10 @@ template <class T> | ... | @@ -613,13 +621,10 @@ template <class T> |
| 613 | # error <atomic> is not implemented | 621 | # error <atomic> is not implemented |
| 614 | #endif | 622 | #endif |
| 615 | 623 | ||
| 616 | #ifdef kill_dependency | ||
| 617 | # error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23. | ||
| 618 | #endif | ||
| 619 | |||
| 620 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 624 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 621 | # include <cmath> | 625 | # include <cmath> |
| 622 | # include <compare> | 626 | # include <compare> |
| 627 | # include <cstdlib> | ||
| 623 | # include <cstring> | 628 | # include <cstring> |
| 624 | # include <type_traits> | 629 | # include <type_traits> |
| 625 | #endif | 630 | #endif |
lib/libcxx/include/barrier+32-33| ... | @@ -47,31 +47,28 @@ namespace std | ... | @@ -47,31 +47,28 @@ namespace std |
| 47 | 47 | ||
| 48 | #include <__config> | 48 | #include <__config> |
| 49 | 49 | ||
| 50 | #ifdef _LIBCPP_HAS_NO_THREADS | 50 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 51 | # error "<barrier> is not supported since libc++ has been configured without support for threads." | 51 | |
| 52 | #endif | 52 | # include <__assert> |
| 53 | 53 | # include <__atomic/atomic_base.h> | |
| 54 | #include <__assert> // all public C++ headers provide the assertion handler | 54 | # include <__atomic/memory_order.h> |
| 55 | #include <__atomic/atomic_base.h> | 55 | # include <__memory/unique_ptr.h> |
| 56 | #include <__atomic/memory_order.h> | 56 | # include <__thread/poll_with_backoff.h> |
| 57 | #include <__availability> | 57 | # include <__thread/timed_backoff_policy.h> |
| 58 | #include <__memory/unique_ptr.h> | 58 | # include <__utility/move.h> |
| 59 | #include <__thread/poll_with_backoff.h> | 59 | # include <cstddef> |
| 60 | #include <__thread/timed_backoff_policy.h> | 60 | # include <cstdint> |
| 61 | #include <__utility/move.h> | 61 | # include <limits> |
| 62 | #include <cstddef> | 62 | # include <version> |
| 63 | #include <cstdint> | 63 | |
| 64 | #include <limits> | 64 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 65 | #include <version> | 65 | # pragma GCC system_header |
| 66 | 66 | # endif | |
| 67 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 68 | # pragma GCC system_header | ||
| 69 | #endif | ||
| 70 | 67 | ||
| 71 | _LIBCPP_PUSH_MACROS | 68 | _LIBCPP_PUSH_MACROS |
| 72 | #include <__undef_macros> | 69 | # include <__undef_macros> |
| 73 | 70 | ||
| 74 | #if _LIBCPP_STD_VER >= 14 | 71 | # if _LIBCPP_STD_VER >= 14 |
| 75 | 72 | ||
| 76 | _LIBCPP_BEGIN_NAMESPACE_STD | 73 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 77 | 74 | ||
| ... | @@ -79,7 +76,7 @@ struct __empty_completion { | ... | @@ -79,7 +76,7 @@ struct __empty_completion { |
| 79 | inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {} | 76 | inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {} |
| 80 | }; | 77 | }; |
| 81 | 78 | ||
| 82 | # ifndef _LIBCPP_HAS_NO_TREE_BARRIER | 79 | # ifndef _LIBCPP_HAS_NO_TREE_BARRIER |
| 83 | 80 | ||
| 84 | /* | 81 | /* |
| 85 | 82 | ||
| ... | @@ -103,10 +100,10 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* | ... | @@ -103,10 +100,10 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* |
| 103 | __construct_barrier_algorithm_base(ptrdiff_t& __expected); | 100 | __construct_barrier_algorithm_base(ptrdiff_t& __expected); |
| 104 | 101 | ||
| 105 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI bool | 102 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI bool |
| 106 | __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase); | 103 | __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept; |
| 107 | 104 | ||
| 108 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 105 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void |
| 109 | __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier); | 106 | __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept; |
| 110 | 107 | ||
| 111 | template <class _CompletionF> | 108 | template <class _CompletionF> |
| 112 | class __barrier_base { | 109 | class __barrier_base { |
| ... | @@ -128,7 +125,7 @@ public: | ... | @@ -128,7 +125,7 @@ public: |
| 128 | __expected_adjustment_(0), | 125 | __expected_adjustment_(0), |
| 129 | __completion_(std::move(__completion)), | 126 | __completion_(std::move(__completion)), |
| 130 | __phase_(0) {} | 127 | __phase_(0) {} |
| 131 | [[__nodiscard__]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { | 128 | _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { |
| 132 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 129 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 133 | __update <= __expected_, "update is greater than the expected count for the current barrier phase"); | 130 | __update <= __expected_, "update is greater than the expected count for the current barrier phase"); |
| 134 | 131 | ||
| ... | @@ -153,7 +150,7 @@ public: | ... | @@ -153,7 +150,7 @@ public: |
| 153 | } | 150 | } |
| 154 | }; | 151 | }; |
| 155 | 152 | ||
| 156 | # else | 153 | # else |
| 157 | 154 | ||
| 158 | /* | 155 | /* |
| 159 | 156 | ||
| ... | @@ -254,10 +251,10 @@ public: | ... | @@ -254,10 +251,10 @@ public: |
| 254 | } | 251 | } |
| 255 | }; | 252 | }; |
| 256 | 253 | ||
| 257 | # endif // !_LIBCPP_HAS_NO_TREE_BARRIER | 254 | # endif // !_LIBCPP_HAS_NO_TREE_BARRIER |
| 258 | 255 | ||
| 259 | template <class _CompletionF = __empty_completion> | 256 | template <class _CompletionF = __empty_completion> |
| 260 | class barrier { | 257 | class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier { |
| 261 | __barrier_base<_CompletionF> __b_; | 258 | __barrier_base<_CompletionF> __b_; |
| 262 | 259 | ||
| 263 | public: | 260 | public: |
| ... | @@ -265,8 +262,8 @@ public: | ... | @@ -265,8 +262,8 @@ public: |
| 265 | 262 | ||
| 266 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return __barrier_base<_CompletionF>::max(); } | 263 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return __barrier_base<_CompletionF>::max(); } |
| 267 | 264 | ||
| 268 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI explicit barrier( | 265 | _LIBCPP_AVAILABILITY_SYNC |
| 269 | ptrdiff_t __count, _CompletionF __completion = _CompletionF()) | 266 | _LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) |
| 270 | : __b_(__count, std::move(__completion)) { | 267 | : __b_(__count, std::move(__completion)) { |
| 271 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 268 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 272 | __count >= 0, | 269 | __count >= 0, |
| ... | @@ -280,7 +277,7 @@ public: | ... | @@ -280,7 +277,7 @@ public: |
| 280 | barrier(barrier const&) = delete; | 277 | barrier(barrier const&) = delete; |
| 281 | barrier& operator=(barrier const&) = delete; | 278 | barrier& operator=(barrier const&) = delete; |
| 282 | 279 | ||
| 283 | [[__nodiscard__]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { | 280 | _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { |
| 284 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0"); | 281 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0"); |
| 285 | return __b_.arrive(__update); | 282 | return __b_.arrive(__update); |
| 286 | } | 283 | } |
| ... | @@ -293,10 +290,12 @@ public: | ... | @@ -293,10 +290,12 @@ public: |
| 293 | 290 | ||
| 294 | _LIBCPP_END_NAMESPACE_STD | 291 | _LIBCPP_END_NAMESPACE_STD |
| 295 | 292 | ||
| 296 | #endif // _LIBCPP_STD_VER >= 14 | 293 | # endif // _LIBCPP_STD_VER >= 14 |
| 297 | 294 | ||
| 298 | _LIBCPP_POP_MACROS | 295 | _LIBCPP_POP_MACROS |
| 299 | 296 | ||
| 297 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 298 | |||
| 300 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 299 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 301 | # include <atomic> | 300 | # include <atomic> |
| 302 | # include <concepts> | 301 | # include <concepts> |
lib/libcxx/include/bit+23-14| ... | @@ -61,27 +61,36 @@ namespace std { | ... | @@ -61,27 +61,36 @@ namespace std { |
| 61 | 61 | ||
| 62 | */ | 62 | */ |
| 63 | 63 | ||
| 64 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 65 | #include <__bit/bit_cast.h> | ||
| 66 | #include <__bit/bit_ceil.h> | ||
| 67 | #include <__bit/bit_floor.h> | ||
| 68 | #include <__bit/bit_log2.h> | ||
| 69 | #include <__bit/bit_width.h> | ||
| 70 | #include <__bit/blsr.h> | ||
| 71 | #include <__bit/byteswap.h> | ||
| 72 | #include <__bit/countl.h> | ||
| 73 | #include <__bit/countr.h> | ||
| 74 | #include <__bit/endian.h> | ||
| 75 | #include <__bit/has_single_bit.h> | ||
| 76 | #include <__bit/popcount.h> | ||
| 77 | #include <__bit/rotate.h> | ||
| 78 | #include <__config> | 64 | #include <__config> |
| 65 | |||
| 66 | #if _LIBCPP_STD_VER >= 20 | ||
| 67 | # include <__bit/bit_cast.h> | ||
| 68 | # include <__bit/bit_ceil.h> | ||
| 69 | # include <__bit/bit_floor.h> | ||
| 70 | # include <__bit/bit_log2.h> | ||
| 71 | # include <__bit/bit_width.h> | ||
| 72 | # include <__bit/countl.h> | ||
| 73 | # include <__bit/countr.h> | ||
| 74 | # include <__bit/endian.h> | ||
| 75 | # include <__bit/has_single_bit.h> | ||
| 76 | # include <__bit/popcount.h> | ||
| 77 | # include <__bit/rotate.h> | ||
| 78 | #endif | ||
| 79 | |||
| 80 | #if _LIBCPP_STD_VER >= 23 | ||
| 81 | # include <__bit/byteswap.h> | ||
| 82 | #endif | ||
| 83 | |||
| 79 | #include <version> | 84 | #include <version> |
| 80 | 85 | ||
| 81 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 86 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 82 | # pragma GCC system_header | 87 | # pragma GCC system_header |
| 83 | #endif | 88 | #endif |
| 84 | 89 | ||
| 90 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | ||
| 91 | # include <cstdint> | ||
| 92 | #endif | ||
| 93 | |||
| 85 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 94 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 86 | # include <cstdlib> | 95 | # include <cstdlib> |
| 87 | # include <iosfwd> | 96 | # include <iosfwd> |
lib/libcxx/include/bitset+4-2| ... | @@ -129,7 +129,6 @@ template <size_t N> struct hash<std::bitset<N>>; | ... | @@ -129,7 +129,6 @@ template <size_t N> struct hash<std::bitset<N>>; |
| 129 | #include <__algorithm/count.h> | 129 | #include <__algorithm/count.h> |
| 130 | #include <__algorithm/fill.h> | 130 | #include <__algorithm/fill.h> |
| 131 | #include <__algorithm/find.h> | 131 | #include <__algorithm/find.h> |
| 132 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 133 | #include <__bit_reference> | 132 | #include <__bit_reference> |
| 134 | #include <__config> | 133 | #include <__config> |
| 135 | #include <__functional/hash.h> | 134 | #include <__functional/hash.h> |
| ... | @@ -376,8 +375,11 @@ template <size_t _N_words, size_t _Size> | ... | @@ -376,8 +375,11 @@ template <size_t _N_words, size_t _Size> |
| 376 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long | 375 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long |
| 377 | __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const { | 376 | __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const { |
| 378 | unsigned long long __r = __first_[0]; | 377 | unsigned long long __r = __first_[0]; |
| 378 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 379 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow") | ||
| 379 | for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) | 380 | for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) |
| 380 | __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); | 381 | __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); |
| 382 | _LIBCPP_DIAGNOSTIC_POP | ||
| 381 | return __r; | 383 | return __r; |
| 382 | } | 384 | } |
| 383 | 385 | ||
| ... | @@ -618,7 +620,7 @@ public: | ... | @@ -618,7 +620,7 @@ public: |
| 618 | // 23.3.5.1 constructors: | 620 | // 23.3.5.1 constructors: |
| 619 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} | 621 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} |
| 620 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} | 622 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} |
| 621 | template <class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> > | 623 | template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0> |
| 622 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( | 624 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( |
| 623 | const _CharT* __str, | 625 | const _CharT* __str, |
| 624 | #if _LIBCPP_STD_VER >= 26 | 626 | #if _LIBCPP_STD_VER >= 26 |
lib/libcxx/include/cassert-1| ... | @@ -16,7 +16,6 @@ Macros: | ... | @@ -16,7 +16,6 @@ Macros: |
| 16 | 16 | ||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 20 | #include <__config> | 19 | #include <__config> |
| 21 | 20 | ||
| 22 | // <assert.h> is not provided by libc++ | 21 | // <assert.h> is not provided by libc++ |
lib/libcxx/include/ccomplex-1| ... | @@ -17,7 +17,6 @@ | ... | @@ -17,7 +17,6 @@ |
| 17 | 17 | ||
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 21 | #include <complex> | 20 | #include <complex> |
| 22 | 21 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/cctype-1| ... | @@ -34,7 +34,6 @@ int toupper(int c); | ... | @@ -34,7 +34,6 @@ int toupper(int c); |
| 34 | } // std | 34 | } // std |
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 38 | #include <__config> | 37 | #include <__config> |
| 39 | 38 | ||
| 40 | #include <ctype.h> | 39 | #include <ctype.h> |
lib/libcxx/include/cerrno+7-1| ... | @@ -22,7 +22,6 @@ Macros: | ... | @@ -22,7 +22,6 @@ Macros: |
| 22 | 22 | ||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 26 | #include <__config> | 25 | #include <__config> |
| 27 | 26 | ||
| 28 | #include <errno.h> | 27 | #include <errno.h> |
| ... | @@ -39,4 +38,11 @@ Macros: | ... | @@ -39,4 +38,11 @@ Macros: |
| 39 | # pragma GCC system_header | 38 | # pragma GCC system_header |
| 40 | #endif | 39 | #endif |
| 41 | 40 | ||
| 41 | // LWG3869 Deprecate std::errc constants related to UNIX STREAMS | ||
| 42 | // | ||
| 43 | // This LWG issue deprecates the POSIX macros ENODATA, ENOSR, ENOSTR, and ETIME. These were | ||
| 44 | // deprecated in libc++ in https://github.com/llvm/llvm-project/pull/80542. | ||
| 45 | // Based on the post commit feedback the macro are no longer deprecated. | ||
| 46 | // Instead libc++ leaves the deprecation to the provider of errno.h. | ||
| 47 | |||
| 42 | #endif // _LIBCPP_CERRNO | 48 | #endif // _LIBCPP_CERRNO |
lib/libcxx/include/cfenv-1| ... | @@ -52,7 +52,6 @@ int feupdateenv(const fenv_t* envp); | ... | @@ -52,7 +52,6 @@ int feupdateenv(const fenv_t* envp); |
| 52 | } // std | 52 | } // std |
| 53 | */ | 53 | */ |
| 54 | 54 | ||
| 55 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 56 | #include <__config> | 55 | #include <__config> |
| 57 | 56 | ||
| 58 | #include <fenv.h> | 57 | #include <fenv.h> |
lib/libcxx/include/cfloat-1| ... | @@ -69,7 +69,6 @@ Macros: | ... | @@ -69,7 +69,6 @@ Macros: |
| 69 | LDBL_TRUE_MIN // C11 | 69 | LDBL_TRUE_MIN // C11 |
| 70 | */ | 70 | */ |
| 71 | 71 | ||
| 72 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 73 | #include <__config> | 72 | #include <__config> |
| 74 | 73 | ||
| 75 | #include <float.h> | 74 | #include <float.h> |
lib/libcxx/include/charconv+21-12| ... | @@ -69,19 +69,21 @@ namespace std { | ... | @@ -69,19 +69,21 @@ namespace std { |
| 69 | 69 | ||
| 70 | */ | 70 | */ |
| 71 | 71 | ||
| 72 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 73 | #include <__charconv/chars_format.h> | ||
| 74 | #include <__charconv/from_chars_integral.h> | ||
| 75 | #include <__charconv/from_chars_result.h> | ||
| 76 | #include <__charconv/tables.h> | ||
| 77 | #include <__charconv/to_chars.h> | ||
| 78 | #include <__charconv/to_chars_base_10.h> | ||
| 79 | #include <__charconv/to_chars_floating_point.h> | ||
| 80 | #include <__charconv/to_chars_integral.h> | ||
| 81 | #include <__charconv/to_chars_result.h> | ||
| 82 | #include <__charconv/traits.h> | ||
| 83 | #include <__config> | 72 | #include <__config> |
| 84 | #include <__system_error/errc.h> | 73 | |
| 74 | #if _LIBCPP_STD_VER >= 17 | ||
| 75 | # include <__charconv/chars_format.h> | ||
| 76 | # include <__charconv/from_chars_integral.h> | ||
| 77 | # include <__charconv/from_chars_result.h> | ||
| 78 | # include <__charconv/tables.h> | ||
| 79 | # include <__charconv/to_chars.h> | ||
| 80 | # include <__charconv/to_chars_base_10.h> | ||
| 81 | # include <__charconv/to_chars_floating_point.h> | ||
| 82 | # include <__charconv/to_chars_integral.h> | ||
| 83 | # include <__charconv/to_chars_result.h> | ||
| 84 | # include <__charconv/traits.h> | ||
| 85 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 86 | |||
| 85 | #include <version> | 87 | #include <version> |
| 86 | 88 | ||
| 87 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 89 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -92,6 +94,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -92,6 +94,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 92 | 94 | ||
| 93 | _LIBCPP_END_NAMESPACE_STD | 95 | _LIBCPP_END_NAMESPACE_STD |
| 94 | 96 | ||
| 97 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | ||
| 98 | # include <cerrno> | ||
| 99 | # include <cstddef> | ||
| 100 | # include <initializer_list> | ||
| 101 | # include <new> | ||
| 102 | #endif | ||
| 103 | |||
| 95 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 104 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 96 | # include <cmath> | 105 | # include <cmath> |
| 97 | # include <concepts> | 106 | # include <concepts> |
lib/libcxx/include/chrono+195-38| ... | @@ -58,7 +58,7 @@ public: | ... | @@ -58,7 +58,7 @@ public: |
| 58 | constexpr explicit duration(const Rep2& r, | 58 | constexpr explicit duration(const Rep2& r, |
| 59 | typename enable_if | 59 | typename enable_if |
| 60 | < | 60 | < |
| 61 | is_convertible<Rep2, rep>::value && | 61 | is_convertible<const Rep2&, rep>::value && |
| 62 | (treat_as_floating_point<rep>::value || | 62 | (treat_as_floating_point<rep>::value || |
| 63 | !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value) | 63 | !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value) |
| 64 | >::type* = 0); | 64 | >::type* = 0); |
| ... | @@ -686,6 +686,12 @@ constexpr hours make24(const hours& h, bool is_pm) noexcept; | ... | @@ -686,6 +686,12 @@ constexpr hours make24(const hours& h, bool is_pm) noexcept; |
| 686 | // [time.zone.db], time zone database | 686 | // [time.zone.db], time zone database |
| 687 | struct tzdb { // C++20 | 687 | struct tzdb { // C++20 |
| 688 | string version; | 688 | string version; |
| 689 | vector<time_zone> zones; | ||
| 690 | vector<time_zone_link> links; | ||
| 691 | vector<leap_second> leap_seconds; | ||
| 692 | |||
| 693 | const time_zone* locate_zone(string_view tz_name) const; | ||
| 694 | const time_zone* current_zone() const; | ||
| 689 | }; | 695 | }; |
| 690 | 696 | ||
| 691 | class tzdb_list { // C++20 | 697 | class tzdb_list { // C++20 |
| ... | @@ -711,20 +717,145 @@ public: | ... | @@ -711,20 +717,145 @@ public: |
| 711 | // [time.zone.db.access], time zone database access | 717 | // [time.zone.db.access], time zone database access |
| 712 | const tzdb& get_tzdb(); // C++20 | 718 | const tzdb& get_tzdb(); // C++20 |
| 713 | tzdb_list& get_tzdb_list(); // C++20 | 719 | tzdb_list& get_tzdb_list(); // C++20 |
| 720 | const time_zone* locate_zone(string_view tz_name); // C++20 | ||
| 721 | const time_zone* current_zone() // C++20 | ||
| 714 | 722 | ||
| 715 | // [time.zone.db.remote], remote time zone database support | 723 | // [time.zone.db.remote], remote time zone database support |
| 716 | const tzdb& reload_tzdb(); // C++20 | 724 | const tzdb& reload_tzdb(); // C++20 |
| 717 | string remote_version(); // C++20 | 725 | string remote_version(); // C++20 |
| 718 | 726 | ||
| 719 | // 25.10.5, class time_zone // C++20 | 727 | // [time.zone.exception], exception classes |
| 728 | class nonexistent_local_time; // C++20 | ||
| 729 | class ambiguous_local_time; // C++20 | ||
| 730 | |||
| 731 | // [time.zone.info], information classes | ||
| 732 | struct sys_info { // C++20 | ||
| 733 | sys_seconds begin; | ||
| 734 | sys_seconds end; | ||
| 735 | seconds offset; | ||
| 736 | minutes save; | ||
| 737 | string abbrev; | ||
| 738 | }; | ||
| 739 | |||
| 740 | template<class charT, class traits> // C++20 | ||
| 741 | basic_ostream<charT, traits>& | ||
| 742 | operator<<(basic_ostream<charT, traits>& os, const sys_info& si); | ||
| 743 | |||
| 744 | struct local_info { // C++20 | ||
| 745 | static constexpr int unique = 0; | ||
| 746 | static constexpr int nonexistent = 1; | ||
| 747 | static constexpr int ambiguous = 2; | ||
| 748 | |||
| 749 | int result; | ||
| 750 | sys_info first; | ||
| 751 | sys_info second; | ||
| 752 | }; | ||
| 753 | |||
| 754 | template<class charT, class traits> // C++20 | ||
| 755 | basic_ostream<charT, traits>& | ||
| 756 | operator<<(basic_ostream<charT, traits>& os, const local_info& li); | ||
| 757 | |||
| 758 | // 25.10.5, class time_zone // C++20 | ||
| 720 | enum class choose {earliest, latest}; | 759 | enum class choose {earliest, latest}; |
| 721 | class time_zone; | 760 | class time_zone { |
| 722 | bool operator==(const time_zone& x, const time_zone& y) noexcept; | 761 | time_zone(time_zone&&) = default; |
| 723 | bool operator!=(const time_zone& x, const time_zone& y) noexcept; | 762 | time_zone& operator=(time_zone&&) = default; |
| 724 | bool operator<(const time_zone& x, const time_zone& y) noexcept; | 763 | |
| 725 | bool operator>(const time_zone& x, const time_zone& y) noexcept; | 764 | // unspecified additional constructors |
| 726 | bool operator<=(const time_zone& x, const time_zone& y) noexcept; | 765 | |
| 727 | bool operator>=(const time_zone& x, const time_zone& y) noexcept; | 766 | string_view name() const noexcept; |
| 767 | |||
| 768 | template<class Duration> | ||
| 769 | sys_info get_info(const sys_time<Duration>& st) const; | ||
| 770 | |||
| 771 | template<class Duration> | ||
| 772 | local_info get_info(const local_time<Duration>& tp) const; | ||
| 773 | |||
| 774 | template<class Duration> | ||
| 775 | sys_time<common_type_t<Duration, seconds>> | ||
| 776 | to_sys(const local_time<Duration>& tp) const; | ||
| 777 | |||
| 778 | template<class Duration> | ||
| 779 | sys_time<common_type_t<Duration, seconds>> | ||
| 780 | to_sys(const local_time<Duration>& tp, choose z) const; | ||
| 781 | |||
| 782 | template<class Duration> | ||
| 783 | local_time<common_type_t<Duration, seconds>> | ||
| 784 | to_local(const sys_time<Duration>& tp) const; | ||
| 785 | }; | ||
| 786 | bool operator==(const time_zone& x, const time_zone& y) noexcept; // C++20 | ||
| 787 | strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept; // C++20 | ||
| 788 | |||
| 789 | // [time.zone.zonedtraits], class template zoned_traits | ||
| 790 | template<class T> struct zoned_traits; // C++20 | ||
| 791 | |||
| 792 | // [time.zone.zonedtime], class template zoned_time | ||
| 793 | template<class Duration, class TimeZonePtr = const time_zone*> // C++20 | ||
| 794 | class zoned_time; | ||
| 795 | |||
| 796 | using zoned_seconds = zoned_time<seconds>; // C++20 | ||
| 797 | |||
| 798 | template<class Duration1, class Duration2, class TimeZonePtr> // C++20 | ||
| 799 | bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, | ||
| 800 | const zoned_time<Duration2, TimeZonePtr>& y); | ||
| 801 | |||
| 802 | template<class charT, class traits, class Duration, class TimeZonePtr> // C++20 | ||
| 803 | basic_ostream<charT, traits>& | ||
| 804 | operator<<(basic_ostream<charT, traits>& os, | ||
| 805 | const zoned_time<Duration, TimeZonePtr>& t); | ||
| 806 | |||
| 807 | // [time.zone.leap], leap second support | ||
| 808 | class leap_second { // C++20 | ||
| 809 | public: | ||
| 810 | leap_second(const leap_second&) = default; | ||
| 811 | leap_second& operator=(const leap_second&) = default; | ||
| 812 | |||
| 813 | // unspecified additional constructors | ||
| 814 | |||
| 815 | constexpr sys_seconds date() const noexcept; | ||
| 816 | constexpr seconds value() const noexcept; | ||
| 817 | }; | ||
| 818 | |||
| 819 | constexpr bool operator==(const leap_second& x, const leap_second& y); // C++20 | ||
| 820 | constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y); | ||
| 821 | |||
| 822 | template<class Duration> // C++20 | ||
| 823 | constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y); | ||
| 824 | template<class Duration> // C++20 | ||
| 825 | constexpr bool operator< (const leap_second& x, const sys_time<Duration>& y); | ||
| 826 | template<class Duration> // C++20 | ||
| 827 | constexpr bool operator< (const sys_time<Duration>& x, const leap_second& y); | ||
| 828 | template<class Duration> // C++20 | ||
| 829 | constexpr bool operator> (const leap_second& x, const sys_time<Duration>& y); | ||
| 830 | template<class Duration> // C++20 | ||
| 831 | constexpr bool operator> (const sys_time<Duration>& x, const leap_second& y); | ||
| 832 | template<class Duration> // C++20 | ||
| 833 | constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y); | ||
| 834 | template<class Duration> // C++20 | ||
| 835 | constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y); | ||
| 836 | template<class Duration> // C++20 | ||
| 837 | constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y); | ||
| 838 | template<class Duration> // C++20 | ||
| 839 | constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y); | ||
| 840 | template<class Duration> // C++20 | ||
| 841 | requires three_way_comparable_with<sys_seconds, sys_time<Duration>> | ||
| 842 | constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y); | ||
| 843 | |||
| 844 | // [time.zone.link], class time_zone_link | ||
| 845 | class time_zone_link { // C++20 | ||
| 846 | public: | ||
| 847 | time_zone_link(time_zone_link&&) = default; | ||
| 848 | time_zone_link& operator=(time_zone_link&&) = default; | ||
| 849 | |||
| 850 | // unspecified additional constructors | ||
| 851 | |||
| 852 | string_view name() const noexcept; | ||
| 853 | string_view target() const noexcept; | ||
| 854 | }; | ||
| 855 | |||
| 856 | bool operator==(const time_zone_link& x, const time_zone_link& y); // C++20 | ||
| 857 | strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); // C++20 | ||
| 858 | |||
| 728 | } // chrono | 859 | } // chrono |
| 729 | 860 | ||
| 730 | namespace std { | 861 | namespace std { |
| ... | @@ -753,6 +884,10 @@ namespace std { | ... | @@ -753,6 +884,10 @@ namespace std { |
| 753 | template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20 | 884 | template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20 |
| 754 | template<class Rep, class Period, class charT> | 885 | template<class Rep, class Period, class charT> |
| 755 | struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20 | 886 | struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20 |
| 887 | template<class charT> struct formatter<chrono::sys_info, charT>; // C++20 | ||
| 888 | template<class charT> struct formatter<chrono::local_info, charT>; // C++20 | ||
| 889 | template<class Duration, class TimeZonePtr, class charT> // C++20 | ||
| 890 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>; | ||
| 756 | } // namespace std | 891 | } // namespace std |
| 757 | 892 | ||
| 758 | namespace chrono { | 893 | namespace chrono { |
| ... | @@ -804,28 +939,51 @@ constexpr chrono::year operator ""y(unsigned lo | ... | @@ -804,28 +939,51 @@ constexpr chrono::year operator ""y(unsigned lo |
| 804 | 939 | ||
| 805 | // clang-format on | 940 | // clang-format on |
| 806 | 941 | ||
| 807 | #include <__assert> // all public C++ headers provide the assertion handler | 942 | #include <__config> |
| 808 | #include <__chrono/calendar.h> | 943 | |
| 809 | #include <__chrono/convert_to_timespec.h> | ||
| 810 | #include <__chrono/convert_to_tm.h> | ||
| 811 | #include <__chrono/day.h> | ||
| 812 | #include <__chrono/duration.h> | 944 | #include <__chrono/duration.h> |
| 813 | #include <__chrono/file_clock.h> | 945 | #include <__chrono/file_clock.h> |
| 814 | #include <__chrono/hh_mm_ss.h> | ||
| 815 | #include <__chrono/high_resolution_clock.h> | 946 | #include <__chrono/high_resolution_clock.h> |
| 816 | #include <__chrono/literals.h> | ||
| 817 | #include <__chrono/month.h> | ||
| 818 | #include <__chrono/month_weekday.h> | ||
| 819 | #include <__chrono/monthday.h> | ||
| 820 | #include <__chrono/steady_clock.h> | 947 | #include <__chrono/steady_clock.h> |
| 821 | #include <__chrono/system_clock.h> | 948 | #include <__chrono/system_clock.h> |
| 822 | #include <__chrono/time_point.h> | 949 | #include <__chrono/time_point.h> |
| 823 | #include <__chrono/weekday.h> | 950 | |
| 824 | #include <__chrono/year.h> | 951 | #if _LIBCPP_STD_VER >= 20 |
| 825 | #include <__chrono/year_month.h> | 952 | # include <__chrono/calendar.h> |
| 826 | #include <__chrono/year_month_day.h> | 953 | # include <__chrono/day.h> |
| 827 | #include <__chrono/year_month_weekday.h> | 954 | # include <__chrono/exception.h> |
| 828 | #include <__config> | 955 | # include <__chrono/hh_mm_ss.h> |
| 956 | # include <__chrono/literals.h> | ||
| 957 | # include <__chrono/local_info.h> | ||
| 958 | # include <__chrono/month.h> | ||
| 959 | # include <__chrono/month_weekday.h> | ||
| 960 | # include <__chrono/monthday.h> | ||
| 961 | # include <__chrono/sys_info.h> | ||
| 962 | # include <__chrono/weekday.h> | ||
| 963 | # include <__chrono/year.h> | ||
| 964 | # include <__chrono/year_month.h> | ||
| 965 | # include <__chrono/year_month_day.h> | ||
| 966 | # include <__chrono/year_month_weekday.h> | ||
| 967 | |||
| 968 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 969 | # include <__chrono/formatter.h> | ||
| 970 | # include <__chrono/ostream.h> | ||
| 971 | # include <__chrono/parser_std_format_spec.h> | ||
| 972 | # include <__chrono/statically_widen.h> | ||
| 973 | # endif | ||
| 974 | |||
| 975 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 976 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 977 | # include <__chrono/leap_second.h> | ||
| 978 | # include <__chrono/time_zone.h> | ||
| 979 | # include <__chrono/time_zone_link.h> | ||
| 980 | # include <__chrono/tzdb.h> | ||
| 981 | # include <__chrono/tzdb_list.h> | ||
| 982 | # include <__chrono/zoned_time.h> | ||
| 983 | # endif | ||
| 984 | |||
| 985 | #endif | ||
| 986 | |||
| 829 | #include <version> | 987 | #include <version> |
| 830 | 988 | ||
| 831 | // standard-mandated includes | 989 | // standard-mandated includes |
| ... | @@ -833,33 +991,32 @@ constexpr chrono::year operator ""y(unsigned lo | ... | @@ -833,33 +991,32 @@ constexpr chrono::year operator ""y(unsigned lo |
| 833 | // [time.syn] | 991 | // [time.syn] |
| 834 | #include <compare> | 992 | #include <compare> |
| 835 | 993 | ||
| 836 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && _LIBCPP_STD_VER >= 20 | ||
| 837 | # include <__chrono/formatter.h> | ||
| 838 | # include <__chrono/ostream.h> | ||
| 839 | # include <__chrono/parser_std_format_spec.h> | ||
| 840 | # include <__chrono/statically_widen.h> | ||
| 841 | #endif | ||
| 842 | |||
| 843 | #if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | ||
| 844 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 845 | # include <__chrono/tzdb.h> | ||
| 846 | # include <__chrono/tzdb_list.h> | ||
| 847 | #endif | ||
| 848 | |||
| 849 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 994 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 850 | # pragma GCC system_header | 995 | # pragma GCC system_header |
| 851 | #endif | 996 | #endif |
| 852 | 997 | ||
| 998 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | ||
| 999 | # include <cstdint> | ||
| 1000 | # include <stdexcept> | ||
| 1001 | # include <string_view> | ||
| 1002 | # include <vector> | ||
| 1003 | #endif | ||
| 1004 | |||
| 853 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 1005 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 854 | # include <bit> | 1006 | # include <bit> |
| 855 | # include <concepts> | 1007 | # include <concepts> |
| 856 | # include <cstring> | 1008 | # include <cstring> |
| 857 | # include <forward_list> | 1009 | # include <forward_list> |
| 858 | # include <string> | 1010 | # include <string> |
| 1011 | # include <tuple> | ||
| 859 | #endif | 1012 | #endif |
| 860 | 1013 | ||
| 861 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 | 1014 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 |
| 862 | # include <charconv> | 1015 | # include <charconv> |
| 1016 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 1017 | # include <locale> | ||
| 1018 | # endif | ||
| 1019 | # include <ostream> | ||
| 863 | #endif | 1020 | #endif |
| 864 | 1021 | ||
| 865 | #endif // _LIBCPP_CHRONO | 1022 | #endif // _LIBCPP_CHRONO |
lib/libcxx/include/cinttypes-1| ... | @@ -234,7 +234,6 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int | ... | @@ -234,7 +234,6 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int |
| 234 | } // std | 234 | } // std |
| 235 | */ | 235 | */ |
| 236 | 236 | ||
| 237 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 238 | #include <__config> | 237 | #include <__config> |
| 239 | 238 | ||
| 240 | // standard-mandated includes | 239 | // standard-mandated includes |
lib/libcxx/include/ciso646-1| ... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
| 15 | 15 | ||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 19 | #include <__config> | 18 | #include <__config> |
| 20 | 19 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/climits-1| ... | @@ -37,7 +37,6 @@ Macros: | ... | @@ -37,7 +37,6 @@ Macros: |
| 37 | 37 | ||
| 38 | */ | 38 | */ |
| 39 | 39 | ||
| 40 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 41 | #include <__config> | 40 | #include <__config> |
| 42 | 41 | ||
| 43 | #include <limits.h> | 42 | #include <limits.h> |
lib/libcxx/include/clocale-1| ... | @@ -34,7 +34,6 @@ lconv* localeconv(); | ... | @@ -34,7 +34,6 @@ lconv* localeconv(); |
| 34 | 34 | ||
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 38 | #include <__config> | 37 | #include <__config> |
| 39 | 38 | ||
| 40 | #include <locale.h> | 39 | #include <locale.h> |
lib/libcxx/include/cmath+10-180| ... | @@ -204,6 +204,14 @@ floating_point fmin (arithmetic x, arithmetic y); | ... | @@ -204,6 +204,14 @@ floating_point fmin (arithmetic x, arithmetic y); |
| 204 | float fminf(float x, float y); | 204 | float fminf(float x, float y); |
| 205 | long double fminl(long double x, long double y); | 205 | long double fminl(long double x, long double y); |
| 206 | 206 | ||
| 207 | double hermite(unsigned n, double x); // C++17 | ||
| 208 | float hermite(unsigned n, float x); // C++17 | ||
| 209 | long double hermite(unsigned n, long double x); // C++17 | ||
| 210 | float hermitef(unsigned n, float x); // C++17 | ||
| 211 | long double hermitel(unsigned n, long double x); // C++17 | ||
| 212 | template <class Integer> | ||
| 213 | double hermite(unsigned n, Integer x); // C++17 | ||
| 214 | |||
| 207 | floating_point hypot (arithmetic x, arithmetic y); | 215 | floating_point hypot (arithmetic x, arithmetic y); |
| 208 | float hypotf(float x, float y); | 216 | float hypotf(float x, float y); |
| 209 | long double hypotl(long double x, long double y); | 217 | long double hypotl(long double x, long double y); |
| ... | @@ -304,8 +312,8 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept | ... | @@ -304,8 +312,8 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept |
| 304 | 312 | ||
| 305 | */ | 313 | */ |
| 306 | 314 | ||
| 307 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 308 | #include <__config> | 315 | #include <__config> |
| 316 | #include <__math/hypot.h> | ||
| 309 | #include <__type_traits/enable_if.h> | 317 | #include <__type_traits/enable_if.h> |
| 310 | #include <__type_traits/is_arithmetic.h> | 318 | #include <__type_traits/is_arithmetic.h> |
| 311 | #include <__type_traits/is_constant_evaluated.h> | 319 | #include <__type_traits/is_constant_evaluated.h> |
| ... | @@ -316,6 +324,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept | ... | @@ -316,6 +324,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept |
| 316 | #include <limits> | 324 | #include <limits> |
| 317 | #include <version> | 325 | #include <version> |
| 318 | 326 | ||
| 327 | #include <__math/special_functions.h> | ||
| 319 | #include <math.h> | 328 | #include <math.h> |
| 320 | 329 | ||
| 321 | #ifndef _LIBCPP_MATH_H | 330 | #ifndef _LIBCPP_MATH_H |
| ... | @@ -545,30 +554,6 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS; | ... | @@ -545,30 +554,6 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS; |
| 545 | using ::tgammal _LIBCPP_USING_IF_EXISTS; | 554 | using ::tgammal _LIBCPP_USING_IF_EXISTS; |
| 546 | using ::truncl _LIBCPP_USING_IF_EXISTS; | 555 | using ::truncl _LIBCPP_USING_IF_EXISTS; |
| 547 | 556 | ||
| 548 | #if _LIBCPP_STD_VER >= 17 | ||
| 549 | inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { | ||
| 550 | return sqrt(__x * __x + __y * __y + __z * __z); | ||
| 551 | } | ||
| 552 | inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { | ||
| 553 | return sqrt(__x * __x + __y * __y + __z * __z); | ||
| 554 | } | ||
| 555 | inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) { | ||
| 556 | return sqrt(__x * __x + __y * __y + __z * __z); | ||
| 557 | } | ||
| 558 | |||
| 559 | template <class _A1, class _A2, class _A3> | ||
| 560 | inline _LIBCPP_HIDE_FROM_ABI | ||
| 561 | typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, | ||
| 562 | __promote<_A1, _A2, _A3> >::type | ||
| 563 | hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT { | ||
| 564 | typedef typename __promote<_A1, _A2, _A3>::type __result_type; | ||
| 565 | static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value && | ||
| 566 | is_same<_A3, __result_type>::value)), | ||
| 567 | ""); | ||
| 568 | return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); | ||
| 569 | } | ||
| 570 | #endif | ||
| 571 | |||
| 572 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | 557 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> |
| 573 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { | 558 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { |
| 574 | #if __has_builtin(__builtin_isnan) | 559 | #if __has_builtin(__builtin_isnan) |
| ... | @@ -611,161 +596,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) | ... | @@ -611,161 +596,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) |
| 611 | return __builtin_isfinite(__lcpp_x); | 596 | return __builtin_isfinite(__lcpp_x); |
| 612 | } | 597 | } |
| 613 | 598 | ||
| 614 | _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI float __constexpr_copysign(float __x, float __y) _NOEXCEPT { | ||
| 615 | return __builtin_copysignf(__x, __y); | ||
| 616 | } | ||
| 617 | |||
| 618 | _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI double __constexpr_copysign(double __x, double __y) _NOEXCEPT { | ||
| 619 | return __builtin_copysign(__x, __y); | ||
| 620 | } | ||
| 621 | |||
| 622 | _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI long double | ||
| 623 | __constexpr_copysign(long double __x, long double __y) _NOEXCEPT { | ||
| 624 | return __builtin_copysignl(__x, __y); | ||
| 625 | } | ||
| 626 | |||
| 627 | template <class _A1, | ||
| 628 | class _A2, | ||
| 629 | __enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> | ||
| 630 | _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type | ||
| 631 | __constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT { | ||
| 632 | typedef typename std::__promote<_A1, _A2>::type __result_type; | ||
| 633 | static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), ""); | ||
| 634 | return __builtin_copysign((__result_type)__x, (__result_type)__y); | ||
| 635 | } | ||
| 636 | |||
| 637 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float __constexpr_fabs(float __x) _NOEXCEPT { | ||
| 638 | return __builtin_fabsf(__x); | ||
| 639 | } | ||
| 640 | |||
| 641 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(double __x) _NOEXCEPT { | ||
| 642 | return __builtin_fabs(__x); | ||
| 643 | } | ||
| 644 | |||
| 645 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double __constexpr_fabs(long double __x) _NOEXCEPT { | ||
| 646 | return __builtin_fabsl(__x); | ||
| 647 | } | ||
| 648 | |||
| 649 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> | ||
| 650 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(_Tp __x) _NOEXCEPT { | ||
| 651 | return __builtin_fabs(static_cast<double>(__x)); | ||
| 652 | } | ||
| 653 | |||
| 654 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 float __constexpr_fmax(float __x, float __y) _NOEXCEPT { | ||
| 655 | #if !__has_constexpr_builtin(__builtin_fmaxf) | ||
| 656 | if (__libcpp_is_constant_evaluated()) { | ||
| 657 | if (std::__constexpr_isnan(__x)) | ||
| 658 | return __y; | ||
| 659 | if (std::__constexpr_isnan(__y)) | ||
| 660 | return __x; | ||
| 661 | return __x < __y ? __y : __x; | ||
| 662 | } | ||
| 663 | #endif | ||
| 664 | return __builtin_fmaxf(__x, __y); | ||
| 665 | } | ||
| 666 | |||
| 667 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 double __constexpr_fmax(double __x, double __y) _NOEXCEPT { | ||
| 668 | #if !__has_constexpr_builtin(__builtin_fmax) | ||
| 669 | if (__libcpp_is_constant_evaluated()) { | ||
| 670 | if (std::__constexpr_isnan(__x)) | ||
| 671 | return __y; | ||
| 672 | if (std::__constexpr_isnan(__y)) | ||
| 673 | return __x; | ||
| 674 | return __x < __y ? __y : __x; | ||
| 675 | } | ||
| 676 | #endif | ||
| 677 | return __builtin_fmax(__x, __y); | ||
| 678 | } | ||
| 679 | |||
| 680 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 long double | ||
| 681 | __constexpr_fmax(long double __x, long double __y) _NOEXCEPT { | ||
| 682 | #if !__has_constexpr_builtin(__builtin_fmaxl) | ||
| 683 | if (__libcpp_is_constant_evaluated()) { | ||
| 684 | if (std::__constexpr_isnan(__x)) | ||
| 685 | return __y; | ||
| 686 | if (std::__constexpr_isnan(__y)) | ||
| 687 | return __x; | ||
| 688 | return __x < __y ? __y : __x; | ||
| 689 | } | ||
| 690 | #endif | ||
| 691 | return __builtin_fmaxl(__x, __y); | ||
| 692 | } | ||
| 693 | |||
| 694 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_arithmetic<_Up>::value, int> = 0> | ||
| 695 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __promote<_Tp, _Up>::type | ||
| 696 | __constexpr_fmax(_Tp __x, _Up __y) _NOEXCEPT { | ||
| 697 | using __result_type = typename __promote<_Tp, _Up>::type; | ||
| 698 | return std::__constexpr_fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); | ||
| 699 | } | ||
| 700 | |||
| 701 | template <class _Tp> | ||
| 702 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __constexpr_logb(_Tp __x) { | ||
| 703 | #if !__has_constexpr_builtin(__builtin_logb) | ||
| 704 | if (__libcpp_is_constant_evaluated()) { | ||
| 705 | if (__x == _Tp(0)) { | ||
| 706 | // raise FE_DIVBYZERO | ||
| 707 | return -numeric_limits<_Tp>::infinity(); | ||
| 708 | } | ||
| 709 | |||
| 710 | if (std::__constexpr_isinf(__x)) | ||
| 711 | return numeric_limits<_Tp>::infinity(); | ||
| 712 | |||
| 713 | if (std::__constexpr_isnan(__x)) | ||
| 714 | return numeric_limits<_Tp>::quiet_NaN(); | ||
| 715 | |||
| 716 | __x = std::__constexpr_fabs(__x); | ||
| 717 | unsigned long long __exp = 0; | ||
| 718 | while (__x >= numeric_limits<_Tp>::radix) { | ||
| 719 | __x /= numeric_limits<_Tp>::radix; | ||
| 720 | __exp += 1; | ||
| 721 | } | ||
| 722 | return _Tp(__exp); | ||
| 723 | } | ||
| 724 | #endif // !__has_constexpr_builtin(__builtin_logb) | ||
| 725 | return __builtin_logb(__x); | ||
| 726 | } | ||
| 727 | |||
| 728 | template <class _Tp> | ||
| 729 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp __constexpr_scalbn(_Tp __x, int __exp) { | ||
| 730 | #if !__has_constexpr_builtin(__builtin_scalbln) | ||
| 731 | if (__libcpp_is_constant_evaluated()) { | ||
| 732 | if (__x == _Tp(0)) | ||
| 733 | return __x; | ||
| 734 | |||
| 735 | if (std::__constexpr_isinf(__x)) | ||
| 736 | return __x; | ||
| 737 | |||
| 738 | if (__exp == _Tp(0)) | ||
| 739 | return __x; | ||
| 740 | |||
| 741 | if (std::__constexpr_isnan(__x)) | ||
| 742 | return numeric_limits<_Tp>::quiet_NaN(); | ||
| 743 | |||
| 744 | _Tp __mult(1); | ||
| 745 | if (__exp > 0) { | ||
| 746 | __mult = numeric_limits<_Tp>::radix; | ||
| 747 | --__exp; | ||
| 748 | } else { | ||
| 749 | ++__exp; | ||
| 750 | __exp = -__exp; | ||
| 751 | __mult /= numeric_limits<_Tp>::radix; | ||
| 752 | } | ||
| 753 | |||
| 754 | while (__exp > 0) { | ||
| 755 | if (!(__exp & 1)) { | ||
| 756 | __mult *= __mult; | ||
| 757 | __exp >>= 1; | ||
| 758 | } else { | ||
| 759 | __x *= __mult; | ||
| 760 | --__exp; | ||
| 761 | } | ||
| 762 | } | ||
| 763 | return __x; | ||
| 764 | } | ||
| 765 | #endif // !__has_constexpr_builtin(__builtin_scalbln) | ||
| 766 | return __builtin_scalbn(__x, __exp); | ||
| 767 | } | ||
| 768 | |||
| 769 | #if _LIBCPP_STD_VER >= 20 | 599 | #if _LIBCPP_STD_VER >= 20 |
| 770 | template <typename _Fp> | 600 | template <typename _Fp> |
| 771 | _LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept { | 601 | _LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept { |
lib/libcxx/include/codecvt+2-3| ... | @@ -54,7 +54,6 @@ class codecvt_utf8_utf16 | ... | @@ -54,7 +54,6 @@ class codecvt_utf8_utf16 |
| 54 | 54 | ||
| 55 | */ | 55 | */ |
| 56 | 56 | ||
| 57 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 58 | #include <__config> | 57 | #include <__config> |
| 59 | #include <__locale> | 58 | #include <__locale> |
| 60 | #include <version> | 59 | #include <version> |
| ... | @@ -434,8 +433,8 @@ protected: | ... | @@ -434,8 +433,8 @@ protected: |
| 434 | 433 | ||
| 435 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 434 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 436 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> | 435 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> |
| 437 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 | 436 | class _LIBCPP_TEMPLATE_VIS |
| 438 | : public __codecvt_utf16<_Elem, _Mode & little_endian> { | 437 | _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { |
| 439 | public: | 438 | public: |
| 440 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0) | 439 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0) |
| 441 | : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} | 440 | : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} |
lib/libcxx/include/compare+24-14| ... | @@ -140,28 +140,38 @@ namespace std { | ... | @@ -140,28 +140,38 @@ namespace std { |
| 140 | } | 140 | } |
| 141 | */ | 141 | */ |
| 142 | 142 | ||
| 143 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 144 | #include <__compare/common_comparison_category.h> | ||
| 145 | #include <__compare/compare_partial_order_fallback.h> | ||
| 146 | #include <__compare/compare_strong_order_fallback.h> | ||
| 147 | #include <__compare/compare_three_way.h> | ||
| 148 | #include <__compare/compare_three_way_result.h> | ||
| 149 | #include <__compare/compare_weak_order_fallback.h> | ||
| 150 | #include <__compare/is_eq.h> | ||
| 151 | #include <__compare/ordering.h> | ||
| 152 | #include <__compare/partial_order.h> | ||
| 153 | #include <__compare/strong_order.h> | ||
| 154 | #include <__compare/synth_three_way.h> | ||
| 155 | #include <__compare/three_way_comparable.h> | ||
| 156 | #include <__compare/weak_order.h> | ||
| 157 | #include <__config> | 143 | #include <__config> |
| 144 | |||
| 145 | #if _LIBCPP_STD_VER >= 20 | ||
| 146 | # include <__compare/common_comparison_category.h> | ||
| 147 | # include <__compare/compare_partial_order_fallback.h> | ||
| 148 | # include <__compare/compare_strong_order_fallback.h> | ||
| 149 | # include <__compare/compare_three_way.h> | ||
| 150 | # include <__compare/compare_three_way_result.h> | ||
| 151 | # include <__compare/compare_weak_order_fallback.h> | ||
| 152 | # include <__compare/is_eq.h> | ||
| 153 | # include <__compare/ordering.h> | ||
| 154 | # include <__compare/partial_order.h> | ||
| 155 | # include <__compare/strong_order.h> | ||
| 156 | # include <__compare/synth_three_way.h> | ||
| 157 | # include <__compare/three_way_comparable.h> | ||
| 158 | # include <__compare/weak_order.h> | ||
| 159 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 160 | |||
| 158 | #include <version> | 161 | #include <version> |
| 159 | 162 | ||
| 160 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 163 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 161 | # pragma GCC system_header | 164 | # pragma GCC system_header |
| 162 | #endif | 165 | #endif |
| 163 | 166 | ||
| 167 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | ||
| 168 | # include <cstddef> | ||
| 169 | # include <cstdint> | ||
| 170 | # include <limits> | ||
| 171 | #endif | ||
| 172 | |||
| 164 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 173 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 174 | # include <cmath> | ||
| 165 | # include <type_traits> | 175 | # include <type_traits> |
| 166 | #endif | 176 | #endif |
| 167 | 177 |
lib/libcxx/include/complex+234-146| ... | @@ -227,12 +227,42 @@ template<class T> complex<T> sqrt (const complex<T>&); | ... | @@ -227,12 +227,42 @@ template<class T> complex<T> sqrt (const complex<T>&); |
| 227 | template<class T> complex<T> tan (const complex<T>&); | 227 | template<class T> complex<T> tan (const complex<T>&); |
| 228 | template<class T> complex<T> tanh (const complex<T>&); | 228 | template<class T> complex<T> tanh (const complex<T>&); |
| 229 | 229 | ||
| 230 | // [complex.tuple], tuple interface | ||
| 231 | template<class T> struct tuple_size; // Since C++26 | ||
| 232 | template<size_t I, class T> struct tuple_element; // Since C++26 | ||
| 233 | template<class T> struct tuple_size<complex<T>>; // Since C++26 | ||
| 234 | template<size_t I, class T> struct tuple_element<I, complex<T>>; // Since C++26 | ||
| 235 | template<size_t I, class T> | ||
| 236 | constexpr T& get(complex<T>&) noexcept; // Since C++26 | ||
| 237 | template<size_t I, class T> | ||
| 238 | constexpr T&& get(complex<T>&&) noexcept; // Since C++26 | ||
| 239 | template<size_t I, class T> | ||
| 240 | constexpr const T& get(const complex<T>&) noexcept; // Since C++26 | ||
| 241 | template<size_t I, class T> | ||
| 242 | constexpr const T&& get(const complex<T>&&) noexcept; // Since C++26 | ||
| 243 | |||
| 244 | // [complex.literals], complex literals | ||
| 245 | inline namespace literals { | ||
| 246 | inline namespace complex_literals { | ||
| 247 | constexpr complex<long double> operator""il(long double); // Since C++14 | ||
| 248 | constexpr complex<long double> operator""il(unsigned long long); // Since C++14 | ||
| 249 | constexpr complex<double> operator""i(long double); // Since C++14 | ||
| 250 | constexpr complex<double> operator""i(unsigned long long); // Since C++14 | ||
| 251 | constexpr complex<float> operator""if(long double); // Since C++14 | ||
| 252 | constexpr complex<float> operator""if(unsigned long long); // Since C++14 | ||
| 253 | } | ||
| 254 | } | ||
| 230 | } // std | 255 | } // std |
| 231 | 256 | ||
| 232 | */ | 257 | */ |
| 233 | 258 | ||
| 234 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 235 | #include <__config> | 259 | #include <__config> |
| 260 | #include <__fwd/complex.h> | ||
| 261 | #include <__fwd/tuple.h> | ||
| 262 | #include <__tuple/tuple_element.h> | ||
| 263 | #include <__tuple/tuple_size.h> | ||
| 264 | #include <__type_traits/conditional.h> | ||
| 265 | #include <__utility/move.h> | ||
| 236 | #include <cmath> | 266 | #include <cmath> |
| 237 | #include <version> | 267 | #include <version> |
| 238 | 268 | ||
| ... | @@ -244,15 +274,27 @@ template<class T> complex<T> tanh (const complex<T>&); | ... | @@ -244,15 +274,27 @@ template<class T> complex<T> tanh (const complex<T>&); |
| 244 | # pragma GCC system_header | 274 | # pragma GCC system_header |
| 245 | #endif | 275 | #endif |
| 246 | 276 | ||
| 277 | _LIBCPP_PUSH_MACROS | ||
| 278 | #include <__undef_macros> | ||
| 279 | |||
| 247 | _LIBCPP_BEGIN_NAMESPACE_STD | 280 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 248 | 281 | ||
| 249 | template <class _Tp> | 282 | template <class _Tp> |
| 250 | class _LIBCPP_TEMPLATE_VIS complex; | 283 | class _LIBCPP_TEMPLATE_VIS complex; |
| 251 | 284 | ||
| 252 | template <class _Tp> | 285 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> |
| 253 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 286 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 254 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); | 287 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); |
| 255 | template <class _Tp> | 288 | |
| 289 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0> | ||
| 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | ||
| 291 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); | ||
| 292 | |||
| 293 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> | ||
| 294 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | ||
| 295 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); | ||
| 296 | |||
| 297 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0> | ||
| 256 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 257 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); | 299 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); |
| 258 | 300 | ||
| ... | @@ -331,6 +373,20 @@ public: | ... | @@ -331,6 +373,20 @@ public: |
| 331 | *this = *this / complex(__c.real(), __c.imag()); | 373 | *this = *this / complex(__c.real(), __c.imag()); |
| 332 | return *this; | 374 | return *this; |
| 333 | } | 375 | } |
| 376 | |||
| 377 | #if _LIBCPP_STD_VER >= 26 | ||
| 378 | template <size_t _Ip, class _Xp> | ||
| 379 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; | ||
| 380 | |||
| 381 | template <size_t _Ip, class _Xp> | ||
| 382 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept; | ||
| 383 | |||
| 384 | template <size_t _Ip, class _Xp> | ||
| 385 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept; | ||
| 386 | |||
| 387 | template <size_t _Ip, class _Xp> | ||
| 388 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; | ||
| 389 | #endif | ||
| 334 | }; | 390 | }; |
| 335 | 391 | ||
| 336 | template <> | 392 | template <> |
| ... | @@ -338,6 +394,23 @@ class _LIBCPP_TEMPLATE_VIS complex<double>; | ... | @@ -338,6 +394,23 @@ class _LIBCPP_TEMPLATE_VIS complex<double>; |
| 338 | template <> | 394 | template <> |
| 339 | class _LIBCPP_TEMPLATE_VIS complex<long double>; | 395 | class _LIBCPP_TEMPLATE_VIS complex<long double>; |
| 340 | 396 | ||
| 397 | struct __from_builtin_tag {}; | ||
| 398 | |||
| 399 | template <class _Tp> | ||
| 400 | using __complex_t = | ||
| 401 | __conditional_t<is_same<_Tp, float>::value, | ||
| 402 | _Complex float, | ||
| 403 | __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >; | ||
| 404 | |||
| 405 | template <class _Tp> | ||
| 406 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) { | ||
| 407 | #if __has_builtin(__builtin_complex) | ||
| 408 | return __builtin_complex(__re, __im); | ||
| 409 | #else | ||
| 410 | return __complex_t<_Tp>{__re, __im}; | ||
| 411 | #endif | ||
| 412 | } | ||
| 413 | |||
| 341 | template <> | 414 | template <> |
| 342 | class _LIBCPP_TEMPLATE_VIS complex<float> { | 415 | class _LIBCPP_TEMPLATE_VIS complex<float> { |
| 343 | float __re_; | 416 | float __re_; |
| ... | @@ -347,6 +420,11 @@ public: | ... | @@ -347,6 +420,11 @@ public: |
| 347 | typedef float value_type; | 420 | typedef float value_type; |
| 348 | 421 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {} | 422 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {} |
| 423 | |||
| 424 | template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> | ||
| 425 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex float __v) | ||
| 426 | : __re_(__real__ __v), __im_(__imag__ __v) {} | ||
| 427 | |||
| 350 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c); | 428 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c); |
| 351 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); | 429 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); |
| 352 | 430 | ||
| ... | @@ -356,6 +434,12 @@ public: | ... | @@ -356,6 +434,12 @@ public: |
| 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 434 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 357 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 435 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| 358 | 436 | ||
| 437 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex float __builtin() const { return std::__make_complex(__re_, __im_); } | ||
| 438 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex float __f) { | ||
| 439 | __re_ = __real__ __f; | ||
| 440 | __im_ = __imag__ __f; | ||
| 441 | } | ||
| 442 | |||
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(float __re) { | 443 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(float __re) { |
| 360 | __re_ = __re; | 444 | __re_ = __re; |
| 361 | __im_ = value_type(); | 445 | __im_ = value_type(); |
| ... | @@ -408,6 +492,20 @@ public: | ... | @@ -408,6 +492,20 @@ public: |
| 408 | *this = *this / complex(__c.real(), __c.imag()); | 492 | *this = *this / complex(__c.real(), __c.imag()); |
| 409 | return *this; | 493 | return *this; |
| 410 | } | 494 | } |
| 495 | |||
| 496 | #if _LIBCPP_STD_VER >= 26 | ||
| 497 | template <size_t _Ip, class _Xp> | ||
| 498 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; | ||
| 499 | |||
| 500 | template <size_t _Ip, class _Xp> | ||
| 501 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept; | ||
| 502 | |||
| 503 | template <size_t _Ip, class _Xp> | ||
| 504 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept; | ||
| 505 | |||
| 506 | template <size_t _Ip, class _Xp> | ||
| 507 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; | ||
| 508 | #endif | ||
| 411 | }; | 509 | }; |
| 412 | 510 | ||
| 413 | template <> | 511 | template <> |
| ... | @@ -419,6 +517,11 @@ public: | ... | @@ -419,6 +517,11 @@ public: |
| 419 | typedef double value_type; | 517 | typedef double value_type; |
| 420 | 518 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {} | 519 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {} |
| 520 | |||
| 521 | template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> | ||
| 522 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex double __v) | ||
| 523 | : __re_(__real__ __v), __im_(__imag__ __v) {} | ||
| 524 | |||
| 422 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); | 525 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); |
| 423 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); | 526 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); |
| 424 | 527 | ||
| ... | @@ -428,6 +531,15 @@ public: | ... | @@ -428,6 +531,15 @@ public: |
| 428 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 531 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 429 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 532 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| 430 | 533 | ||
| 534 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex double __builtin() const { | ||
| 535 | return std::__make_complex(__re_, __im_); | ||
| 536 | } | ||
| 537 | |||
| 538 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex double __f) { | ||
| 539 | __re_ = __real__ __f; | ||
| 540 | __im_ = __imag__ __f; | ||
| 541 | } | ||
| 542 | |||
| 431 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(double __re) { | 543 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(double __re) { |
| 432 | __re_ = __re; | 544 | __re_ = __re; |
| 433 | __im_ = value_type(); | 545 | __im_ = value_type(); |
| ... | @@ -480,6 +592,20 @@ public: | ... | @@ -480,6 +592,20 @@ public: |
| 480 | *this = *this / complex(__c.real(), __c.imag()); | 592 | *this = *this / complex(__c.real(), __c.imag()); |
| 481 | return *this; | 593 | return *this; |
| 482 | } | 594 | } |
| 595 | |||
| 596 | #if _LIBCPP_STD_VER >= 26 | ||
| 597 | template <size_t _Ip, class _Xp> | ||
| 598 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; | ||
| 599 | |||
| 600 | template <size_t _Ip, class _Xp> | ||
| 601 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept; | ||
| 602 | |||
| 603 | template <size_t _Ip, class _Xp> | ||
| 604 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept; | ||
| 605 | |||
| 606 | template <size_t _Ip, class _Xp> | ||
| 607 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; | ||
| 608 | #endif | ||
| 483 | }; | 609 | }; |
| 484 | 610 | ||
| 485 | template <> | 611 | template <> |
| ... | @@ -492,6 +618,11 @@ public: | ... | @@ -492,6 +618,11 @@ public: |
| 492 | 618 | ||
| 493 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L) | 619 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L) |
| 494 | : __re_(__re), __im_(__im) {} | 620 | : __re_(__re), __im_(__im) {} |
| 621 | |||
| 622 | template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> | ||
| 623 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex long double __v) | ||
| 624 | : __re_(__real__ __v), __im_(__imag__ __v) {} | ||
| 625 | |||
| 495 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); | 626 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); |
| 496 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<double>& __c); | 627 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<double>& __c); |
| 497 | 628 | ||
| ... | @@ -501,6 +632,15 @@ public: | ... | @@ -501,6 +632,15 @@ public: |
| 501 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 632 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 502 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 633 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| 503 | 634 | ||
| 635 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex long double __builtin() const { | ||
| 636 | return std::__make_complex(__re_, __im_); | ||
| 637 | } | ||
| 638 | |||
| 639 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex long double __f) { | ||
| 640 | __re_ = __real__ __f; | ||
| 641 | __im_ = __imag__ __f; | ||
| 642 | } | ||
| 643 | |||
| 504 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(long double __re) { | 644 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(long double __re) { |
| 505 | __re_ = __re; | 645 | __re_ = __re; |
| 506 | __im_ = value_type(); | 646 | __im_ = value_type(); |
| ... | @@ -553,6 +693,20 @@ public: | ... | @@ -553,6 +693,20 @@ public: |
| 553 | *this = *this / complex(__c.real(), __c.imag()); | 693 | *this = *this / complex(__c.real(), __c.imag()); |
| 554 | return *this; | 694 | return *this; |
| 555 | } | 695 | } |
| 696 | |||
| 697 | #if _LIBCPP_STD_VER >= 26 | ||
| 698 | template <size_t _Ip, class _Xp> | ||
| 699 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; | ||
| 700 | |||
| 701 | template <size_t _Ip, class _Xp> | ||
| 702 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept; | ||
| 703 | |||
| 704 | template <size_t _Ip, class _Xp> | ||
| 705 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept; | ||
| 706 | |||
| 707 | template <size_t _Ip, class _Xp> | ||
| 708 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; | ||
| 709 | #endif | ||
| 556 | }; | 710 | }; |
| 557 | 711 | ||
| 558 | inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} | 712 | inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} |
| ... | @@ -621,7 +775,13 @@ operator-(const _Tp& __x, const complex<_Tp>& __y) { | ... | @@ -621,7 +775,13 @@ operator-(const _Tp& __x, const complex<_Tp>& __y) { |
| 621 | return __t; | 775 | return __t; |
| 622 | } | 776 | } |
| 623 | 777 | ||
| 624 | template <class _Tp> | 778 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > |
| 779 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | ||
| 780 | operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { | ||
| 781 | return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() * __rhs.__builtin()); | ||
| 782 | } | ||
| 783 | |||
| 784 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > | ||
| 625 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 785 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 626 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { | 786 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 627 | _Tp __a = __z.real(); | 787 | _Tp __a = __z.real(); |
| ... | @@ -629,78 +789,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { | ... | @@ -629,78 +789,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 629 | _Tp __c = __w.real(); | 789 | _Tp __c = __w.real(); |
| 630 | _Tp __d = __w.imag(); | 790 | _Tp __d = __w.imag(); |
| 631 | 791 | ||
| 632 | // Avoid floating point operations that are invalid during constant evaluation | 792 | return complex<_Tp>((__a * __c) - (__b * __d), (__a * __d) + (__b * __c)); |
| 633 | if (__libcpp_is_constant_evaluated()) { | ||
| 634 | bool __z_zero = __a == _Tp(0) && __b == _Tp(0); | ||
| 635 | bool __w_zero = __c == _Tp(0) && __d == _Tp(0); | ||
| 636 | bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b); | ||
| 637 | bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d); | ||
| 638 | bool __z_nan = | ||
| 639 | !__z_inf && ((std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b)) || | ||
| 640 | (std::__constexpr_isnan(__a) && __b == _Tp(0)) || (__a == _Tp(0) && std::__constexpr_isnan(__b))); | ||
| 641 | bool __w_nan = | ||
| 642 | !__w_inf && ((std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d)) || | ||
| 643 | (std::__constexpr_isnan(__c) && __d == _Tp(0)) || (__c == _Tp(0) && std::__constexpr_isnan(__d))); | ||
| 644 | if (__z_nan || __w_nan) { | ||
| 645 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0)); | ||
| 646 | } | ||
| 647 | if (__z_inf || __w_inf) { | ||
| 648 | if (__z_zero || __w_zero) { | ||
| 649 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0)); | ||
| 650 | } | ||
| 651 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity())); | ||
| 652 | } | ||
| 653 | bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b)); | ||
| 654 | bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d)); | ||
| 655 | if (__z_nonzero_nan || __w_nonzero_nan) { | ||
| 656 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0)); | ||
| 657 | } | ||
| 658 | } | ||
| 659 | |||
| 660 | _Tp __ac = __a * __c; | ||
| 661 | _Tp __bd = __b * __d; | ||
| 662 | _Tp __ad = __a * __d; | ||
| 663 | _Tp __bc = __b * __c; | ||
| 664 | _Tp __x = __ac - __bd; | ||
| 665 | _Tp __y = __ad + __bc; | ||
| 666 | if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y)) { | ||
| 667 | bool __recalc = false; | ||
| 668 | if (std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) { | ||
| 669 | __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a); | ||
| 670 | __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b); | ||
| 671 | if (std::__constexpr_isnan(__c)) | ||
| 672 | __c = std::__constexpr_copysign(_Tp(0), __c); | ||
| 673 | if (std::__constexpr_isnan(__d)) | ||
| 674 | __d = std::__constexpr_copysign(_Tp(0), __d); | ||
| 675 | __recalc = true; | ||
| 676 | } | ||
| 677 | if (std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d)) { | ||
| 678 | __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c); | ||
| 679 | __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d); | ||
| 680 | if (std::__constexpr_isnan(__a)) | ||
| 681 | __a = std::__constexpr_copysign(_Tp(0), __a); | ||
| 682 | if (std::__constexpr_isnan(__b)) | ||
| 683 | __b = std::__constexpr_copysign(_Tp(0), __b); | ||
| 684 | __recalc = true; | ||
| 685 | } | ||
| 686 | if (!__recalc && (std::__constexpr_isinf(__ac) || std::__constexpr_isinf(__bd) || std::__constexpr_isinf(__ad) || | ||
| 687 | std::__constexpr_isinf(__bc))) { | ||
| 688 | if (std::__constexpr_isnan(__a)) | ||
| 689 | __a = std::__constexpr_copysign(_Tp(0), __a); | ||
| 690 | if (std::__constexpr_isnan(__b)) | ||
| 691 | __b = std::__constexpr_copysign(_Tp(0), __b); | ||
| 692 | if (std::__constexpr_isnan(__c)) | ||
| 693 | __c = std::__constexpr_copysign(_Tp(0), __c); | ||
| 694 | if (std::__constexpr_isnan(__d)) | ||
| 695 | __d = std::__constexpr_copysign(_Tp(0), __d); | ||
| 696 | __recalc = true; | ||
| 697 | } | ||
| 698 | if (__recalc) { | ||
| 699 | __x = _Tp(INFINITY) * (__a * __c - __b * __d); | ||
| 700 | __y = _Tp(INFINITY) * (__a * __d + __b * __c); | ||
| 701 | } | ||
| 702 | } | ||
| 703 | return complex<_Tp>(__x, __y); | ||
| 704 | } | 793 | } |
| 705 | 794 | ||
| 706 | template <class _Tp> | 795 | template <class _Tp> |
| ... | @@ -719,80 +808,22 @@ operator*(const _Tp& __x, const complex<_Tp>& __y) { | ... | @@ -719,80 +808,22 @@ operator*(const _Tp& __x, const complex<_Tp>& __y) { |
| 719 | return __t; | 808 | return __t; |
| 720 | } | 809 | } |
| 721 | 810 | ||
| 722 | template <class _Tp> | 811 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > |
| 812 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | ||
| 813 | operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { | ||
| 814 | return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() / __rhs.__builtin()); | ||
| 815 | } | ||
| 816 | |||
| 817 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > | ||
| 723 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 818 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 724 | operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { | 819 | operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 725 | int __ilogbw = 0; | 820 | _Tp __a = __z.real(); |
| 726 | _Tp __a = __z.real(); | 821 | _Tp __b = __z.imag(); |
| 727 | _Tp __b = __z.imag(); | 822 | _Tp __c = __w.real(); |
| 728 | _Tp __c = __w.real(); | 823 | _Tp __d = __w.imag(); |
| 729 | _Tp __d = __w.imag(); | ||
| 730 | _Tp __logbw = std::__constexpr_logb(std::__constexpr_fmax(std::__constexpr_fabs(__c), std::__constexpr_fabs(__d))); | ||
| 731 | if (std::__constexpr_isfinite(__logbw)) { | ||
| 732 | __ilogbw = static_cast<int>(__logbw); | ||
| 733 | __c = std::__constexpr_scalbn(__c, -__ilogbw); | ||
| 734 | __d = std::__constexpr_scalbn(__d, -__ilogbw); | ||
| 735 | } | ||
| 736 | |||
| 737 | // Avoid floating point operations that are invalid during constant evaluation | ||
| 738 | if (__libcpp_is_constant_evaluated()) { | ||
| 739 | bool __z_zero = __a == _Tp(0) && __b == _Tp(0); | ||
| 740 | bool __w_zero = __c == _Tp(0) && __d == _Tp(0); | ||
| 741 | bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b); | ||
| 742 | bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d); | ||
| 743 | bool __z_nan = | ||
| 744 | !__z_inf && ((std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b)) || | ||
| 745 | (std::__constexpr_isnan(__a) && __b == _Tp(0)) || (__a == _Tp(0) && std::__constexpr_isnan(__b))); | ||
| 746 | bool __w_nan = | ||
| 747 | !__w_inf && ((std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d)) || | ||
| 748 | (std::__constexpr_isnan(__c) && __d == _Tp(0)) || (__c == _Tp(0) && std::__constexpr_isnan(__d))); | ||
| 749 | if ((__z_nan || __w_nan) || (__z_inf && __w_inf)) { | ||
| 750 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0)); | ||
| 751 | } | ||
| 752 | bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b)); | ||
| 753 | bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d)); | ||
| 754 | if (__z_nonzero_nan || __w_nonzero_nan) { | ||
| 755 | if (__w_zero) { | ||
| 756 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity())); | ||
| 757 | } | ||
| 758 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0)); | ||
| 759 | } | ||
| 760 | if (__w_inf) { | ||
| 761 | return complex<_Tp>(_Tp(0), _Tp(0)); | ||
| 762 | } | ||
| 763 | if (__z_inf) { | ||
| 764 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity())); | ||
| 765 | } | ||
| 766 | if (__w_zero) { | ||
| 767 | if (__z_zero) { | ||
| 768 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0)); | ||
| 769 | } | ||
| 770 | return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity())); | ||
| 771 | } | ||
| 772 | } | ||
| 773 | 824 | ||
| 774 | _Tp __denom = __c * __c + __d * __d; | 825 | _Tp __denom = __c * __c + __d * __d; |
| 775 | _Tp __x = std::__constexpr_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw); | 826 | return complex<_Tp>((__a * __c + __b * __d) / __denom, (__b * __c - __a * __d) / __denom); |
| 776 | _Tp __y = std::__constexpr_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw); | ||
| 777 | if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y)) { | ||
| 778 | if ((__denom == _Tp(0)) && (!std::__constexpr_isnan(__a) || !std::__constexpr_isnan(__b))) { | ||
| 779 | __x = std::__constexpr_copysign(_Tp(INFINITY), __c) * __a; | ||
| 780 | __y = std::__constexpr_copysign(_Tp(INFINITY), __c) * __b; | ||
| 781 | } else if ((std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) && std::__constexpr_isfinite(__c) && | ||
| 782 | std::__constexpr_isfinite(__d)) { | ||
| 783 | __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a); | ||
| 784 | __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b); | ||
| 785 | __x = _Tp(INFINITY) * (__a * __c + __b * __d); | ||
| 786 | __y = _Tp(INFINITY) * (__b * __c - __a * __d); | ||
| 787 | } else if (std::__constexpr_isinf(__logbw) && __logbw > _Tp(0) && std::__constexpr_isfinite(__a) && | ||
| 788 | std::__constexpr_isfinite(__b)) { | ||
| 789 | __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c); | ||
| 790 | __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d); | ||
| 791 | __x = _Tp(0) * (__a * __c + __b * __d); | ||
| 792 | __y = _Tp(0) * (__b * __c - __a * __d); | ||
| 793 | } | ||
| 794 | } | ||
| 795 | return complex<_Tp>(__x, __y); | ||
| 796 | } | 827 | } |
| 797 | 828 | ||
| 798 | template <class _Tp> | 829 | template <class _Tp> |
| ... | @@ -1352,6 +1383,61 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { | ... | @@ -1352,6 +1383,61 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { |
| 1352 | } | 1383 | } |
| 1353 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION | 1384 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION |
| 1354 | 1385 | ||
| 1386 | #if _LIBCPP_STD_VER >= 26 | ||
| 1387 | |||
| 1388 | // [complex.tuple], tuple interface | ||
| 1389 | |||
| 1390 | template <class _Tp> | ||
| 1391 | struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {}; | ||
| 1392 | |||
| 1393 | template <size_t _Ip, class _Tp> | ||
| 1394 | struct tuple_element<_Ip, complex<_Tp>> { | ||
| 1395 | static_assert(_Ip < 2, "Index value is out of range."); | ||
| 1396 | using type = _Tp; | ||
| 1397 | }; | ||
| 1398 | |||
| 1399 | template <size_t _Ip, class _Xp> | ||
| 1400 | _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept { | ||
| 1401 | static_assert(_Ip < 2, "Index value is out of range."); | ||
| 1402 | if constexpr (_Ip == 0) { | ||
| 1403 | return __z.__re_; | ||
| 1404 | } else { | ||
| 1405 | return __z.__im_; | ||
| 1406 | } | ||
| 1407 | } | ||
| 1408 | |||
| 1409 | template <size_t _Ip, class _Xp> | ||
| 1410 | _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept { | ||
| 1411 | static_assert(_Ip < 2, "Index value is out of range."); | ||
| 1412 | if constexpr (_Ip == 0) { | ||
| 1413 | return std::move(__z.__re_); | ||
| 1414 | } else { | ||
| 1415 | return std::move(__z.__im_); | ||
| 1416 | } | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | template <size_t _Ip, class _Xp> | ||
| 1420 | _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept { | ||
| 1421 | static_assert(_Ip < 2, "Index value is out of range."); | ||
| 1422 | if constexpr (_Ip == 0) { | ||
| 1423 | return __z.__re_; | ||
| 1424 | } else { | ||
| 1425 | return __z.__im_; | ||
| 1426 | } | ||
| 1427 | } | ||
| 1428 | |||
| 1429 | template <size_t _Ip, class _Xp> | ||
| 1430 | _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexcept { | ||
| 1431 | static_assert(_Ip < 2, "Index value is out of range."); | ||
| 1432 | if constexpr (_Ip == 0) { | ||
| 1433 | return std::move(__z.__re_); | ||
| 1434 | } else { | ||
| 1435 | return std::move(__z.__im_); | ||
| 1436 | } | ||
| 1437 | } | ||
| 1438 | |||
| 1439 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 1440 | |||
| 1355 | #if _LIBCPP_STD_VER >= 14 | 1441 | #if _LIBCPP_STD_VER >= 14 |
| 1356 | // Literal suffix for complex number literals [complex.literals] | 1442 | // Literal suffix for complex number literals [complex.literals] |
| 1357 | inline namespace literals { | 1443 | inline namespace literals { |
| ... | @@ -1383,6 +1469,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long | ... | @@ -1383,6 +1469,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long |
| 1383 | 1469 | ||
| 1384 | _LIBCPP_END_NAMESPACE_STD | 1470 | _LIBCPP_END_NAMESPACE_STD |
| 1385 | 1471 | ||
| 1472 | _LIBCPP_POP_MACROS | ||
| 1473 | |||
| 1386 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 1474 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 1387 | # include <iosfwd> | 1475 | # include <iosfwd> |
| 1388 | # include <stdexcept> | 1476 | # include <stdexcept> |
lib/libcxx/include/concepts+30-23| ... | @@ -129,32 +129,39 @@ namespace std { | ... | @@ -129,32 +129,39 @@ namespace std { |
| 129 | 129 | ||
| 130 | */ | 130 | */ |
| 131 | 131 | ||
| 132 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 133 | #include <__concepts/arithmetic.h> | ||
| 134 | #include <__concepts/assignable.h> | ||
| 135 | #include <__concepts/boolean_testable.h> | ||
| 136 | #include <__concepts/class_or_enum.h> | ||
| 137 | #include <__concepts/common_reference_with.h> | ||
| 138 | #include <__concepts/common_with.h> | ||
| 139 | #include <__concepts/constructible.h> | ||
| 140 | #include <__concepts/convertible_to.h> | ||
| 141 | #include <__concepts/copyable.h> | ||
| 142 | #include <__concepts/derived_from.h> | ||
| 143 | #include <__concepts/destructible.h> | ||
| 144 | #include <__concepts/different_from.h> | ||
| 145 | #include <__concepts/equality_comparable.h> | ||
| 146 | #include <__concepts/invocable.h> | ||
| 147 | #include <__concepts/movable.h> | ||
| 148 | #include <__concepts/predicate.h> | ||
| 149 | #include <__concepts/regular.h> | ||
| 150 | #include <__concepts/relation.h> | ||
| 151 | #include <__concepts/same_as.h> | ||
| 152 | #include <__concepts/semiregular.h> | ||
| 153 | #include <__concepts/swappable.h> | ||
| 154 | #include <__concepts/totally_ordered.h> | ||
| 155 | #include <__config> | 132 | #include <__config> |
| 133 | |||
| 134 | #if _LIBCPP_STD_VER >= 20 | ||
| 135 | # include <__concepts/arithmetic.h> | ||
| 136 | # include <__concepts/assignable.h> | ||
| 137 | # include <__concepts/boolean_testable.h> | ||
| 138 | # include <__concepts/class_or_enum.h> | ||
| 139 | # include <__concepts/common_reference_with.h> | ||
| 140 | # include <__concepts/common_with.h> | ||
| 141 | # include <__concepts/constructible.h> | ||
| 142 | # include <__concepts/convertible_to.h> | ||
| 143 | # include <__concepts/copyable.h> | ||
| 144 | # include <__concepts/derived_from.h> | ||
| 145 | # include <__concepts/destructible.h> | ||
| 146 | # include <__concepts/different_from.h> | ||
| 147 | # include <__concepts/equality_comparable.h> | ||
| 148 | # include <__concepts/invocable.h> | ||
| 149 | # include <__concepts/movable.h> | ||
| 150 | # include <__concepts/predicate.h> | ||
| 151 | # include <__concepts/regular.h> | ||
| 152 | # include <__concepts/relation.h> | ||
| 153 | # include <__concepts/same_as.h> | ||
| 154 | # include <__concepts/semiregular.h> | ||
| 155 | # include <__concepts/swappable.h> | ||
| 156 | # include <__concepts/totally_ordered.h> | ||
| 157 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 158 | |||
| 156 | #include <version> | 159 | #include <version> |
| 157 | 160 | ||
| 161 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | ||
| 162 | # include <cstddef> | ||
| 163 | #endif | ||
| 164 | |||
| 158 | #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | 165 | #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) |
| 159 | # include <type_traits> | 166 | # include <type_traits> |
| 160 | #endif | 167 | #endif |
lib/libcxx/include/condition_variable-2| ... | @@ -118,8 +118,6 @@ public: | ... | @@ -118,8 +118,6 @@ public: |
| 118 | 118 | ||
| 119 | */ | 119 | */ |
| 120 | 120 | ||
| 121 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 122 | #include <__availability> | ||
| 123 | #include <__chrono/duration.h> | 121 | #include <__chrono/duration.h> |
| 124 | #include <__chrono/steady_clock.h> | 122 | #include <__chrono/steady_clock.h> |
| 125 | #include <__chrono/time_point.h> | 123 | #include <__chrono/time_point.h> |
lib/libcxx/include/coroutine+9-5| ... | @@ -38,12 +38,15 @@ struct suspend_always; | ... | @@ -38,12 +38,15 @@ struct suspend_always; |
| 38 | 38 | ||
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 42 | #include <__config> | 41 | #include <__config> |
| 43 | #include <__coroutine/coroutine_handle.h> | 42 | |
| 44 | #include <__coroutine/coroutine_traits.h> | 43 | #if _LIBCPP_STD_VER >= 20 |
| 45 | #include <__coroutine/noop_coroutine_handle.h> | 44 | # include <__coroutine/coroutine_handle.h> |
| 46 | #include <__coroutine/trivial_awaitables.h> | 45 | # include <__coroutine/coroutine_traits.h> |
| 46 | # include <__coroutine/noop_coroutine_handle.h> | ||
| 47 | # include <__coroutine/trivial_awaitables.h> | ||
| 48 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 49 | |||
| 47 | #include <version> | 50 | #include <version> |
| 48 | 51 | ||
| 49 | // standard-mandated includes | 52 | // standard-mandated includes |
| ... | @@ -57,6 +60,7 @@ struct suspend_always; | ... | @@ -57,6 +60,7 @@ struct suspend_always; |
| 57 | 60 | ||
| 58 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 61 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 59 | # include <iosfwd> | 62 | # include <iosfwd> |
| 63 | # include <limits> | ||
| 60 | # include <type_traits> | 64 | # include <type_traits> |
| 61 | #endif | 65 | #endif |
| 62 | 66 |
lib/libcxx/include/csetjmp-1| ... | @@ -30,7 +30,6 @@ void longjmp(jmp_buf env, int val); | ... | @@ -30,7 +30,6 @@ void longjmp(jmp_buf env, int val); |
| 30 | 30 | ||
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 34 | #include <__config> | 33 | #include <__config> |
| 35 | 34 | ||
| 36 | // <setjmp.h> is not provided by libc++ | 35 | // <setjmp.h> is not provided by libc++ |
lib/libcxx/include/csignal-1| ... | @@ -39,7 +39,6 @@ int raise(int sig); | ... | @@ -39,7 +39,6 @@ int raise(int sig); |
| 39 | 39 | ||
| 40 | */ | 40 | */ |
| 41 | 41 | ||
| 42 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 43 | #include <__config> | 42 | #include <__config> |
| 44 | 43 | ||
| 45 | // <signal.h> is not provided by libc++ | 44 | // <signal.h> is not provided by libc++ |
lib/libcxx/include/cstdarg-1| ... | @@ -31,7 +31,6 @@ Types: | ... | @@ -31,7 +31,6 @@ Types: |
| 31 | 31 | ||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 35 | #include <__config> | 34 | #include <__config> |
| 36 | 35 | ||
| 37 | // <stdarg.h> is not provided by libc++ | 36 | // <stdarg.h> is not provided by libc++ |
lib/libcxx/include/cstdbool-1| ... | @@ -19,7 +19,6 @@ Macros: | ... | @@ -19,7 +19,6 @@ Macros: |
| 19 | 19 | ||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 23 | #include <__config> | 22 | #include <__config> |
| 24 | 23 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/cstddef+1-2| ... | @@ -33,7 +33,6 @@ Types: | ... | @@ -33,7 +33,6 @@ Types: |
| 33 | 33 | ||
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 37 | #include <__config> | 36 | #include <__config> |
| 38 | #include <__type_traits/enable_if.h> | 37 | #include <__type_traits/enable_if.h> |
| 39 | #include <__type_traits/integral_constant.h> | 38 | #include <__type_traits/integral_constant.h> |
| ... | @@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) no | ... | @@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) no |
| 123 | } | 122 | } |
| 124 | 123 | ||
| 125 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | 124 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> |
| 126 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { | 125 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { |
| 127 | return static_cast<_Integer>(__b); | 126 | return static_cast<_Integer>(__b); |
| 128 | } | 127 | } |
| 129 | 128 |
lib/libcxx/include/cstdint-1| ... | @@ -140,7 +140,6 @@ Types: | ... | @@ -140,7 +140,6 @@ Types: |
| 140 | } // std | 140 | } // std |
| 141 | */ | 141 | */ |
| 142 | 142 | ||
| 143 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 144 | #include <__config> | 143 | #include <__config> |
| 145 | 144 | ||
| 146 | #include <stdint.h> | 145 | #include <stdint.h> |
lib/libcxx/include/cstdio-1| ... | @@ -95,7 +95,6 @@ void perror(const char* s); | ... | @@ -95,7 +95,6 @@ void perror(const char* s); |
| 95 | } // std | 95 | } // std |
| 96 | */ | 96 | */ |
| 97 | 97 | ||
| 98 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 99 | #include <__config> | 98 | #include <__config> |
| 100 | 99 | ||
| 101 | #include <stdio.h> | 100 | #include <stdio.h> |
lib/libcxx/include/cstdlib-1| ... | @@ -81,7 +81,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 | ... | @@ -81,7 +81,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 81 | 81 | ||
| 82 | */ | 82 | */ |
| 83 | 83 | ||
| 84 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 85 | #include <__config> | 84 | #include <__config> |
| 86 | 85 | ||
| 87 | #include <stdlib.h> | 86 | #include <stdlib.h> |
lib/libcxx/include/cstring-1| ... | @@ -56,7 +56,6 @@ size_t strlen(const char* s); | ... | @@ -56,7 +56,6 @@ size_t strlen(const char* s); |
| 56 | 56 | ||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 60 | #include <__config> | 59 | #include <__config> |
| 61 | #include <__type_traits/is_constant_evaluated.h> | 60 | #include <__type_traits/is_constant_evaluated.h> |
| 62 | 61 |
lib/libcxx/include/ctgmath-1| ... | @@ -18,7 +18,6 @@ | ... | @@ -18,7 +18,6 @@ |
| 18 | 18 | ||
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 22 | #include <ccomplex> | 21 | #include <ccomplex> |
| 23 | #include <cmath> | 22 | #include <cmath> |
| 24 | 23 |
lib/libcxx/include/ctime-1| ... | @@ -45,7 +45,6 @@ int timespec_get( struct timespec *ts, int base); // C++17 | ... | @@ -45,7 +45,6 @@ int timespec_get( struct timespec *ts, int base); // C++17 |
| 45 | 45 | ||
| 46 | */ | 46 | */ |
| 47 | 47 | ||
| 48 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 49 | #include <__config> | 48 | #include <__config> |
| 50 | 49 | ||
| 51 | // <time.h> is not provided by libc++ | 50 | // <time.h> is not provided by libc++ |
lib/libcxx/include/cuchar-1| ... | @@ -36,7 +36,6 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); | ... | @@ -36,7 +36,6 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); |
| 36 | 36 | ||
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 40 | #include <__config> | 39 | #include <__config> |
| 41 | 40 | ||
| 42 | #include <uchar.h> | 41 | #include <uchar.h> |
lib/libcxx/include/cwchar+6-3| ... | @@ -102,9 +102,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, | ... | @@ -102,9 +102,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 102 | 102 | ||
| 103 | */ | 103 | */ |
| 104 | 104 | ||
| 105 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 106 | #include <__config> | 105 | #include <__config> |
| 107 | #include <__type_traits/apply_cv.h> | 106 | #include <__type_traits/copy_cv.h> |
| 108 | #include <__type_traits/is_constant_evaluated.h> | 107 | #include <__type_traits/is_constant_evaluated.h> |
| 109 | #include <__type_traits/is_equality_comparable.h> | 108 | #include <__type_traits/is_equality_comparable.h> |
| 110 | #include <__type_traits/is_same.h> | 109 | #include <__type_traits/is_same.h> |
| ... | @@ -237,7 +236,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp | ... | @@ -237,7 +236,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp |
| 237 | wchar_t __value_buffer = 0; | 236 | wchar_t __value_buffer = 0; |
| 238 | __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t)); | 237 | __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t)); |
| 239 | return reinterpret_cast<_Tp*>( | 238 | return reinterpret_cast<_Tp*>( |
| 240 | __builtin_wmemchr(reinterpret_cast<__apply_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count)); | 239 | __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count)); |
| 241 | } | 240 | } |
| 242 | # if _LIBCPP_STD_VER >= 17 | 241 | # if _LIBCPP_STD_VER >= 17 |
| 243 | else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>) | 242 | else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>) |
| ... | @@ -255,4 +254,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp | ... | @@ -255,4 +254,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp |
| 255 | 254 | ||
| 256 | _LIBCPP_END_NAMESPACE_STD | 255 | _LIBCPP_END_NAMESPACE_STD |
| 257 | 256 | ||
| 257 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 258 | # include <cstddef> | ||
| 259 | #endif | ||
| 260 | |||
| 258 | #endif // _LIBCPP_CWCHAR | 261 | #endif // _LIBCPP_CWCHAR |
lib/libcxx/include/cwctype-1| ... | @@ -49,7 +49,6 @@ wctrans_t wctrans(const char* property); | ... | @@ -49,7 +49,6 @@ wctrans_t wctrans(const char* property); |
| 49 | 49 | ||
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 53 | #include <__config> | 52 | #include <__config> |
| 54 | #include <cctype> | 53 | #include <cctype> |
| 55 | 54 |
lib/libcxx/include/deque+74-62| ... | @@ -188,10 +188,11 @@ template <class T, class Allocator, class Predicate> | ... | @@ -188,10 +188,11 @@ template <class T, class Allocator, class Predicate> |
| 188 | #include <__algorithm/remove.h> | 188 | #include <__algorithm/remove.h> |
| 189 | #include <__algorithm/remove_if.h> | 189 | #include <__algorithm/remove_if.h> |
| 190 | #include <__algorithm/unwrap_iter.h> | 190 | #include <__algorithm/unwrap_iter.h> |
| 191 | #include <__assert> // all public C++ headers provide the assertion handler | 191 | #include <__assert> |
| 192 | #include <__availability> | ||
| 193 | #include <__config> | 192 | #include <__config> |
| 193 | #include <__debug_utils/sanitizers.h> | ||
| 194 | #include <__format/enable_insertable.h> | 194 | #include <__format/enable_insertable.h> |
| 195 | #include <__fwd/deque.h> | ||
| 195 | #include <__iterator/distance.h> | 196 | #include <__iterator/distance.h> |
| 196 | #include <__iterator/iterator_traits.h> | 197 | #include <__iterator/iterator_traits.h> |
| 197 | #include <__iterator/next.h> | 198 | #include <__iterator/next.h> |
| ... | @@ -213,6 +214,7 @@ template <class T, class Allocator, class Predicate> | ... | @@ -213,6 +214,7 @@ template <class T, class Allocator, class Predicate> |
| 213 | #include <__type_traits/is_allocator.h> | 214 | #include <__type_traits/is_allocator.h> |
| 214 | #include <__type_traits/is_convertible.h> | 215 | #include <__type_traits/is_convertible.h> |
| 215 | #include <__type_traits/is_same.h> | 216 | #include <__type_traits/is_same.h> |
| 217 | #include <__type_traits/is_swappable.h> | ||
| 216 | #include <__type_traits/type_identity.h> | 218 | #include <__type_traits/type_identity.h> |
| 217 | #include <__utility/forward.h> | 219 | #include <__utility/forward.h> |
| 218 | #include <__utility/move.h> | 220 | #include <__utility/move.h> |
| ... | @@ -244,9 +246,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -244,9 +246,6 @@ _LIBCPP_PUSH_MACROS |
| 244 | 246 | ||
| 245 | _LIBCPP_BEGIN_NAMESPACE_STD | 247 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 246 | 248 | ||
| 247 | template <class _Tp, class _Allocator = allocator<_Tp> > | ||
| 248 | class _LIBCPP_TEMPLATE_VIS deque; | ||
| 249 | |||
| 250 | template <class _ValueType, class _DiffType> | 249 | template <class _ValueType, class _DiffType> |
| 251 | struct __deque_block_size { | 250 | struct __deque_block_size { |
| 252 | static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16; | 251 | static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16; |
| ... | @@ -377,10 +376,13 @@ public: | ... | @@ -377,10 +376,13 @@ public: |
| 377 | return __x.__ptr_ == __y.__ptr_; | 376 | return __x.__ptr_ == __y.__ptr_; |
| 378 | } | 377 | } |
| 379 | 378 | ||
| 379 | #if _LIBCPP_STD_VER <= 17 | ||
| 380 | _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) { | 380 | _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) { |
| 381 | return !(__x == __y); | 381 | return !(__x == __y); |
| 382 | } | 382 | } |
| 383 | #endif | ||
| 383 | 384 | ||
| 385 | // TODO(mordante) disable these overloads in the LLVM 20 release. | ||
| 384 | _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) { | 386 | _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) { |
| 385 | return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_); | 387 | return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_); |
| 386 | } | 388 | } |
| ... | @@ -397,6 +399,29 @@ public: | ... | @@ -397,6 +399,29 @@ public: |
| 397 | return !(__x < __y); | 399 | return !(__x < __y); |
| 398 | } | 400 | } |
| 399 | 401 | ||
| 402 | #if _LIBCPP_STD_VER >= 20 | ||
| 403 | _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) { | ||
| 404 | if (__x.__m_iter_ < __y.__m_iter_) | ||
| 405 | return strong_ordering::less; | ||
| 406 | |||
| 407 | if (__x.__m_iter_ == __y.__m_iter_) { | ||
| 408 | if constexpr (three_way_comparable<pointer, strong_ordering>) { | ||
| 409 | return __x.__ptr_ <=> __y.__ptr_; | ||
| 410 | } else { | ||
| 411 | if (__x.__ptr_ < __y.__ptr_) | ||
| 412 | return strong_ordering::less; | ||
| 413 | |||
| 414 | if (__x.__ptr_ == __y.__ptr_) | ||
| 415 | return strong_ordering::equal; | ||
| 416 | |||
| 417 | return strong_ordering::greater; | ||
| 418 | } | ||
| 419 | } | ||
| 420 | |||
| 421 | return strong_ordering::greater; | ||
| 422 | } | ||
| 423 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 424 | |||
| 400 | private: | 425 | private: |
| 401 | _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT | 426 | _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT |
| 402 | : __m_iter_(__m), | 427 | : __m_iter_(__m), |
| ... | @@ -450,11 +475,11 @@ public: | ... | @@ -450,11 +475,11 @@ public: |
| 450 | 475 | ||
| 451 | using value_type = _Tp; | 476 | using value_type = _Tp; |
| 452 | 477 | ||
| 453 | static_assert((is_same<typename _Allocator::value_type, value_type>::value), | ||
| 454 | "Allocator::value_type must be same type as value_type"); | ||
| 455 | |||
| 456 | using allocator_type = _Allocator; | 478 | using allocator_type = _Allocator; |
| 457 | using __alloc_traits = allocator_traits<allocator_type>; | 479 | using __alloc_traits = allocator_traits<allocator_type>; |
| 480 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | ||
| 481 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | ||
| 482 | "Allocator::value_type must be same type as value_type"); | ||
| 458 | 483 | ||
| 459 | using size_type = typename __alloc_traits::size_type; | 484 | using size_type = typename __alloc_traits::size_type; |
| 460 | using difference_type = typename __alloc_traits::difference_type; | 485 | using difference_type = typename __alloc_traits::difference_type; |
| ... | @@ -479,15 +504,22 @@ public: | ... | @@ -479,15 +504,22 @@ public: |
| 479 | using reverse_iterator = std::reverse_iterator<iterator>; | 504 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 480 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | 505 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 481 | 506 | ||
| 482 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | 507 | // A deque contains the following members which may be trivially relocatable: |
| 483 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | 508 | // - __map: is a `__split_buffer`, see `__split_buffer` for more information on when it is trivially relocatable |
| 484 | "original allocator"); | 509 | // - size_type: is always trivially relocatable, since it is required to be an integral type |
| 510 | // - allocator_type: may not be trivially relocatable, so it's checked | ||
| 511 | // None of these are referencing the `deque` itself, so if all of them are trivially relocatable, `deque` is too. | ||
| 512 | using __trivially_relocatable = __conditional_t< | ||
| 513 | __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | ||
| 514 | deque, | ||
| 515 | void>; | ||
| 516 | |||
| 485 | static_assert(is_nothrow_default_constructible<allocator_type>::value == | 517 | static_assert(is_nothrow_default_constructible<allocator_type>::value == |
| 486 | is_nothrow_default_constructible<__pointer_allocator>::value, | 518 | is_nothrow_default_constructible<__pointer_allocator>::value, |
| 487 | "rebinding an allocator should not change excpetion guarantees"); | 519 | "rebinding an allocator should not change exception guarantees"); |
| 488 | static_assert(is_nothrow_move_constructible<allocator_type>::value == | 520 | static_assert(is_nothrow_move_constructible<allocator_type>::value == |
| 489 | is_nothrow_move_constructible<typename __map::allocator_type>::value, | 521 | is_nothrow_move_constructible<typename __map::allocator_type>::value, |
| 490 | "rebinding an allocator should not change excpetion guarantees"); | 522 | "rebinding an allocator should not change exception guarantees"); |
| 491 | 523 | ||
| 492 | private: | 524 | private: |
| 493 | struct __deque_block_range { | 525 | struct __deque_block_range { |
| ... | @@ -581,7 +613,7 @@ public: | ... | @@ -581,7 +613,7 @@ public: |
| 581 | #endif | 613 | #endif |
| 582 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v); | 614 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v); |
| 583 | 615 | ||
| 584 | template <class = __enable_if_t<__is_allocator<_Allocator>::value> > | 616 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 585 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a) | 617 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a) |
| 586 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | 618 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { |
| 587 | __annotate_new(0); | 619 | __annotate_new(0); |
| ... | @@ -623,11 +655,11 @@ public: | ... | @@ -623,11 +655,11 @@ public: |
| 623 | return *this; | 655 | return *this; |
| 624 | } | 656 | } |
| 625 | 657 | ||
| 626 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 658 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value); |
| 627 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a); | 659 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a); |
| 628 | _LIBCPP_HIDE_FROM_ABI deque& operator=(deque&& __c) | 660 | _LIBCPP_HIDE_FROM_ABI deque& |
| 629 | _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value&& | 661 | operator=(deque&& __c) noexcept(__alloc_traits::propagate_on_container_move_assignment::value && |
| 630 | is_nothrow_move_assignable<allocator_type>::value); | 662 | is_nothrow_move_assignable<allocator_type>::value); |
| 631 | 663 | ||
| 632 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } | 664 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } |
| 633 | #endif // _LIBCPP_CXX03_LANG | 665 | #endif // _LIBCPP_CXX03_LANG |
| ... | @@ -709,7 +741,7 @@ public: | ... | @@ -709,7 +741,7 @@ public: |
| 709 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); | 741 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); |
| 710 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); | 742 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); |
| 711 | _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; | 743 | _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; |
| 712 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | 744 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } |
| 713 | 745 | ||
| 714 | // element access: | 746 | // element access: |
| 715 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT; | 747 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT; |
| ... | @@ -796,7 +828,7 @@ public: | ... | @@ -796,7 +828,7 @@ public: |
| 796 | #if _LIBCPP_STD_VER >= 14 | 828 | #if _LIBCPP_STD_VER >= 14 |
| 797 | _NOEXCEPT; | 829 | _NOEXCEPT; |
| 798 | #else | 830 | #else |
| 799 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value); | 831 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 800 | #endif | 832 | #endif |
| 801 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; | 833 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; |
| 802 | 834 | ||
| ... | @@ -866,33 +898,6 @@ private: | ... | @@ -866,33 +898,6 @@ private: |
| 866 | __asan_back_moved, | 898 | __asan_back_moved, |
| 867 | }; | 899 | }; |
| 868 | 900 | ||
| 869 | // The following functions are no-ops outside of AddressSanitizer mode. | ||
| 870 | // We call annotations for every allocator, unless explicitly disabled. | ||
| 871 | // | ||
| 872 | // To disable annotations for a particular allocator, change value of | ||
| 873 | // __asan_annotate_container_with_allocator to false. | ||
| 874 | // For more details, see the "Using libc++" documentation page or | ||
| 875 | // the documentation for __sanitizer_annotate_contiguous_container. | ||
| 876 | _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( | ||
| 877 | const void* __beg, | ||
| 878 | const void* __end, | ||
| 879 | const void* __old_con_beg, | ||
| 880 | const void* __old_con_end, | ||
| 881 | const void* __new_con_beg, | ||
| 882 | const void* __new_con_end) const { | ||
| 883 | (void)__beg; | ||
| 884 | (void)__end; | ||
| 885 | (void)__old_con_beg; | ||
| 886 | (void)__old_con_end; | ||
| 887 | (void)__new_con_beg; | ||
| 888 | (void)__new_con_end; | ||
| 889 | #ifndef _LIBCPP_HAS_NO_ASAN | ||
| 890 | if (__beg != nullptr && __asan_annotate_container_with_allocator<_Allocator>::value) | ||
| 891 | __sanitizer_annotate_double_ended_contiguous_container( | ||
| 892 | __beg, __end, __old_con_beg, __old_con_end, __new_con_beg, __new_con_end); | ||
| 893 | #endif | ||
| 894 | } | ||
| 895 | |||
| 896 | _LIBCPP_HIDE_FROM_ABI void __annotate_from_to( | 901 | _LIBCPP_HIDE_FROM_ABI void __annotate_from_to( |
| 897 | size_type __beg, | 902 | size_type __beg, |
| 898 | size_type __end, | 903 | size_type __end, |
| ... | @@ -992,7 +997,8 @@ private: | ... | @@ -992,7 +997,8 @@ private: |
| 992 | const void* __new_beg = __front ? __new_edge : __old_edge; | 997 | const void* __new_beg = __front ? __new_edge : __old_edge; |
| 993 | const void* __new_end = __front ? __old_edge : __new_edge; | 998 | const void* __new_end = __front ? __old_edge : __new_edge; |
| 994 | 999 | ||
| 995 | __annotate_double_ended_contiguous_container(__mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); | 1000 | std::__annotate_double_ended_contiguous_container<_Allocator>( |
| 1001 | __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); | ||
| 996 | } | 1002 | } |
| 997 | #endif // !_LIBCPP_HAS_NO_ASAN | 1003 | #endif // !_LIBCPP_HAS_NO_ASAN |
| 998 | } | 1004 | } |
| ... | @@ -1053,11 +1059,7 @@ private: | ... | @@ -1053,11 +1059,7 @@ private: |
| 1053 | } | 1059 | } |
| 1054 | 1060 | ||
| 1055 | _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT { | 1061 | _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT { |
| 1056 | (void)__beginning; | 1062 | std::__annotate_double_ended_contiguous_container<_Allocator>(__beginning, __end, __beginning, __end, __end, __end); |
| 1057 | (void)__end; | ||
| 1058 | #ifndef _LIBCPP_HAS_NO_ASAN | ||
| 1059 | __annotate_double_ended_contiguous_container(__beginning, __end, __beginning, __end, __end, __end); | ||
| 1060 | #endif | ||
| 1061 | } | 1063 | } |
| 1062 | 1064 | ||
| 1063 | _LIBCPP_HIDE_FROM_ABI void | 1065 | _LIBCPP_HIDE_FROM_ABI void |
| ... | @@ -1072,7 +1074,7 @@ private: | ... | @@ -1072,7 +1074,7 @@ private: |
| 1072 | if (__annotation_type == __asan_poison) | 1074 | if (__annotation_type == __asan_poison) |
| 1073 | __annotate_poison_block(__block_start, __block_end); | 1075 | __annotate_poison_block(__block_start, __block_end); |
| 1074 | else { | 1076 | else { |
| 1075 | __annotate_double_ended_contiguous_container( | 1077 | std::__annotate_double_ended_contiguous_container<_Allocator>( |
| 1076 | __block_start, __block_end, __block_start, __block_start, __block_start, __block_end); | 1078 | __block_start, __block_end, __block_start, __block_start, __block_start, __block_end); |
| 1077 | } | 1079 | } |
| 1078 | #endif | 1080 | #endif |
| ... | @@ -1330,7 +1332,7 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator | ... | @@ -1330,7 +1332,7 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator |
| 1330 | } | 1332 | } |
| 1331 | 1333 | ||
| 1332 | template <class _Tp, class _Allocator> | 1334 | template <class _Tp, class _Allocator> |
| 1333 | inline deque<_Tp, _Allocator>::deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 1335 | inline deque<_Tp, _Allocator>::deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value) |
| 1334 | : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_)) { | 1336 | : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_)) { |
| 1335 | __c.__start_ = 0; | 1337 | __c.__start_ = 0; |
| 1336 | __c.__size() = 0; | 1338 | __c.__size() = 0; |
| ... | @@ -1354,8 +1356,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca | ... | @@ -1354,8 +1356,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca |
| 1354 | } | 1356 | } |
| 1355 | 1357 | ||
| 1356 | template <class _Tp, class _Allocator> | 1358 | template <class _Tp, class _Allocator> |
| 1357 | inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) _NOEXCEPT_( | 1359 | inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept( |
| 1358 | __alloc_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<allocator_type>::value) { | 1360 | __alloc_traits::propagate_on_container_move_assignment::value && |
| 1361 | is_nothrow_move_assignable<allocator_type>::value) { | ||
| 1359 | __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | 1362 | __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 1360 | return *this; | 1363 | return *this; |
| 1361 | } | 1364 | } |
| ... | @@ -1370,8 +1373,8 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type) { | ... | @@ -1370,8 +1373,8 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type) { |
| 1370 | } | 1373 | } |
| 1371 | 1374 | ||
| 1372 | template <class _Tp, class _Allocator> | 1375 | template <class _Tp, class _Allocator> |
| 1373 | void deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type) | 1376 | void deque<_Tp, _Allocator>::__move_assign(deque& __c, |
| 1374 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | 1377 | true_type) noexcept(is_nothrow_move_assignable<allocator_type>::value) { |
| 1375 | clear(); | 1378 | clear(); |
| 1376 | shrink_to_fit(); | 1379 | shrink_to_fit(); |
| 1377 | __move_assign(__c); | 1380 | __move_assign(__c); |
| ... | @@ -1487,6 +1490,7 @@ void deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { | ... | @@ -1487,6 +1490,7 @@ void deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { |
| 1487 | 1490 | ||
| 1488 | template <class _Tp, class _Allocator> | 1491 | template <class _Tp, class _Allocator> |
| 1489 | inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT { | 1492 | inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT { |
| 1493 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "deque::operator[] index out of bounds"); | ||
| 1490 | size_type __p = __start_ + __i; | 1494 | size_type __p = __start_ + __i; |
| 1491 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); | 1495 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); |
| 1492 | } | 1496 | } |
| ... | @@ -1494,6 +1498,7 @@ inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operat | ... | @@ -1494,6 +1498,7 @@ inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operat |
| 1494 | template <class _Tp, class _Allocator> | 1498 | template <class _Tp, class _Allocator> |
| 1495 | inline typename deque<_Tp, _Allocator>::const_reference | 1499 | inline typename deque<_Tp, _Allocator>::const_reference |
| 1496 | deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT { | 1500 | deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT { |
| 1501 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "deque::operator[] index out of bounds"); | ||
| 1497 | size_type __p = __start_ + __i; | 1502 | size_type __p = __start_ + __i; |
| 1498 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); | 1503 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); |
| 1499 | } | 1504 | } |
| ... | @@ -1516,22 +1521,26 @@ inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>:: | ... | @@ -1516,22 +1521,26 @@ inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>:: |
| 1516 | 1521 | ||
| 1517 | template <class _Tp, class _Allocator> | 1522 | template <class _Tp, class _Allocator> |
| 1518 | inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() _NOEXCEPT { | 1523 | inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() _NOEXCEPT { |
| 1524 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::front called on an empty deque"); | ||
| 1519 | return *(*(__map_.begin() + __start_ / __block_size) + __start_ % __block_size); | 1525 | return *(*(__map_.begin() + __start_ / __block_size) + __start_ % __block_size); |
| 1520 | } | 1526 | } |
| 1521 | 1527 | ||
| 1522 | template <class _Tp, class _Allocator> | 1528 | template <class _Tp, class _Allocator> |
| 1523 | inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const _NOEXCEPT { | 1529 | inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const _NOEXCEPT { |
| 1530 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::front called on an empty deque"); | ||
| 1524 | return *(*(__map_.begin() + __start_ / __block_size) + __start_ % __block_size); | 1531 | return *(*(__map_.begin() + __start_ / __block_size) + __start_ % __block_size); |
| 1525 | } | 1532 | } |
| 1526 | 1533 | ||
| 1527 | template <class _Tp, class _Allocator> | 1534 | template <class _Tp, class _Allocator> |
| 1528 | inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::back() _NOEXCEPT { | 1535 | inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::back() _NOEXCEPT { |
| 1536 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::back called on an empty deque"); | ||
| 1529 | size_type __p = size() + __start_ - 1; | 1537 | size_type __p = size() + __start_ - 1; |
| 1530 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); | 1538 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); |
| 1531 | } | 1539 | } |
| 1532 | 1540 | ||
| 1533 | template <class _Tp, class _Allocator> | 1541 | template <class _Tp, class _Allocator> |
| 1534 | inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::back() const _NOEXCEPT { | 1542 | inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::back() const _NOEXCEPT { |
| 1543 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::back called on an empty deque"); | ||
| 1535 | size_type __p = size() + __start_ - 1; | 1544 | size_type __p = size() + __start_ - 1; |
| 1536 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); | 1545 | return *(*(__map_.begin() + __p / __block_size) + __p % __block_size); |
| 1537 | } | 1546 | } |
| ... | @@ -2255,6 +2264,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { | ... | @@ -2255,6 +2264,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { |
| 2255 | 2264 | ||
| 2256 | template <class _Tp, class _Allocator> | 2265 | template <class _Tp, class _Allocator> |
| 2257 | void deque<_Tp, _Allocator>::pop_front() { | 2266 | void deque<_Tp, _Allocator>::pop_front() { |
| 2267 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::pop_front called on an empty deque"); | ||
| 2258 | size_type __old_sz = size(); | 2268 | size_type __old_sz = size(); |
| 2259 | size_type __old_start = __start_; | 2269 | size_type __old_start = __start_; |
| 2260 | allocator_type& __a = __alloc(); | 2270 | allocator_type& __a = __alloc(); |
| ... | @@ -2395,6 +2405,8 @@ void deque<_Tp, _Allocator>::__move_construct_backward_and_check( | ... | @@ -2395,6 +2405,8 @@ void deque<_Tp, _Allocator>::__move_construct_backward_and_check( |
| 2395 | 2405 | ||
| 2396 | template <class _Tp, class _Allocator> | 2406 | template <class _Tp, class _Allocator> |
| 2397 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f) { | 2407 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f) { |
| 2408 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | ||
| 2409 | __f != end(), "deque::erase(iterator) called with a non-dereferenceable iterator"); | ||
| 2398 | size_type __old_sz = size(); | 2410 | size_type __old_sz = size(); |
| 2399 | size_type __old_start = __start_; | 2411 | size_type __old_start = __start_; |
| 2400 | iterator __b = begin(); | 2412 | iterator __b = begin(); |
| ... | @@ -2420,6 +2432,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it | ... | @@ -2420,6 +2432,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it |
| 2420 | 2432 | ||
| 2421 | template <class _Tp, class _Allocator> | 2433 | template <class _Tp, class _Allocator> |
| 2422 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l) { | 2434 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l) { |
| 2435 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__f <= __l, "deque::erase(first, last) called with an invalid range"); | ||
| 2423 | size_type __old_sz = size(); | 2436 | size_type __old_sz = size(); |
| 2424 | size_type __old_start = __start_; | 2437 | size_type __old_start = __start_; |
| 2425 | difference_type __n = __l - __f; | 2438 | difference_type __n = __l - __f; |
| ... | @@ -2474,7 +2487,7 @@ inline void deque<_Tp, _Allocator>::swap(deque& __c) | ... | @@ -2474,7 +2487,7 @@ inline void deque<_Tp, _Allocator>::swap(deque& __c) |
| 2474 | #if _LIBCPP_STD_VER >= 14 | 2487 | #if _LIBCPP_STD_VER >= 14 |
| 2475 | _NOEXCEPT | 2488 | _NOEXCEPT |
| 2476 | #else | 2489 | #else |
| 2477 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) | 2490 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 2478 | #endif | 2491 | #endif |
| 2479 | { | 2492 | { |
| 2480 | __map_.swap(__c.__map_); | 2493 | __map_.swap(__c.__map_); |
| ... | @@ -2543,8 +2556,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x, | ... | @@ -2543,8 +2556,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x, |
| 2543 | template <class _Tp, class _Allocator> | 2556 | template <class _Tp, class _Allocator> |
| 2544 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> | 2557 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 2545 | operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { | 2558 | operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { |
| 2546 | return std::lexicographical_compare_three_way( | 2559 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 2547 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>); | ||
| 2548 | } | 2560 | } |
| 2549 | 2561 | ||
| 2550 | #endif // _LIBCPP_STD_VER <= 17 | 2562 | #endif // _LIBCPP_STD_VER <= 17 |
lib/libcxx/include/exception-1| ... | @@ -76,7 +76,6 @@ template <class E> void rethrow_if_nested(const E& e); | ... | @@ -76,7 +76,6 @@ template <class E> void rethrow_if_nested(const E& e); |
| 76 | 76 | ||
| 77 | */ | 77 | */ |
| 78 | 78 | ||
| 79 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 80 | #include <__config> | 79 | #include <__config> |
| 81 | #include <__exception/exception.h> | 80 | #include <__exception/exception.h> |
| 82 | #include <__exception/exception_ptr.h> | 81 | #include <__exception/exception_ptr.h> |
lib/libcxx/include/execution+4-1| ... | @@ -32,7 +32,6 @@ namespace std { | ... | @@ -32,7 +32,6 @@ namespace std { |
| 32 | } | 32 | } |
| 33 | */ | 33 | */ |
| 34 | 34 | ||
| 35 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 36 | #include <__config> | 35 | #include <__config> |
| 37 | #include <__type_traits/is_execution_policy.h> | 36 | #include <__type_traits/is_execution_policy.h> |
| 38 | #include <__type_traits/is_same.h> | 37 | #include <__type_traits/is_same.h> |
| ... | @@ -143,4 +142,8 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -143,4 +142,8 @@ _LIBCPP_END_NAMESPACE_STD |
| 143 | 142 | ||
| 144 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | 143 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 |
| 145 | 144 | ||
| 145 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 146 | # include <cstddef> | ||
| 147 | #endif | ||
| 148 | |||
| 146 | #endif // _LIBCPP_EXECUTION | 149 | #endif // _LIBCPP_EXECUTION |
lib/libcxx/include/expected+14-5| ... | @@ -38,16 +38,25 @@ namespace std { | ... | @@ -38,16 +38,25 @@ namespace std { |
| 38 | 38 | ||
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 42 | #include <__config> | 41 | #include <__config> |
| 43 | #include <__expected/bad_expected_access.h> | 42 | |
| 44 | #include <__expected/expected.h> | 43 | #if _LIBCPP_STD_VER >= 23 |
| 45 | #include <__expected/unexpect.h> | 44 | # include <__expected/bad_expected_access.h> |
| 46 | #include <__expected/unexpected.h> | 45 | # include <__expected/expected.h> |
| 46 | # include <__expected/unexpect.h> | ||
| 47 | # include <__expected/unexpected.h> | ||
| 48 | #endif | ||
| 49 | |||
| 47 | #include <version> | 50 | #include <version> |
| 48 | 51 | ||
| 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 50 | # pragma GCC system_header | 53 | # pragma GCC system_header |
| 51 | #endif | 54 | #endif |
| 52 | 55 | ||
| 56 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 57 | # include <cstddef> | ||
| 58 | # include <initializer_list> | ||
| 59 | # include <new> | ||
| 60 | #endif | ||
| 61 | |||
| 53 | #endif // _LIBCPP_EXPECTED | 62 | #endif // _LIBCPP_EXPECTED |
lib/libcxx/include/experimental/__memory deleted-94| ... | @@ -1,94 +0,0 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP_EXPERIMENTAL___MEMORY | ||
| 11 | #define _LIBCPP_EXPERIMENTAL___MEMORY | ||
| 12 | |||
| 13 | #include <__memory/allocator_arg_t.h> | ||
| 14 | #include <__memory/uses_allocator.h> | ||
| 15 | #include <__type_traits/conditional.h> | ||
| 16 | #include <__type_traits/is_constructible.h> | ||
| 17 | #include <__type_traits/is_convertible.h> | ||
| 18 | #include <__type_traits/is_same.h> | ||
| 19 | #include <experimental/__config> | ||
| 20 | #include <experimental/utility> // for erased_type | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_BEGIN_NAMESPACE_LFTS | ||
| 27 | |||
| 28 | template < class _Tp, class _Alloc, bool = uses_allocator<_Tp, _Alloc>::value, bool = __has_allocator_type<_Tp>::value > | ||
| 29 | struct __lfts_uses_allocator : public false_type {}; | ||
| 30 | |||
| 31 | template <class _Tp, class _Alloc> | ||
| 32 | struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {}; | ||
| 33 | |||
| 34 | template <class _Tp, class _Alloc, bool HasAlloc> | ||
| 35 | struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {}; | ||
| 36 | |||
| 37 | template <class _Tp, class _Alloc> | ||
| 38 | struct __lfts_uses_allocator<_Tp, _Alloc, false, true> | ||
| 39 | : public integral_constant<bool, | ||
| 40 | is_convertible<_Alloc, typename _Tp::allocator_type>::value || | ||
| 41 | is_same<erased_type, typename _Tp::allocator_type>::value > {}; | ||
| 42 | |||
| 43 | template <bool _UsesAlloc, class _Tp, class _Alloc, class... _Args> | ||
| 44 | struct __lfts_uses_alloc_ctor_imp { | ||
| 45 | static const int value = 0; | ||
| 46 | }; | ||
| 47 | |||
| 48 | template <class _Tp, class _Alloc, class... _Args> | ||
| 49 | struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...> { | ||
| 50 | static const bool __ic_first = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; | ||
| 51 | |||
| 52 | static const bool __ic_second = | ||
| 53 | __conditional_t< __ic_first, false_type, is_constructible<_Tp, _Args..., _Alloc> >::value; | ||
| 54 | |||
| 55 | static_assert(__ic_first || __ic_second, "Request for uses allocator construction is ill-formed"); | ||
| 56 | |||
| 57 | static const int value = __ic_first ? 1 : 2; | ||
| 58 | }; | ||
| 59 | |||
| 60 | template <class _Tp, class _Alloc, class... _Args> | ||
| 61 | struct __lfts_uses_alloc_ctor | ||
| 62 | : integral_constant< | ||
| 63 | int, | ||
| 64 | __lfts_uses_alloc_ctor_imp< __lfts_uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args... >::value > {}; | ||
| 65 | |||
| 66 | template <class _Tp, class _Allocator, class... _Args> | ||
| 67 | inline _LIBCPP_HIDE_FROM_ABI void | ||
| 68 | __user_alloc_construct_impl(integral_constant<int, 0>, _Tp* __storage, const _Allocator&, _Args&&... __args) { | ||
| 69 | new (__storage) _Tp(std::forward<_Args>(__args)...); | ||
| 70 | } | ||
| 71 | |||
| 72 | // FIXME: This should have a version which takes a non-const alloc. | ||
| 73 | template <class _Tp, class _Allocator, class... _Args> | ||
| 74 | inline _LIBCPP_HIDE_FROM_ABI void | ||
| 75 | __user_alloc_construct_impl(integral_constant<int, 1>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) { | ||
| 76 | new (__storage) _Tp(allocator_arg_t(), __a, std::forward<_Args>(__args)...); | ||
| 77 | } | ||
| 78 | |||
| 79 | // FIXME: This should have a version which takes a non-const alloc. | ||
| 80 | template <class _Tp, class _Allocator, class... _Args> | ||
| 81 | inline _LIBCPP_HIDE_FROM_ABI void | ||
| 82 | __user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) { | ||
| 83 | new (__storage) _Tp(std::forward<_Args>(__args)..., __a); | ||
| 84 | } | ||
| 85 | |||
| 86 | template <class _Tp, class _Alloc, class... _Args> | ||
| 87 | inline _LIBCPP_HIDE_FROM_ABI void __lfts_user_alloc_construct(_Tp* __store, const _Alloc& __a, _Args&&... __args) { | ||
| 88 | ::std::experimental::fundamentals_v1::__user_alloc_construct_impl( | ||
| 89 | typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type(), __store, __a, std::forward<_Args>(__args)...); | ||
| 90 | } | ||
| 91 | |||
| 92 | _LIBCPP_END_NAMESPACE_LFTS | ||
| 93 | |||
| 94 | #endif /* _LIBCPP_EXPERIMENTAL___MEMORY */ | ||
lib/libcxx/include/experimental/__simd/reference.h+41| ... | @@ -13,10 +13,14 @@ | ... | @@ -13,10 +13,14 @@ |
| 13 | #include <__type_traits/is_assignable.h> | 13 | #include <__type_traits/is_assignable.h> |
| 14 | #include <__type_traits/is_same.h> | 14 | #include <__type_traits/is_same.h> |
| 15 | #include <__utility/forward.h> | 15 | #include <__utility/forward.h> |
| 16 | #include <__utility/move.h> | ||
| 16 | #include <cstddef> | 17 | #include <cstddef> |
| 17 | #include <experimental/__config> | 18 | #include <experimental/__config> |
| 18 | #include <experimental/__simd/utility.h> | 19 | #include <experimental/__simd/utility.h> |
| 19 | 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | ||
| 22 | #include <__undef_macros> | ||
| 23 | |||
| 20 | #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) | 24 | #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) |
| 21 | 25 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL | 26 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL |
| ... | @@ -55,10 +59,47 @@ public: | ... | @@ -55,10 +59,47 @@ public: |
| 55 | __set(static_cast<value_type>(std::forward<_Up>(__v))); | 59 | __set(static_cast<value_type>(std::forward<_Up>(__v))); |
| 56 | return {__s_, __idx_}; | 60 | return {__s_, __idx_}; |
| 57 | } | 61 | } |
| 62 | |||
| 63 | // Note: This approach might not fully align with the specification, | ||
| 64 | // which might be a wording defect. (https://wg21.link/N4808 section 9.6.3) | ||
| 65 | template <class _Tp1, class _Storage1, class _Vp1> | ||
| 66 | friend void | ||
| 67 | swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, __simd_reference<_Tp1, _Storage1, _Vp1>&& __b) noexcept; | ||
| 68 | |||
| 69 | template <class _Tp1, class _Storage1, class _Vp1> | ||
| 70 | friend void swap(_Vp1& __a, __simd_reference<_Tp1, _Storage1, _Vp1>&& __b) noexcept; | ||
| 71 | |||
| 72 | template <class _Tp1, class _Storage1, class _Vp1> | ||
| 73 | friend void swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, _Vp1& __b) noexcept; | ||
| 58 | }; | 74 | }; |
| 59 | 75 | ||
| 76 | template <class _Tp, class _Storage, class _Vp> | ||
| 77 | _LIBCPP_HIDE_FROM_ABI void | ||
| 78 | swap(__simd_reference<_Tp, _Storage, _Vp>&& __a, __simd_reference<_Tp, _Storage, _Vp>&& __b) noexcept { | ||
| 79 | _Vp __tmp(std::move(__a)); | ||
| 80 | std::move(__a) = std::move(__b); | ||
| 81 | std::move(__b) = std::move(__tmp); | ||
| 82 | } | ||
| 83 | |||
| 84 | template <class _Tp, class _Storage, class _Vp> | ||
| 85 | _LIBCPP_HIDE_FROM_ABI void swap(_Vp& __a, __simd_reference<_Tp, _Storage, _Vp>&& __b) noexcept { | ||
| 86 | _Vp __tmp(std::move(__a)); | ||
| 87 | __a = std::move(__b); | ||
| 88 | std::move(__b) = std::move(__tmp); | ||
| 89 | } | ||
| 90 | |||
| 91 | template <class _Tp, class _Storage, class _Vp> | ||
| 92 | _LIBCPP_HIDE_FROM_ABI void swap(__simd_reference<_Tp, _Storage, _Vp>&& __a, _Vp& __b) noexcept { | ||
| 93 | _Vp __tmp(std::move(__a)); | ||
| 94 | std::move(__a) = std::move(__b); | ||
| 95 | __b = std::move(__tmp); | ||
| 96 | } | ||
| 97 | |||
| 60 | } // namespace parallelism_v2 | 98 | } // namespace parallelism_v2 |
| 61 | _LIBCPP_END_NAMESPACE_EXPERIMENTAL | 99 | _LIBCPP_END_NAMESPACE_EXPERIMENTAL |
| 62 | 100 | ||
| 63 | #endif // _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) | 101 | #endif // _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) |
| 102 | |||
| 103 | _LIBCPP_POP_MACROS | ||
| 104 | |||
| 64 | #endif // _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H | 105 | #endif // _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H |
lib/libcxx/include/experimental/__simd/scalar.h+8| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H |
| 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 13 | #include <cstddef> | 14 | #include <cstddef> |
| 14 | #include <experimental/__config> | 15 | #include <experimental/__config> |
| 15 | #include <experimental/__simd/declaration.h> | 16 | #include <experimental/__simd/declaration.h> |
| ... | @@ -61,6 +62,11 @@ struct __simd_operations<_Tp, simd_abi::__scalar> { | ... | @@ -61,6 +62,11 @@ struct __simd_operations<_Tp, simd_abi::__scalar> { |
| 61 | static _LIBCPP_HIDE_FROM_ABI void __load(_SimdStorage& __s, const _Up* __mem) noexcept { | 62 | static _LIBCPP_HIDE_FROM_ABI void __load(_SimdStorage& __s, const _Up* __mem) noexcept { |
| 62 | __s.__data = static_cast<_Tp>(__mem[0]); | 63 | __s.__data = static_cast<_Tp>(__mem[0]); |
| 63 | } | 64 | } |
| 65 | |||
| 66 | template <class _Up> | ||
| 67 | static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept { | ||
| 68 | *__mem = static_cast<_Up>(__s.__data); | ||
| 69 | } | ||
| 64 | }; | 70 | }; |
| 65 | 71 | ||
| 66 | template <class _Tp> | 72 | template <class _Tp> |
| ... | @@ -70,6 +76,8 @@ struct __mask_operations<_Tp, simd_abi::__scalar> { | ... | @@ -70,6 +76,8 @@ struct __mask_operations<_Tp, simd_abi::__scalar> { |
| 70 | static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; } | 76 | static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; } |
| 71 | 77 | ||
| 72 | static _LIBCPP_HIDE_FROM_ABI void __load(_MaskStorage& __s, const bool* __mem) noexcept { __s.__data = __mem[0]; } | 78 | static _LIBCPP_HIDE_FROM_ABI void __load(_MaskStorage& __s, const bool* __mem) noexcept { __s.__data = __mem[0]; } |
| 79 | |||
| 80 | static _LIBCPP_HIDE_FROM_ABI void __store(_MaskStorage __s, bool* __mem) noexcept { __mem[0] = __s.__data; } | ||
| 73 | }; | 81 | }; |
| 74 | 82 | ||
| 75 | } // namespace parallelism_v2 | 83 | } // namespace parallelism_v2 |
lib/libcxx/include/experimental/__simd/simd.h+11| ... | @@ -70,6 +70,17 @@ public: | ... | @@ -70,6 +70,17 @@ public: |
| 70 | _Impl::__load(__s_, _Flags::template __apply<simd>(__mem)); | 70 | _Impl::__load(__s_, _Flags::template __apply<simd>(__mem)); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | // copy functions | ||
| 74 | template <class _Up, class _Flags, enable_if_t<__is_vectorizable_v<_Up> && is_simd_flag_type_v<_Flags>, int> = 0> | ||
| 75 | _LIBCPP_HIDE_FROM_ABI void copy_from(const _Up* __mem, _Flags) { | ||
| 76 | _Impl::__load(__s_, _Flags::template __apply<simd>(__mem)); | ||
| 77 | } | ||
| 78 | |||
| 79 | template <class _Up, class _Flags, enable_if_t<__is_vectorizable_v<_Up> && is_simd_flag_type_v<_Flags>, int> = 0> | ||
| 80 | _LIBCPP_HIDE_FROM_ABI void copy_to(_Up* __mem, _Flags) const { | ||
| 81 | _Impl::__store(__s_, _Flags::template __apply<simd>(__mem)); | ||
| 82 | } | ||
| 83 | |||
| 73 | // scalar access [simd.subscr] | 84 | // scalar access [simd.subscr] |
| 74 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); } | 85 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); } |
| 75 | _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); } | 86 | _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); } |
lib/libcxx/include/experimental/__simd/simd_mask.h+11| ... | @@ -58,6 +58,17 @@ public: | ... | @@ -58,6 +58,17 @@ public: |
| 58 | _Impl::__load(__s_, _Flags::template __apply<simd_mask>(__mem)); | 58 | _Impl::__load(__s_, _Flags::template __apply<simd_mask>(__mem)); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | // copy functions | ||
| 62 | template <class _Flags, enable_if_t<is_simd_flag_type_v<_Flags>, int> = 0> | ||
| 63 | _LIBCPP_HIDE_FROM_ABI void copy_from(const value_type* __mem, _Flags) { | ||
| 64 | _Impl::__load(__s_, _Flags::template __apply<simd_mask>(__mem)); | ||
| 65 | } | ||
| 66 | |||
| 67 | template <class _Flags, enable_if_t<is_simd_flag_type_v<_Flags>, int> = 0> | ||
| 68 | _LIBCPP_HIDE_FROM_ABI void copy_to(value_type* __mem, _Flags) const { | ||
| 69 | _Impl::__store(__s_, _Flags::template __apply<simd_mask>(__mem)); | ||
| 70 | } | ||
| 71 | |||
| 61 | // scalar access [simd.mask.subscr] | 72 | // scalar access [simd.mask.subscr] |
| 62 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); } | 73 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); } |
| 63 | _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); } | 74 | _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); } |
lib/libcxx/include/experimental/__simd/vec_ext.h+12| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H |
| 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 13 | #include <__bit/bit_ceil.h> | 14 | #include <__bit/bit_ceil.h> |
| 14 | #include <__utility/forward.h> | 15 | #include <__utility/forward.h> |
| 15 | #include <__utility/integer_sequence.h> | 16 | #include <__utility/integer_sequence.h> |
| ... | @@ -79,6 +80,12 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> { | ... | @@ -79,6 +80,12 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> { |
| 79 | for (size_t __i = 0; __i < _Np; __i++) | 80 | for (size_t __i = 0; __i < _Np; __i++) |
| 80 | __s.__data[__i] = static_cast<_Tp>(__mem[__i]); | 81 | __s.__data[__i] = static_cast<_Tp>(__mem[__i]); |
| 81 | } | 82 | } |
| 83 | |||
| 84 | template <class _Up> | ||
| 85 | static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept { | ||
| 86 | for (size_t __i = 0; __i < _Np; __i++) | ||
| 87 | __mem[__i] = static_cast<_Up>(__s.__data[__i]); | ||
| 88 | } | ||
| 82 | }; | 89 | }; |
| 83 | 90 | ||
| 84 | template <class _Tp, int _Np> | 91 | template <class _Tp, int _Np> |
| ... | @@ -98,6 +105,11 @@ struct __mask_operations<_Tp, simd_abi::__vec_ext<_Np>> { | ... | @@ -98,6 +105,11 @@ struct __mask_operations<_Tp, simd_abi::__vec_ext<_Np>> { |
| 98 | for (size_t __i = 0; __i < _Np; __i++) | 105 | for (size_t __i = 0; __i < _Np; __i++) |
| 99 | __s.__data[__i] = experimental::__set_all_bits<_Tp>(__mem[__i]); | 106 | __s.__data[__i] = experimental::__set_all_bits<_Tp>(__mem[__i]); |
| 100 | } | 107 | } |
| 108 | |||
| 109 | static _LIBCPP_HIDE_FROM_ABI void __store(_MaskStorage __s, bool* __mem) noexcept { | ||
| 110 | for (size_t __i = 0; __i < _Np; __i++) | ||
| 111 | __mem[__i] = static_cast<bool>(__s.__data[__i]); | ||
| 112 | } | ||
| 101 | }; | 113 | }; |
| 102 | 114 | ||
| 103 | } // namespace parallelism_v2 | 115 | } // namespace parallelism_v2 |
lib/libcxx/include/experimental/iterator-1| ... | @@ -52,7 +52,6 @@ namespace std { | ... | @@ -52,7 +52,6 @@ namespace std { |
| 52 | 52 | ||
| 53 | */ | 53 | */ |
| 54 | 54 | ||
| 55 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 56 | #include <__memory/addressof.h> | 55 | #include <__memory/addressof.h> |
| 57 | #include <__type_traits/decay.h> | 56 | #include <__type_traits/decay.h> |
| 58 | #include <__utility/forward.h> | 57 | #include <__utility/forward.h> |
lib/libcxx/include/experimental/memory+5-1| ... | @@ -79,7 +79,7 @@ public: | ... | @@ -79,7 +79,7 @@ public: |
| 79 | _LIBCPP_HIDE_FROM_ABI constexpr observer_ptr(nullptr_t) noexcept : __ptr_(nullptr) {} | 79 | _LIBCPP_HIDE_FROM_ABI constexpr observer_ptr(nullptr_t) noexcept : __ptr_(nullptr) {} |
| 80 | _LIBCPP_HIDE_FROM_ABI constexpr explicit observer_ptr(element_type* __p) noexcept : __ptr_(__p) {} | 80 | _LIBCPP_HIDE_FROM_ABI constexpr explicit observer_ptr(element_type* __p) noexcept : __ptr_(__p) {} |
| 81 | 81 | ||
| 82 | template <class _W2, class = __enable_if_t<is_convertible<_W2*, _Wp*>::value>> | 82 | template <class _W2, __enable_if_t<is_convertible<_W2*, _Wp*>::value, int> = 0> |
| 83 | _LIBCPP_HIDE_FROM_ABI constexpr observer_ptr(observer_ptr<_W2> __other) noexcept : __ptr_(__other.get()) {} | 83 | _LIBCPP_HIDE_FROM_ABI constexpr observer_ptr(observer_ptr<_W2> __other) noexcept : __ptr_(__other.get()) {} |
| 84 | 84 | ||
| 85 | // observers | 85 | // observers |
| ... | @@ -191,4 +191,8 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -191,4 +191,8 @@ _LIBCPP_END_NAMESPACE_STD |
| 191 | 191 | ||
| 192 | #endif // _LIBCPP_ENABLE_EXPERIMENTAL | 192 | #endif // _LIBCPP_ENABLE_EXPERIMENTAL |
| 193 | 193 | ||
| 194 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 195 | # include <limits> | ||
| 196 | #endif | ||
| 197 | |||
| 194 | #endif /* _LIBCPP_EXPERIMENTAL_MEMORY */ | 198 | #endif /* _LIBCPP_EXPERIMENTAL_MEMORY */ |
lib/libcxx/include/experimental/propagate_const+54-63| ... | @@ -107,9 +107,8 @@ | ... | @@ -107,9 +107,8 @@ |
| 107 | 107 | ||
| 108 | */ | 108 | */ |
| 109 | 109 | ||
| 110 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 111 | #include <__functional/operations.h> | 110 | #include <__functional/operations.h> |
| 112 | #include <__fwd/hash.h> | 111 | #include <__fwd/functional.h> |
| 113 | #include <__type_traits/conditional.h> | 112 | #include <__type_traits/conditional.h> |
| 114 | #include <__type_traits/decay.h> | 113 | #include <__type_traits/decay.h> |
| 115 | #include <__type_traits/enable_if.h> | 114 | #include <__type_traits/enable_if.h> |
| ... | @@ -146,10 +145,10 @@ template <class _Tp> | ... | @@ -146,10 +145,10 @@ template <class _Tp> |
| 146 | class propagate_const; | 145 | class propagate_const; |
| 147 | 146 | ||
| 148 | template <class _Up> | 147 | template <class _Up> |
| 149 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; | 148 | inline _LIBCPP_HIDE_FROM_ABI constexpr const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; |
| 150 | 149 | ||
| 151 | template <class _Up> | 150 | template <class _Up> |
| 152 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; | 151 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; |
| 153 | 152 | ||
| 154 | template <class _Tp> | 153 | template <class _Tp> |
| 155 | class propagate_const { | 154 | class propagate_const { |
| ... | @@ -165,22 +164,22 @@ public: | ... | @@ -165,22 +164,22 @@ public: |
| 165 | 164 | ||
| 166 | private: | 165 | private: |
| 167 | template <class _Up> | 166 | template <class _Up> |
| 168 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) { | 167 | static _LIBCPP_HIDE_FROM_ABI constexpr element_type* __get_pointer(_Up* __u) { |
| 169 | return __u; | 168 | return __u; |
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | template <class _Up> | 171 | template <class _Up> |
| 173 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) { | 172 | static _LIBCPP_HIDE_FROM_ABI constexpr element_type* __get_pointer(_Up& __u) { |
| 174 | return __get_pointer(__u.get()); | 173 | return __get_pointer(__u.get()); |
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | template <class _Up> | 176 | template <class _Up> |
| 178 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) { | 177 | static _LIBCPP_HIDE_FROM_ABI constexpr const element_type* __get_pointer(const _Up* __u) { |
| 179 | return __u; | 178 | return __u; |
| 180 | } | 179 | } |
| 181 | 180 | ||
| 182 | template <class _Up> | 181 | template <class _Up> |
| 183 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) { | 182 | static _LIBCPP_HIDE_FROM_ABI constexpr const element_type* __get_pointer(const _Up& __u) { |
| 184 | return __get_pointer(__u.get()); | 183 | return __get_pointer(__u.get()); |
| 185 | } | 184 | } |
| 186 | 185 | ||
| ... | @@ -194,215 +193,207 @@ private: | ... | @@ -194,215 +193,207 @@ private: |
| 194 | 193 | ||
| 195 | public: | 194 | public: |
| 196 | template <class _Up> | 195 | template <class _Up> |
| 197 | friend _LIBCPP_CONSTEXPR const _Up& | 196 | friend constexpr const _Up& experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; |
| 198 | experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; | ||
| 199 | template <class _Up> | 197 | template <class _Up> |
| 200 | friend _LIBCPP_CONSTEXPR _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; | 198 | friend constexpr _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; |
| 201 | 199 | ||
| 202 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const() = default; | 200 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const() = default; |
| 203 | 201 | ||
| 204 | propagate_const(const propagate_const&) = delete; | 202 | propagate_const(const propagate_const&) = delete; |
| 205 | 203 | ||
| 206 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default; | 204 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(propagate_const&&) = default; |
| 207 | 205 | ||
| 208 | template <class _Up, | 206 | template <class _Up, |
| 209 | enable_if_t<!is_convertible<_Up, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = true> | 207 | enable_if_t<!is_convertible<_Up, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = true> |
| 210 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) | 208 | explicit _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(propagate_const<_Up>&& __pu) |
| 211 | : __t_(std::move(experimental::get_underlying(__pu))) {} | 209 | : __t_(std::move(experimental::get_underlying(__pu))) {} |
| 212 | 210 | ||
| 213 | template <class _Up, | 211 | template <class _Up, |
| 214 | enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = false> | 212 | enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = false> |
| 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) | 213 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(propagate_const<_Up>&& __pu) |
| 216 | : __t_(std::move(experimental::get_underlying(__pu))) {} | 214 | : __t_(std::move(experimental::get_underlying(__pu))) {} |
| 217 | 215 | ||
| 218 | template <class _Up, | 216 | template <class _Up, |
| 219 | enable_if_t<!is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value && | 217 | enable_if_t<!is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value && |
| 220 | !__is_propagate_const<decay_t<_Up>>::value, | 218 | !__is_propagate_const<decay_t<_Up>>::value, |
| 221 | bool> = true> | 219 | bool> = true> |
| 222 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {} | 220 | explicit _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {} |
| 223 | 221 | ||
| 224 | template <class _Up, | 222 | template <class _Up, |
| 225 | enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value && | 223 | enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value && |
| 226 | !__is_propagate_const<decay_t<_Up>>::value, | 224 | !__is_propagate_const<decay_t<_Up>>::value, |
| 227 | bool> = false> | 225 | bool> = false> |
| 228 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {} | 226 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {} |
| 229 | 227 | ||
| 230 | propagate_const& operator=(const propagate_const&) = delete; | 228 | propagate_const& operator=(const propagate_const&) = delete; |
| 231 | 229 | ||
| 232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default; | 230 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const& operator=(propagate_const&&) = default; |
| 233 | 231 | ||
| 234 | template <class _Up> | 232 | template <class _Up> |
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) { | 233 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const& operator=(propagate_const<_Up>&& __pu) { |
| 236 | __t_ = std::move(experimental::get_underlying(__pu)); | 234 | __t_ = std::move(experimental::get_underlying(__pu)); |
| 237 | return *this; | 235 | return *this; |
| 238 | } | 236 | } |
| 239 | 237 | ||
| 240 | template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>> | 238 | template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>> |
| 241 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) { | 239 | _LIBCPP_HIDE_FROM_ABI constexpr propagate_const& operator=(_Up&& __u) { |
| 242 | __t_ = std::forward<_Up>(__u); | 240 | __t_ = std::forward<_Up>(__u); |
| 243 | return *this; | 241 | return *this; |
| 244 | } | 242 | } |
| 245 | 243 | ||
| 246 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* get() const { return __get_pointer(__t_); } | 244 | _LIBCPP_HIDE_FROM_ABI constexpr const element_type* get() const { return __get_pointer(__t_); } |
| 247 | 245 | ||
| 248 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* get() { return __get_pointer(__t_); } | 246 | _LIBCPP_HIDE_FROM_ABI constexpr element_type* get() { return __get_pointer(__t_); } |
| 249 | 247 | ||
| 250 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR operator bool() const { return get() != nullptr; } | 248 | _LIBCPP_HIDE_FROM_ABI explicit constexpr operator bool() const { return get() != nullptr; } |
| 251 | 249 | ||
| 252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* operator->() const { return get(); } | 250 | _LIBCPP_HIDE_FROM_ABI constexpr const element_type* operator->() const { return get(); } |
| 253 | 251 | ||
| 254 | template <class _Dummy = _Tp, class _Up = enable_if_t<is_convertible< const _Dummy, const element_type*>::value>> | 252 | template <class _Dummy = _Tp, class _Up = enable_if_t<is_convertible< const _Dummy, const element_type*>::value>> |
| 255 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator const element_type*() const { | 253 | _LIBCPP_HIDE_FROM_ABI constexpr operator const element_type*() const { |
| 256 | return get(); | 254 | return get(); |
| 257 | } | 255 | } |
| 258 | 256 | ||
| 259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type& operator*() const { return *get(); } | 257 | _LIBCPP_HIDE_FROM_ABI constexpr const element_type& operator*() const { return *get(); } |
| 260 | 258 | ||
| 261 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* operator->() { return get(); } | 259 | _LIBCPP_HIDE_FROM_ABI constexpr element_type* operator->() { return get(); } |
| 262 | 260 | ||
| 263 | template <class _Dummy = _Tp, class _Up = enable_if_t< is_convertible<_Dummy, element_type*>::value>> | 261 | template <class _Dummy = _Tp, class _Up = enable_if_t< is_convertible<_Dummy, element_type*>::value>> |
| 264 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator element_type*() { | 262 | _LIBCPP_HIDE_FROM_ABI constexpr operator element_type*() { |
| 265 | return get(); | 263 | return get(); |
| 266 | } | 264 | } |
| 267 | 265 | ||
| 268 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type& operator*() { return *get(); } | 266 | _LIBCPP_HIDE_FROM_ABI constexpr element_type& operator*() { return *get(); } |
| 269 | 267 | ||
| 270 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const& __pt) | 268 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(propagate_const& __pt) noexcept(__is_nothrow_swappable_v<_Tp>) { |
| 271 | _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { | ||
| 272 | using std::swap; | 269 | using std::swap; |
| 273 | swap(__t_, __pt.__t_); | 270 | swap(__t_, __pt.__t_); |
| 274 | } | 271 | } |
| 275 | }; | 272 | }; |
| 276 | 273 | ||
| 277 | template <class _Tp> | 274 | template <class _Tp> |
| 278 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) { | 275 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) { |
| 279 | return experimental::get_underlying(__pt) == nullptr; | 276 | return experimental::get_underlying(__pt) == nullptr; |
| 280 | } | 277 | } |
| 281 | 278 | ||
| 282 | template <class _Tp> | 279 | template <class _Tp> |
| 283 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) { | 280 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) { |
| 284 | return nullptr == experimental::get_underlying(__pt); | 281 | return nullptr == experimental::get_underlying(__pt); |
| 285 | } | 282 | } |
| 286 | 283 | ||
| 287 | template <class _Tp> | 284 | template <class _Tp> |
| 288 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) { | 285 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) { |
| 289 | return experimental::get_underlying(__pt) != nullptr; | 286 | return experimental::get_underlying(__pt) != nullptr; |
| 290 | } | 287 | } |
| 291 | 288 | ||
| 292 | template <class _Tp> | 289 | template <class _Tp> |
| 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) { | 290 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) { |
| 294 | return nullptr != experimental::get_underlying(__pt); | 291 | return nullptr != experimental::get_underlying(__pt); |
| 295 | } | 292 | } |
| 296 | 293 | ||
| 297 | template <class _Tp, class _Up> | 294 | template <class _Tp, class _Up> |
| 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 295 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { |
| 299 | operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { | ||
| 300 | return experimental::get_underlying(__pt) == experimental::get_underlying(__pu); | 296 | return experimental::get_underlying(__pt) == experimental::get_underlying(__pu); |
| 301 | } | 297 | } |
| 302 | 298 | ||
| 303 | template <class _Tp, class _Up> | 299 | template <class _Tp, class _Up> |
| 304 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 300 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { |
| 305 | operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { | ||
| 306 | return experimental::get_underlying(__pt) != experimental::get_underlying(__pu); | 301 | return experimental::get_underlying(__pt) != experimental::get_underlying(__pu); |
| 307 | } | 302 | } |
| 308 | 303 | ||
| 309 | template <class _Tp, class _Up> | 304 | template <class _Tp, class _Up> |
| 310 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 305 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { |
| 311 | operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { | ||
| 312 | return experimental::get_underlying(__pt) < experimental::get_underlying(__pu); | 306 | return experimental::get_underlying(__pt) < experimental::get_underlying(__pu); |
| 313 | } | 307 | } |
| 314 | 308 | ||
| 315 | template <class _Tp, class _Up> | 309 | template <class _Tp, class _Up> |
| 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 310 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { |
| 317 | operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { | ||
| 318 | return experimental::get_underlying(__pt) > experimental::get_underlying(__pu); | 311 | return experimental::get_underlying(__pt) > experimental::get_underlying(__pu); |
| 319 | } | 312 | } |
| 320 | 313 | ||
| 321 | template <class _Tp, class _Up> | 314 | template <class _Tp, class _Up> |
| 322 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 315 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { |
| 323 | operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { | ||
| 324 | return experimental::get_underlying(__pt) <= experimental::get_underlying(__pu); | 316 | return experimental::get_underlying(__pt) <= experimental::get_underlying(__pu); |
| 325 | } | 317 | } |
| 326 | 318 | ||
| 327 | template <class _Tp, class _Up> | 319 | template <class _Tp, class _Up> |
| 328 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool | 320 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { |
| 329 | operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { | ||
| 330 | return experimental::get_underlying(__pt) >= experimental::get_underlying(__pu); | 321 | return experimental::get_underlying(__pt) >= experimental::get_underlying(__pu); |
| 331 | } | 322 | } |
| 332 | 323 | ||
| 333 | template <class _Tp, class _Up> | 324 | template <class _Tp, class _Up> |
| 334 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) { | 325 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) { |
| 335 | return experimental::get_underlying(__pt) == __u; | 326 | return experimental::get_underlying(__pt) == __u; |
| 336 | } | 327 | } |
| 337 | 328 | ||
| 338 | template <class _Tp, class _Up> | 329 | template <class _Tp, class _Up> |
| 339 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) { | 330 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) { |
| 340 | return experimental::get_underlying(__pt) != __u; | 331 | return experimental::get_underlying(__pt) != __u; |
| 341 | } | 332 | } |
| 342 | 333 | ||
| 343 | template <class _Tp, class _Up> | 334 | template <class _Tp, class _Up> |
| 344 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) { | 335 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) { |
| 345 | return experimental::get_underlying(__pt) < __u; | 336 | return experimental::get_underlying(__pt) < __u; |
| 346 | } | 337 | } |
| 347 | 338 | ||
| 348 | template <class _Tp, class _Up> | 339 | template <class _Tp, class _Up> |
| 349 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) { | 340 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) { |
| 350 | return experimental::get_underlying(__pt) > __u; | 341 | return experimental::get_underlying(__pt) > __u; |
| 351 | } | 342 | } |
| 352 | 343 | ||
| 353 | template <class _Tp, class _Up> | 344 | template <class _Tp, class _Up> |
| 354 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) { | 345 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) { |
| 355 | return experimental::get_underlying(__pt) <= __u; | 346 | return experimental::get_underlying(__pt) <= __u; |
| 356 | } | 347 | } |
| 357 | 348 | ||
| 358 | template <class _Tp, class _Up> | 349 | template <class _Tp, class _Up> |
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) { | 350 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) { |
| 360 | return experimental::get_underlying(__pt) >= __u; | 351 | return experimental::get_underlying(__pt) >= __u; |
| 361 | } | 352 | } |
| 362 | 353 | ||
| 363 | template <class _Tp, class _Up> | 354 | template <class _Tp, class _Up> |
| 364 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) { | 355 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) { |
| 365 | return __t == experimental::get_underlying(__pu); | 356 | return __t == experimental::get_underlying(__pu); |
| 366 | } | 357 | } |
| 367 | 358 | ||
| 368 | template <class _Tp, class _Up> | 359 | template <class _Tp, class _Up> |
| 369 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) { | 360 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) { |
| 370 | return __t != experimental::get_underlying(__pu); | 361 | return __t != experimental::get_underlying(__pu); |
| 371 | } | 362 | } |
| 372 | 363 | ||
| 373 | template <class _Tp, class _Up> | 364 | template <class _Tp, class _Up> |
| 374 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) { | 365 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) { |
| 375 | return __t < experimental::get_underlying(__pu); | 366 | return __t < experimental::get_underlying(__pu); |
| 376 | } | 367 | } |
| 377 | 368 | ||
| 378 | template <class _Tp, class _Up> | 369 | template <class _Tp, class _Up> |
| 379 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) { | 370 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) { |
| 380 | return __t > experimental::get_underlying(__pu); | 371 | return __t > experimental::get_underlying(__pu); |
| 381 | } | 372 | } |
| 382 | 373 | ||
| 383 | template <class _Tp, class _Up> | 374 | template <class _Tp, class _Up> |
| 384 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) { | 375 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) { |
| 385 | return __t <= experimental::get_underlying(__pu); | 376 | return __t <= experimental::get_underlying(__pu); |
| 386 | } | 377 | } |
| 387 | 378 | ||
| 388 | template <class _Tp, class _Up> | 379 | template <class _Tp, class _Up> |
| 389 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) { | 380 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) { |
| 390 | return __t >= experimental::get_underlying(__pu); | 381 | return __t >= experimental::get_underlying(__pu); |
| 391 | } | 382 | } |
| 392 | 383 | ||
| 393 | template <class _Tp> | 384 | template <class _Tp> |
| 394 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) | 385 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 395 | _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { | 386 | swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) noexcept(__is_nothrow_swappable_v<_Tp>) { |
| 396 | __pc1.swap(__pc2); | 387 | __pc1.swap(__pc2); |
| 397 | } | 388 | } |
| 398 | 389 | ||
| 399 | template <class _Tp> | 390 | template <class _Tp> |
| 400 | _LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT { | 391 | constexpr const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT { |
| 401 | return __pt.__t_; | 392 | return __pt.__t_; |
| 402 | } | 393 | } |
| 403 | 394 | ||
| 404 | template <class _Tp> | 395 | template <class _Tp> |
| 405 | _LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT { | 396 | constexpr _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT { |
| 406 | return __pt.__t_; | 397 | return __pt.__t_; |
| 407 | } | 398 | } |
| 408 | 399 |
lib/libcxx/include/experimental/simd+1-2| ... | @@ -71,8 +71,6 @@ inline namespace parallelism_v2 { | ... | @@ -71,8 +71,6 @@ inline namespace parallelism_v2 { |
| 71 | 71 | ||
| 72 | */ | 72 | */ |
| 73 | 73 | ||
| 74 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 75 | |||
| 76 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 74 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 77 | # pragma GCC system_header | 75 | # pragma GCC system_header |
| 78 | #endif | 76 | #endif |
| ... | @@ -80,6 +78,7 @@ inline namespace parallelism_v2 { | ... | @@ -80,6 +78,7 @@ inline namespace parallelism_v2 { |
| 80 | #include <experimental/__config> | 78 | #include <experimental/__config> |
| 81 | #include <experimental/__simd/aligned_tag.h> | 79 | #include <experimental/__simd/aligned_tag.h> |
| 82 | #include <experimental/__simd/declaration.h> | 80 | #include <experimental/__simd/declaration.h> |
| 81 | #include <experimental/__simd/reference.h> | ||
| 83 | #include <experimental/__simd/scalar.h> | 82 | #include <experimental/__simd/scalar.h> |
| 84 | #include <experimental/__simd/simd.h> | 83 | #include <experimental/__simd/simd.h> |
| 85 | #include <experimental/__simd/simd_mask.h> | 84 | #include <experimental/__simd/simd_mask.h> |
lib/libcxx/include/experimental/type_traits+3-4| ... | @@ -68,7 +68,6 @@ inline namespace fundamentals_v1 { | ... | @@ -68,7 +68,6 @@ inline namespace fundamentals_v1 { |
| 68 | 68 | ||
| 69 | */ | 69 | */ |
| 70 | 70 | ||
| 71 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 72 | #include <experimental/__config> | 71 | #include <experimental/__config> |
| 73 | 72 | ||
| 74 | #if _LIBCPP_STD_VER >= 14 | 73 | #if _LIBCPP_STD_VER >= 14 |
| ... | @@ -130,7 +129,7 @@ using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t; | ... | @@ -130,7 +129,7 @@ using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t; |
| 130 | template <template <class...> class _Op, class... _Args> | 129 | template <template <class...> class _Op, class... _Args> |
| 131 | using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type; | 130 | using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type; |
| 132 | template <template <class...> class _Op, class... _Args> | 131 | template <template <class...> class _Op, class... _Args> |
| 133 | _LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value; | 132 | constexpr bool is_detected_v = is_detected<_Op, _Args...>::value; |
| 134 | 133 | ||
| 135 | template <class _Default, template <class...> class _Op, class... _Args> | 134 | template <class _Default, template <class...> class _Op, class... _Args> |
| 136 | using detected_or = _DETECTOR<_Default, void, _Op, _Args...>; | 135 | using detected_or = _DETECTOR<_Default, void, _Op, _Args...>; |
| ... | @@ -140,12 +139,12 @@ using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; | ... | @@ -140,12 +139,12 @@ using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; |
| 140 | template <class _Expected, template <class...> class _Op, class... _Args> | 139 | template <class _Expected, template <class...> class _Op, class... _Args> |
| 141 | using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; | 140 | using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; |
| 142 | template <class _Expected, template <class...> class _Op, class... _Args> | 141 | template <class _Expected, template <class...> class _Op, class... _Args> |
| 143 | _LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value; | 142 | constexpr bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value; |
| 144 | 143 | ||
| 145 | template <class _To, template <class...> class _Op, class... _Args> | 144 | template <class _To, template <class...> class _Op, class... _Args> |
| 146 | using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, _To>; | 145 | using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, _To>; |
| 147 | template <class _To, template <class...> class _Op, class... _Args> | 146 | template <class _To, template <class...> class _Op, class... _Args> |
| 148 | _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value; | 147 | constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value; |
| 149 | 148 | ||
| 150 | _LIBCPP_END_NAMESPACE_LFTS | 149 | _LIBCPP_END_NAMESPACE_LFTS |
| 151 | 150 |
lib/libcxx/include/experimental/utility-1| ... | @@ -30,7 +30,6 @@ inline namespace fundamentals_v1 { | ... | @@ -30,7 +30,6 @@ inline namespace fundamentals_v1 { |
| 30 | 30 | ||
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 34 | #include <experimental/__config> | 33 | #include <experimental/__config> |
| 35 | #include <utility> | 34 | #include <utility> |
| 36 | 35 |
lib/libcxx/include/ext/hash_map-1| ... | @@ -201,7 +201,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc> | ... | @@ -201,7 +201,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 201 | 201 | ||
| 202 | */ | 202 | */ |
| 203 | 203 | ||
| 204 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 205 | #include <__config> | 204 | #include <__config> |
| 206 | #include <__hash_table> | 205 | #include <__hash_table> |
| 207 | #include <algorithm> | 206 | #include <algorithm> |
lib/libcxx/include/ext/hash_set-1| ... | @@ -192,7 +192,6 @@ template <class Value, class Hash, class Pred, class Alloc> | ... | @@ -192,7 +192,6 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 192 | 192 | ||
| 193 | */ | 193 | */ |
| 194 | 194 | ||
| 195 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 196 | #include <__config> | 195 | #include <__config> |
| 197 | #include <__hash_table> | 196 | #include <__hash_table> |
| 198 | #include <algorithm> | 197 | #include <algorithm> |
lib/libcxx/include/filesystem+21-17| ... | @@ -533,24 +533,27 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct | ... | @@ -533,24 +533,27 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct |
| 533 | 533 | ||
| 534 | */ | 534 | */ |
| 535 | 535 | ||
| 536 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 537 | #include <__config> | 536 | #include <__config> |
| 538 | #include <__filesystem/copy_options.h> | 537 | |
| 539 | #include <__filesystem/directory_entry.h> | 538 | #if _LIBCPP_STD_VER >= 17 |
| 540 | #include <__filesystem/directory_iterator.h> | 539 | # include <__filesystem/copy_options.h> |
| 541 | #include <__filesystem/directory_options.h> | 540 | # include <__filesystem/directory_entry.h> |
| 542 | #include <__filesystem/file_status.h> | 541 | # include <__filesystem/directory_iterator.h> |
| 543 | #include <__filesystem/file_time_type.h> | 542 | # include <__filesystem/directory_options.h> |
| 544 | #include <__filesystem/file_type.h> | 543 | # include <__filesystem/file_status.h> |
| 545 | #include <__filesystem/filesystem_error.h> | 544 | # include <__filesystem/file_time_type.h> |
| 546 | #include <__filesystem/operations.h> | 545 | # include <__filesystem/file_type.h> |
| 547 | #include <__filesystem/path.h> | 546 | # include <__filesystem/filesystem_error.h> |
| 548 | #include <__filesystem/path_iterator.h> | 547 | # include <__filesystem/operations.h> |
| 549 | #include <__filesystem/perm_options.h> | 548 | # include <__filesystem/path.h> |
| 550 | #include <__filesystem/perms.h> | 549 | # include <__filesystem/path_iterator.h> |
| 551 | #include <__filesystem/recursive_directory_iterator.h> | 550 | # include <__filesystem/perm_options.h> |
| 552 | #include <__filesystem/space_info.h> | 551 | # include <__filesystem/perms.h> |
| 553 | #include <__filesystem/u8path.h> | 552 | # include <__filesystem/recursive_directory_iterator.h> |
| 553 | # include <__filesystem/space_info.h> | ||
| 554 | # include <__filesystem/u8path.h> | ||
| 555 | #endif | ||
| 556 | |||
| 554 | #include <version> | 557 | #include <version> |
| 555 | 558 | ||
| 556 | // standard-mandated includes | 559 | // standard-mandated includes |
| ... | @@ -565,6 +568,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct | ... | @@ -565,6 +568,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct |
| 565 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 568 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 566 | # include <concepts> | 569 | # include <concepts> |
| 567 | # include <cstdlib> | 570 | # include <cstdlib> |
| 571 | # include <cstring> | ||
| 568 | # include <iosfwd> | 572 | # include <iosfwd> |
| 569 | # include <new> | 573 | # include <new> |
| 570 | # include <system_error> | 574 | # include <system_error> |
lib/libcxx/include/format+60-28| ... | @@ -170,7 +170,7 @@ namespace std { | ... | @@ -170,7 +170,7 @@ namespace std { |
| 170 | template<class Context> class basic_format_arg; | 170 | template<class Context> class basic_format_arg; |
| 171 | 171 | ||
| 172 | template<class Visitor, class Context> | 172 | template<class Visitor, class Context> |
| 173 | see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); | 173 | see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // Deprecated in C++26 |
| 174 | 174 | ||
| 175 | // [format.arg.store], class template format-arg-store | 175 | // [format.arg.store], class template format-arg-store |
| 176 | template<class Context, class... Args> struct format-arg-store; // exposition only | 176 | template<class Context, class... Args> struct format-arg-store; // exposition only |
| ... | @@ -188,38 +188,70 @@ namespace std { | ... | @@ -188,38 +188,70 @@ namespace std { |
| 188 | 188 | ||
| 189 | */ | 189 | */ |
| 190 | 190 | ||
| 191 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 192 | #include <__config> | 191 | #include <__config> |
| 193 | #include <__format/buffer.h> | 192 | |
| 194 | #include <__format/concepts.h> | 193 | #if _LIBCPP_STD_VER >= 20 |
| 195 | #include <__format/container_adaptor.h> | 194 | # include <__format/buffer.h> |
| 196 | #include <__format/enable_insertable.h> | 195 | # include <__format/concepts.h> |
| 197 | #include <__format/format_arg.h> | 196 | # include <__format/container_adaptor.h> |
| 198 | #include <__format/format_arg_store.h> | 197 | # include <__format/enable_insertable.h> |
| 199 | #include <__format/format_args.h> | 198 | # include <__format/escaped_output_table.h> |
| 200 | #include <__format/format_context.h> | 199 | # include <__format/extended_grapheme_cluster_table.h> |
| 201 | #include <__format/format_error.h> | 200 | # include <__format/format_arg.h> |
| 202 | #include <__format/format_functions.h> | 201 | # include <__format/format_arg_store.h> |
| 203 | #include <__format/format_fwd.h> | 202 | # include <__format/format_args.h> |
| 204 | #include <__format/format_parse_context.h> | 203 | # include <__format/format_context.h> |
| 205 | #include <__format/format_string.h> | 204 | # include <__format/format_error.h> |
| 206 | #include <__format/format_to_n_result.h> | 205 | # include <__format/format_functions.h> |
| 207 | #include <__format/formatter.h> | 206 | # include <__format/format_parse_context.h> |
| 208 | #include <__format/formatter_bool.h> | 207 | # include <__format/format_string.h> |
| 209 | #include <__format/formatter_char.h> | 208 | # include <__format/format_to_n_result.h> |
| 210 | #include <__format/formatter_floating_point.h> | 209 | # include <__format/formatter.h> |
| 211 | #include <__format/formatter_integer.h> | 210 | # include <__format/formatter_bool.h> |
| 212 | #include <__format/formatter_pointer.h> | 211 | # include <__format/formatter_char.h> |
| 213 | #include <__format/formatter_string.h> | 212 | # include <__format/formatter_floating_point.h> |
| 214 | #include <__format/formatter_tuple.h> | 213 | # include <__format/formatter_integer.h> |
| 215 | #include <__format/parser_std_format_spec.h> | 214 | # include <__format/formatter_pointer.h> |
| 216 | #include <__format/range_default_formatter.h> | 215 | # include <__format/formatter_string.h> |
| 217 | #include <__format/range_formatter.h> | 216 | # include <__format/formatter_tuple.h> |
| 218 | #include <__format/unicode.h> | 217 | # include <__format/parser_std_format_spec.h> |
| 218 | # include <__format/range_default_formatter.h> | ||
| 219 | # include <__format/range_formatter.h> | ||
| 220 | # include <__format/unicode.h> | ||
| 221 | # include <__fwd/format.h> | ||
| 222 | #endif | ||
| 223 | |||
| 219 | #include <version> | 224 | #include <version> |
| 220 | 225 | ||
| 221 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 226 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 222 | # pragma GCC system_header | 227 | # pragma GCC system_header |
| 223 | #endif | 228 | #endif |
| 224 | 229 | ||
| 230 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 231 | # include <array> | ||
| 232 | # include <cctype> | ||
| 233 | # include <cerrno> | ||
| 234 | # include <clocale> | ||
| 235 | # include <cmath> | ||
| 236 | # include <cstddef> | ||
| 237 | # include <cstdint> | ||
| 238 | # include <cstdlib> | ||
| 239 | # include <cstring> | ||
| 240 | # include <cwchar> | ||
| 241 | # include <initializer_list> | ||
| 242 | # include <limits> | ||
| 243 | # include <new> | ||
| 244 | # include <optional> | ||
| 245 | # include <stdexcept> | ||
| 246 | # include <string> | ||
| 247 | # include <string_view> | ||
| 248 | # include <tuple> | ||
| 249 | #endif | ||
| 250 | |||
| 251 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 252 | # include <locale> | ||
| 253 | # include <queue> | ||
| 254 | # include <stack> | ||
| 255 | #endif | ||
| 256 | |||
| 225 | #endif // _LIBCPP_FORMAT | 257 | #endif // _LIBCPP_FORMAT |
lib/libcxx/include/forward_list+34-53| ... | @@ -199,8 +199,6 @@ template <class T, class Allocator, class Predicate> | ... | @@ -199,8 +199,6 @@ template <class T, class Allocator, class Predicate> |
| 199 | #include <__algorithm/lexicographical_compare.h> | 199 | #include <__algorithm/lexicographical_compare.h> |
| 200 | #include <__algorithm/lexicographical_compare_three_way.h> | 200 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 201 | #include <__algorithm/min.h> | 201 | #include <__algorithm/min.h> |
| 202 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 203 | #include <__availability> | ||
| 204 | #include <__config> | 202 | #include <__config> |
| 205 | #include <__iterator/distance.h> | 203 | #include <__iterator/distance.h> |
| 206 | #include <__iterator/iterator_traits.h> | 204 | #include <__iterator/iterator_traits.h> |
| ... | @@ -222,11 +220,11 @@ template <class T, class Allocator, class Predicate> | ... | @@ -222,11 +220,11 @@ template <class T, class Allocator, class Predicate> |
| 222 | #include <__type_traits/conditional.h> | 220 | #include <__type_traits/conditional.h> |
| 223 | #include <__type_traits/is_allocator.h> | 221 | #include <__type_traits/is_allocator.h> |
| 224 | #include <__type_traits/is_const.h> | 222 | #include <__type_traits/is_const.h> |
| 225 | #include <__type_traits/is_nothrow_default_constructible.h> | 223 | #include <__type_traits/is_nothrow_assignable.h> |
| 226 | #include <__type_traits/is_nothrow_move_assignable.h> | 224 | #include <__type_traits/is_nothrow_constructible.h> |
| 227 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 228 | #include <__type_traits/is_pointer.h> | 225 | #include <__type_traits/is_pointer.h> |
| 229 | #include <__type_traits/is_same.h> | 226 | #include <__type_traits/is_same.h> |
| 227 | #include <__type_traits/is_swappable.h> | ||
| 230 | #include <__type_traits/type_identity.h> | 228 | #include <__type_traits/type_identity.h> |
| 231 | #include <__utility/forward.h> | 229 | #include <__utility/forward.h> |
| 232 | #include <__utility/move.h> | 230 | #include <__utility/move.h> |
| ... | @@ -410,7 +408,7 @@ public: | ... | @@ -410,7 +408,7 @@ public: |
| 410 | 408 | ||
| 411 | template <class _NodeConstPtr> | 409 | template <class _NodeConstPtr> |
| 412 | class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator { | 410 | class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator { |
| 413 | static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), ""); | 411 | static_assert(!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value, ""); |
| 414 | typedef _NodeConstPtr _NodePtr; | 412 | typedef _NodeConstPtr _NodePtr; |
| 415 | 413 | ||
| 416 | typedef __forward_node_traits<_NodePtr> __traits; | 414 | typedef __forward_node_traits<_NodePtr> __traits; |
| ... | @@ -513,19 +511,17 @@ protected: | ... | @@ -513,19 +511,17 @@ protected: |
| 513 | : __before_begin_(__begin_node(), __node_allocator(__a)) {} | 511 | : __before_begin_(__begin_node(), __node_allocator(__a)) {} |
| 514 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a) | 512 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a) |
| 515 | : __before_begin_(__begin_node(), __a) {} | 513 | : __before_begin_(__begin_node(), __a) {} |
| 516 | #ifndef _LIBCPP_CXX03_LANG | ||
| 517 | 514 | ||
| 518 | public: | 515 | public: |
| 519 | _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x) | 516 | #ifndef _LIBCPP_CXX03_LANG |
| 520 | _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); | 517 | _LIBCPP_HIDE_FROM_ABI |
| 518 | __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value); | ||
| 521 | _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); | 519 | _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); |
| 522 | #endif // _LIBCPP_CXX03_LANG | 520 | #endif // _LIBCPP_CXX03_LANG |
| 523 | 521 | ||
| 524 | private: | 522 | __forward_list_base(const __forward_list_base&) = delete; |
| 525 | __forward_list_base(const __forward_list_base&); | 523 | __forward_list_base& operator=(const __forward_list_base&) = delete; |
| 526 | __forward_list_base& operator=(const __forward_list_base&); | ||
| 527 | 524 | ||
| 528 | public: | ||
| 529 | _LIBCPP_HIDE_FROM_ABI ~__forward_list_base(); | 525 | _LIBCPP_HIDE_FROM_ABI ~__forward_list_base(); |
| 530 | 526 | ||
| 531 | protected: | 527 | protected: |
| ... | @@ -556,7 +552,6 @@ protected: | ... | @@ -556,7 +552,6 @@ protected: |
| 556 | return __guard.__release_ptr(); | 552 | return __guard.__release_ptr(); |
| 557 | } | 553 | } |
| 558 | 554 | ||
| 559 | template <class... _Args> | ||
| 560 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { | 555 | _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, | 556 | // For the same reason as above, we use the allocator's destroy() method for the value_type, |
| 562 | // but not for the node itself. | 557 | // but not for the node itself. |
| ... | @@ -571,7 +566,7 @@ public: | ... | @@ -571,7 +566,7 @@ public: |
| 571 | #if _LIBCPP_STD_VER >= 14 | 566 | #if _LIBCPP_STD_VER >= 14 |
| 572 | _NOEXCEPT; | 567 | _NOEXCEPT; |
| 573 | #else | 568 | #else |
| 574 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value); | 569 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>); |
| 575 | #endif | 570 | #endif |
| 576 | 571 | ||
| 577 | protected: | 572 | protected: |
| ... | @@ -595,8 +590,8 @@ private: | ... | @@ -595,8 +590,8 @@ private: |
| 595 | #ifndef _LIBCPP_CXX03_LANG | 590 | #ifndef _LIBCPP_CXX03_LANG |
| 596 | 591 | ||
| 597 | template <class _Tp, class _Alloc> | 592 | template <class _Tp, class _Alloc> |
| 598 | inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) | 593 | inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept( |
| 599 | _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value) | 594 | is_nothrow_move_constructible<__node_allocator>::value) |
| 600 | : __before_begin_(std::move(__x.__before_begin_)) { | 595 | : __before_begin_(std::move(__x.__before_begin_)) { |
| 601 | __x.__before_begin()->__next_ = nullptr; | 596 | __x.__before_begin()->__next_ = nullptr; |
| 602 | } | 597 | } |
| ... | @@ -622,7 +617,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) | ... | @@ -622,7 +617,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) |
| 622 | #if _LIBCPP_STD_VER >= 14 | 617 | #if _LIBCPP_STD_VER >= 14 |
| 623 | _NOEXCEPT | 618 | _NOEXCEPT |
| 624 | #else | 619 | #else |
| 625 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) | 620 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) |
| 626 | #endif | 621 | #endif |
| 627 | { | 622 | { |
| 628 | std::__swap_allocator( | 623 | std::__swap_allocator( |
| ... | @@ -654,16 +649,13 @@ public: | ... | @@ -654,16 +649,13 @@ public: |
| 654 | typedef _Tp value_type; | 649 | typedef _Tp value_type; |
| 655 | typedef _Alloc allocator_type; | 650 | typedef _Alloc allocator_type; |
| 656 | 651 | ||
| 652 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | ||
| 653 | |||
| 657 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, | 654 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, |
| 658 | "Allocator::value_type must be same type as value_type"); | 655 | "Allocator::value_type must be same type as value_type"); |
| 659 | 656 | ||
| 660 | static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value, | 657 | static_assert(!is_same<allocator_type, __node_allocator>::value, |
| 661 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | 658 | "internal allocator type must differ from user-specified type; otherwise overload resolution breaks"); |
| 662 | "original allocator"); | ||
| 663 | |||
| 664 | static_assert((!is_same<allocator_type, __node_allocator>::value), | ||
| 665 | "internal allocator type must differ from user-specified " | ||
| 666 | "type; otherwise overload resolution breaks"); | ||
| 667 | 659 | ||
| 668 | typedef value_type& reference; | 660 | typedef value_type& reference; |
| 669 | typedef const value_type& const_reference; | 661 | typedef const value_type& const_reference; |
| ... | @@ -689,22 +681,16 @@ public: | ... | @@ -689,22 +681,16 @@ public: |
| 689 | #endif | 681 | #endif |
| 690 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); | 682 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); |
| 691 | 683 | ||
| 692 | template <class = __enable_if_t<__is_allocator<_Alloc>::value> > | 684 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 693 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) { | 685 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) { |
| 694 | insert_after(cbefore_begin(), __n, __v); | 686 | insert_after(cbefore_begin(), __n, __v); |
| 695 | } | 687 | } |
| 696 | 688 | ||
| 697 | template <class _InputIterator> | 689 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 698 | _LIBCPP_HIDE_FROM_ABI | 690 | _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l); |
| 699 | forward_list(_InputIterator __f, | 691 | |
| 700 | _InputIterator __l, | 692 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 701 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value>* = nullptr); | 693 | _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a); |
| 702 | template <class _InputIterator> | ||
| 703 | _LIBCPP_HIDE_FROM_ABI | ||
| 704 | forward_list(_InputIterator __f, | ||
| 705 | _InputIterator __l, | ||
| 706 | const allocator_type& __a, | ||
| 707 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value>* = nullptr); | ||
| 708 | 694 | ||
| 709 | #if _LIBCPP_STD_VER >= 23 | 695 | #if _LIBCPP_STD_VER >= 23 |
| 710 | template <_ContainerCompatibleRange<_Tp> _Range> | 696 | template <_ContainerCompatibleRange<_Tp> _Range> |
| ... | @@ -720,15 +706,16 @@ public: | ... | @@ -720,15 +706,16 @@ public: |
| 720 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x); | 706 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x); |
| 721 | 707 | ||
| 722 | #ifndef _LIBCPP_CXX03_LANG | 708 | #ifndef _LIBCPP_CXX03_LANG |
| 723 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) _NOEXCEPT_(is_nothrow_move_constructible<base>::value) | 709 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<base>::value) |
| 724 | : base(std::move(__x)) {} | 710 | : base(std::move(__x)) {} |
| 725 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a); | 711 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a); |
| 726 | 712 | ||
| 727 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il); | 713 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il); |
| 728 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il, const allocator_type& __a); | 714 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il, const allocator_type& __a); |
| 729 | 715 | ||
| 730 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) _NOEXCEPT_( | 716 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept( |
| 731 | __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<allocator_type>::value); | 717 | __node_traits::propagate_on_container_move_assignment::value && |
| 718 | is_nothrow_move_assignable<allocator_type>::value); | ||
| 732 | 719 | ||
| 733 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il); | 720 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il); |
| 734 | 721 | ||
| ... | @@ -769,7 +756,7 @@ public: | ... | @@ -769,7 +756,7 @@ public: |
| 769 | return const_iterator(base::__before_begin()); | 756 | return const_iterator(base::__before_begin()); |
| 770 | } | 757 | } |
| 771 | 758 | ||
| 772 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | 759 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 773 | return base::__before_begin()->__next_ == nullptr; | 760 | return base::__before_begin()->__next_ == nullptr; |
| 774 | } | 761 | } |
| 775 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 762 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| ... | @@ -831,7 +818,7 @@ public: | ... | @@ -831,7 +818,7 @@ public: |
| 831 | #if _LIBCPP_STD_VER >= 14 | 818 | #if _LIBCPP_STD_VER >= 14 |
| 832 | _NOEXCEPT | 819 | _NOEXCEPT |
| 833 | #else | 820 | #else |
| 834 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) | 821 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) |
| 835 | #endif | 822 | #endif |
| 836 | { | 823 | { |
| 837 | base::swap(__x); | 824 | base::swap(__x); |
| ... | @@ -938,20 +925,14 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { | ... | @@ -938,20 +925,14 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { |
| 938 | } | 925 | } |
| 939 | 926 | ||
| 940 | template <class _Tp, class _Alloc> | 927 | template <class _Tp, class _Alloc> |
| 941 | template <class _InputIterator> | 928 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 942 | forward_list<_Tp, _Alloc>::forward_list( | 929 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) { |
| 943 | _InputIterator __f, _InputIterator __l, __enable_if_t<__has_input_iterator_category<_InputIterator>::value>*) { | ||
| 944 | insert_after(cbefore_begin(), __f, __l); | 930 | insert_after(cbefore_begin(), __f, __l); |
| 945 | } | 931 | } |
| 946 | 932 | ||
| 947 | template <class _Tp, class _Alloc> | 933 | template <class _Tp, class _Alloc> |
| 948 | template <class _InputIterator> | 934 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 949 | forward_list<_Tp, _Alloc>::forward_list( | 935 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : base(__a) { |
| 950 | _InputIterator __f, | ||
| 951 | _InputIterator __l, | ||
| 952 | const allocator_type& __a, | ||
| 953 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value>*) | ||
| 954 | : base(__a) { | ||
| 955 | insert_after(cbefore_begin(), __f, __l); | 936 | insert_after(cbefore_begin(), __f, __l); |
| 956 | } | 937 | } |
| 957 | 938 | ||
| ... | @@ -1538,7 +1519,7 @@ template <class _Tp, class _Allocator> | ... | @@ -1538,7 +1519,7 @@ template <class _Tp, class _Allocator> |
| 1538 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> | 1519 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 1539 | operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) { | 1520 | operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) { |
| 1540 | return std::lexicographical_compare_three_way( | 1521 | return std::lexicographical_compare_three_way( |
| 1541 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>); | 1522 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1542 | } | 1523 | } |
| 1543 | 1524 | ||
| 1544 | #endif // #if _LIBCPP_STD_VER <= 17 | 1525 | #endif // #if _LIBCPP_STD_VER <= 17 |
lib/libcxx/include/fstream+173-135| ... | @@ -78,8 +78,8 @@ public: | ... | @@ -78,8 +78,8 @@ public: |
| 78 | basic_ifstream(); | 78 | basic_ifstream(); |
| 79 | explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); | 79 | explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); |
| 80 | explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in); | 80 | explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in); |
| 81 | explicit basic_ifstream(const filesystem::path& p, | 81 | template<class T> |
| 82 | ios_base::openmode mode = ios_base::in); // C++17 | 82 | explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17 |
| 83 | basic_ifstream(basic_ifstream&& rhs); | 83 | basic_ifstream(basic_ifstream&& rhs); |
| 84 | 84 | ||
| 85 | basic_ifstream& operator=(basic_ifstream&& rhs); | 85 | basic_ifstream& operator=(basic_ifstream&& rhs); |
| ... | @@ -117,8 +117,8 @@ public: | ... | @@ -117,8 +117,8 @@ public: |
| 117 | basic_ofstream(); | 117 | basic_ofstream(); |
| 118 | explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out); | 118 | explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out); |
| 119 | explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out); | 119 | explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out); |
| 120 | explicit basic_ofstream(const filesystem::path& p, | 120 | template<class T> |
| 121 | ios_base::openmode mode = ios_base::out); // C++17 | 121 | explicit basic_ofstream(const T& s, ios_base::openmode mode = ios_base::out); // Since C++17 |
| 122 | basic_ofstream(basic_ofstream&& rhs); | 122 | basic_ofstream(basic_ofstream&& rhs); |
| 123 | 123 | ||
| 124 | basic_ofstream& operator=(basic_ofstream&& rhs); | 124 | basic_ofstream& operator=(basic_ofstream&& rhs); |
| ... | @@ -158,8 +158,8 @@ public: | ... | @@ -158,8 +158,8 @@ public: |
| 158 | basic_fstream(); | 158 | basic_fstream(); |
| 159 | explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out); | 159 | explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out); |
| 160 | explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); | 160 | explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); |
| 161 | explicit basic_fstream(const filesystem::path& p, | 161 | template<class T> |
| 162 | ios_base::openmode mode = ios_base::in|ios_base::out); C++17 | 162 | explicit basic_fstream(const T& s, ios_base::openmode mode = ios_base::in | ios_base::out); // Since C++17 |
| 163 | basic_fstream(basic_fstream&& rhs); | 163 | basic_fstream(basic_fstream&& rhs); |
| 164 | 164 | ||
| 165 | basic_fstream& operator=(basic_fstream&& rhs); | 165 | basic_fstream& operator=(basic_fstream&& rhs); |
| ... | @@ -187,11 +187,12 @@ typedef basic_fstream<wchar_t> wfstream; | ... | @@ -187,11 +187,12 @@ typedef basic_fstream<wchar_t> wfstream; |
| 187 | */ | 187 | */ |
| 188 | 188 | ||
| 189 | #include <__algorithm/max.h> | 189 | #include <__algorithm/max.h> |
| 190 | #include <__assert> // all public C++ headers provide the assertion handler | 190 | #include <__assert> |
| 191 | #include <__availability> | ||
| 192 | #include <__config> | 191 | #include <__config> |
| 193 | #include <__fwd/fstream.h> | 192 | #include <__fwd/fstream.h> |
| 194 | #include <__locale> | 193 | #include <__locale> |
| 194 | #include <__type_traits/enable_if.h> | ||
| 195 | #include <__type_traits/is_same.h> | ||
| 195 | #include <__utility/move.h> | 196 | #include <__utility/move.h> |
| 196 | #include <__utility/swap.h> | 197 | #include <__utility/swap.h> |
| 197 | #include <__utility/unreachable.h> | 198 | #include <__utility/unreachable.h> |
| ... | @@ -279,6 +280,9 @@ public: | ... | @@ -279,6 +280,9 @@ public: |
| 279 | # endif // _LIBCPP_STD_VER >= 26 | 280 | # endif // _LIBCPP_STD_VER >= 26 |
| 280 | 281 | ||
| 281 | _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT; | 282 | _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT; |
| 283 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | ||
| 284 | _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT; | ||
| 285 | # endif | ||
| 282 | 286 | ||
| 283 | protected: | 287 | protected: |
| 284 | // 27.9.1.5 Overridden virtual functions: | 288 | // 27.9.1.5 Overridden virtual functions: |
| ... | @@ -305,6 +309,43 @@ private: | ... | @@ -305,6 +309,43 @@ private: |
| 305 | state_type __st_; | 309 | state_type __st_; |
| 306 | state_type __st_last_; | 310 | state_type __st_last_; |
| 307 | ios_base::openmode __om_; | 311 | ios_base::openmode __om_; |
| 312 | // There have been no file operations yet, which allows setting unbuffered | ||
| 313 | // I/O mode. | ||
| 314 | static const ios_base::openmode __no_io_operations = ios_base::trunc; | ||
| 315 | // Unbuffered I/O mode has been requested. | ||
| 316 | static const ios_base::openmode __use_unbuffered_io = ios_base::ate; | ||
| 317 | // Used to track the currently used mode and track whether the output should | ||
| 318 | // be unbuffered. | ||
| 319 | // [filebuf.virtuals]/12 | ||
| 320 | // If setbuf(0, 0) is called on a stream before any I/O has occurred on | ||
| 321 | // that stream, the stream becomes unbuffered. Otherwise the results are | ||
| 322 | // implementation-defined. | ||
| 323 | // This allows calling setbuf(0, 0) | ||
| 324 | // - before opening a file, | ||
| 325 | // - after opening a file, before | ||
| 326 | // - a read | ||
| 327 | // - a write | ||
| 328 | // - a seek. | ||
| 329 | // Note that opening a file with ios_base::ate does a seek operation. | ||
| 330 | // Normally underflow, overflow, and sync change this flag to ios_base::in, | ||
| 331 | // ios_base_out, or 0. | ||
| 332 | // | ||
| 333 | // The ios_base::trunc and ios_base::ate flags are not used in __cm_. They | ||
| 334 | // are used to track the state of the unbuffered request. For readability | ||
| 335 | // they have the aliases __no_io_operations and __use_unbuffered_io | ||
| 336 | // respectively. | ||
| 337 | // | ||
| 338 | // The __no_io_operations and __use_unbuffered_io flags are used in the | ||
| 339 | // following way: | ||
| 340 | // - __no_io_operations is set upon construction to indicate the unbuffered | ||
| 341 | // state can be set. | ||
| 342 | // - When requesting unbuffered output: | ||
| 343 | // - If the file is open it sets the mode. | ||
| 344 | // - Else places a request by adding the __use_unbuffered_io flag. | ||
| 345 | // - When a file is opened it checks whether both __no_io_operations and | ||
| 346 | // __use_unbuffered_io are set. If so switches to unbuffered mode. | ||
| 347 | // - All file I/O operations change the mode effectively clearing the | ||
| 348 | // __no_io_operations and __use_unbuffered_io flags. | ||
| 308 | ios_base::openmode __cm_; | 349 | ios_base::openmode __cm_; |
| 309 | bool __owns_eb_; | 350 | bool __owns_eb_; |
| 310 | bool __owns_ib_; | 351 | bool __owns_ib_; |
| ... | @@ -314,6 +355,46 @@ private: | ... | @@ -314,6 +355,46 @@ private: |
| 314 | void __write_mode(); | 355 | void __write_mode(); |
| 315 | 356 | ||
| 316 | _LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&); | 357 | _LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&); |
| 358 | |||
| 359 | // There are multiple (__)open function, they use different C-API open | ||
| 360 | // function. After that call these functions behave the same. This function | ||
| 361 | // does that part and determines the final return value. | ||
| 362 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* __do_open(FILE* __file, ios_base::openmode __mode) { | ||
| 363 | __file_ = __file; | ||
| 364 | if (!__file_) | ||
| 365 | return nullptr; | ||
| 366 | |||
| 367 | __om_ = __mode; | ||
| 368 | if (__cm_ == (__no_io_operations | __use_unbuffered_io)) { | ||
| 369 | std::setbuf(__file_, nullptr); | ||
| 370 | __cm_ = 0; | ||
| 371 | } | ||
| 372 | |||
| 373 | if (__mode & ios_base::ate) { | ||
| 374 | __cm_ = 0; | ||
| 375 | if (fseek(__file_, 0, SEEK_END)) { | ||
| 376 | fclose(__file_); | ||
| 377 | __file_ = nullptr; | ||
| 378 | return nullptr; | ||
| 379 | } | ||
| 380 | } | ||
| 381 | |||
| 382 | return this; | ||
| 383 | } | ||
| 384 | |||
| 385 | // If the file is already open, switch to unbuffered mode. Otherwise, record | ||
| 386 | // the request to use unbuffered mode so that we use that mode when we | ||
| 387 | // eventually open the file. | ||
| 388 | _LIBCPP_HIDE_FROM_ABI void __request_unbuffered_mode(char_type* __s, streamsize __n) { | ||
| 389 | if (__cm_ == __no_io_operations && __s == nullptr && __n == 0) { | ||
| 390 | if (__file_) { | ||
| 391 | std::setbuf(__file_, nullptr); | ||
| 392 | __cm_ = 0; | ||
| 393 | } else { | ||
| 394 | __cm_ = __no_io_operations | __use_unbuffered_io; | ||
| 395 | } | ||
| 396 | } | ||
| 397 | } | ||
| 317 | }; | 398 | }; |
| 318 | 399 | ||
| 319 | template <class _CharT, class _Traits> | 400 | template <class _CharT, class _Traits> |
| ... | @@ -329,7 +410,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf() | ... | @@ -329,7 +410,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf() |
| 329 | __st_(), | 410 | __st_(), |
| 330 | __st_last_(), | 411 | __st_last_(), |
| 331 | __om_(0), | 412 | __om_(0), |
| 332 | __cm_(0), | 413 | __cm_(__no_io_operations), |
| 333 | __owns_eb_(false), | 414 | __owns_eb_(false), |
| 334 | __owns_ib_(false), | 415 | __owns_ib_(false), |
| 335 | __always_noconv_(false) { | 416 | __always_noconv_(false) { |
| ... | @@ -548,50 +629,79 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ | ... | @@ -548,50 +629,79 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ |
| 548 | __libcpp_unreachable(); | 629 | __libcpp_unreachable(); |
| 549 | } | 630 | } |
| 550 | 631 | ||
| 632 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | ||
| 551 | template <class _CharT, class _Traits> | 633 | template <class _CharT, class _Traits> |
| 552 | basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) { | 634 | const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT { |
| 553 | basic_filebuf<_CharT, _Traits>* __rt = nullptr; | 635 | switch (__mode & ~ios_base::ate) { |
| 554 | if (__file_ == nullptr) { | 636 | case ios_base::out: |
| 555 | if (const char* __mdstr = __make_mdstring(__mode)) { | 637 | case ios_base::out | ios_base::trunc: |
| 556 | __rt = this; | 638 | return L"w"; |
| 557 | __file_ = fopen(__s, __mdstr); | 639 | case ios_base::out | ios_base::app: |
| 558 | if (__file_) { | 640 | case ios_base::app: |
| 559 | __om_ = __mode; | 641 | return L"a"; |
| 560 | if (__mode & ios_base::ate) { | 642 | case ios_base::in: |
| 561 | if (fseek(__file_, 0, SEEK_END)) { | 643 | return L"r"; |
| 562 | fclose(__file_); | 644 | case ios_base::in | ios_base::out: |
| 563 | __file_ = nullptr; | 645 | return L"r+"; |
| 564 | __rt = nullptr; | 646 | case ios_base::in | ios_base::out | ios_base::trunc: |
| 565 | } | 647 | return L"w+"; |
| 566 | } | 648 | case ios_base::in | ios_base::out | ios_base::app: |
| 567 | } else | 649 | case ios_base::in | ios_base::app: |
| 568 | __rt = nullptr; | 650 | return L"a+"; |
| 569 | } | 651 | case ios_base::out | ios_base::binary: |
| 652 | case ios_base::out | ios_base::trunc | ios_base::binary: | ||
| 653 | return L"wb"; | ||
| 654 | case ios_base::out | ios_base::app | ios_base::binary: | ||
| 655 | case ios_base::app | ios_base::binary: | ||
| 656 | return L"ab"; | ||
| 657 | case ios_base::in | ios_base::binary: | ||
| 658 | return L"rb"; | ||
| 659 | case ios_base::in | ios_base::out | ios_base::binary: | ||
| 660 | return L"r+b"; | ||
| 661 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary: | ||
| 662 | return L"w+b"; | ||
| 663 | case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: | ||
| 664 | case ios_base::in | ios_base::app | ios_base::binary: | ||
| 665 | return L"a+b"; | ||
| 666 | # if _LIBCPP_STD_VER >= 23 | ||
| 667 | case ios_base::out | ios_base::noreplace: | ||
| 668 | case ios_base::out | ios_base::trunc | ios_base::noreplace: | ||
| 669 | return L"wx"; | ||
| 670 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::noreplace: | ||
| 671 | return L"w+x"; | ||
| 672 | case ios_base::out | ios_base::binary | ios_base::noreplace: | ||
| 673 | case ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: | ||
| 674 | return L"wbx"; | ||
| 675 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: | ||
| 676 | return L"w+bx"; | ||
| 677 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 678 | default: | ||
| 679 | return nullptr; | ||
| 570 | } | 680 | } |
| 571 | return __rt; | 681 | __libcpp_unreachable(); |
| 682 | } | ||
| 683 | # endif | ||
| 684 | |||
| 685 | template <class _CharT, class _Traits> | ||
| 686 | basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) { | ||
| 687 | if (__file_) | ||
| 688 | return nullptr; | ||
| 689 | const char* __mdstr = __make_mdstring(__mode); | ||
| 690 | if (!__mdstr) | ||
| 691 | return nullptr; | ||
| 692 | |||
| 693 | return __do_open(fopen(__s, __mdstr), __mode); | ||
| 572 | } | 694 | } |
| 573 | 695 | ||
| 574 | template <class _CharT, class _Traits> | 696 | template <class _CharT, class _Traits> |
| 575 | inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) { | 697 | inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) { |
| 576 | basic_filebuf<_CharT, _Traits>* __rt = nullptr; | 698 | if (__file_) |
| 577 | if (__file_ == nullptr) { | 699 | return nullptr; |
| 578 | if (const char* __mdstr = __make_mdstring(__mode)) { | 700 | const char* __mdstr = __make_mdstring(__mode); |
| 579 | __rt = this; | 701 | if (!__mdstr) |
| 580 | __file_ = fdopen(__fd, __mdstr); | 702 | return nullptr; |
| 581 | if (__file_) { | 703 | |
| 582 | __om_ = __mode; | 704 | return __do_open(fdopen(__fd, __mdstr), __mode); |
| 583 | if (__mode & ios_base::ate) { | ||
| 584 | if (fseek(__file_, 0, SEEK_END)) { | ||
| 585 | fclose(__file_); | ||
| 586 | __file_ = nullptr; | ||
| 587 | __rt = nullptr; | ||
| 588 | } | ||
| 589 | } | ||
| 590 | } else | ||
| 591 | __rt = nullptr; | ||
| 592 | } | ||
| 593 | } | ||
| 594 | return __rt; | ||
| 595 | } | 705 | } |
| 596 | 706 | ||
| 597 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | 707 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| ... | @@ -599,89 +709,13 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in | ... | @@ -599,89 +709,13 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in |
| 599 | // and long mode strings. | 709 | // and long mode strings. |
| 600 | template <class _CharT, class _Traits> | 710 | template <class _CharT, class _Traits> |
| 601 | basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { | 711 | basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { |
| 602 | basic_filebuf<_CharT, _Traits>* __rt = nullptr; | 712 | if (__file_) |
| 603 | if (__file_ == nullptr) { | 713 | return nullptr; |
| 604 | __rt = this; | 714 | const wchar_t* __mdstr = __make_mdwstring(__mode); |
| 605 | const wchar_t* __mdstr; | 715 | if (!__mdstr) |
| 606 | switch (__mode & ~ios_base::ate) { | 716 | return nullptr; |
| 607 | case ios_base::out: | 717 | |
| 608 | case ios_base::out | ios_base::trunc: | 718 | return __do_open(_wfopen(__s, __mdstr), __mode); |
| 609 | __mdstr = L"w"; | ||
| 610 | break; | ||
| 611 | case ios_base::out | ios_base::app: | ||
| 612 | case ios_base::app: | ||
| 613 | __mdstr = L"a"; | ||
| 614 | break; | ||
| 615 | case ios_base::in: | ||
| 616 | __mdstr = L"r"; | ||
| 617 | break; | ||
| 618 | case ios_base::in | ios_base::out: | ||
| 619 | __mdstr = L"r+"; | ||
| 620 | break; | ||
| 621 | case ios_base::in | ios_base::out | ios_base::trunc: | ||
| 622 | __mdstr = L"w+"; | ||
| 623 | break; | ||
| 624 | case ios_base::in | ios_base::out | ios_base::app: | ||
| 625 | case ios_base::in | ios_base::app: | ||
| 626 | __mdstr = L"a+"; | ||
| 627 | break; | ||
| 628 | case ios_base::out | ios_base::binary: | ||
| 629 | case ios_base::out | ios_base::trunc | ios_base::binary: | ||
| 630 | __mdstr = L"wb"; | ||
| 631 | break; | ||
| 632 | case ios_base::out | ios_base::app | ios_base::binary: | ||
| 633 | case ios_base::app | ios_base::binary: | ||
| 634 | __mdstr = L"ab"; | ||
| 635 | break; | ||
| 636 | case ios_base::in | ios_base::binary: | ||
| 637 | __mdstr = L"rb"; | ||
| 638 | break; | ||
| 639 | case ios_base::in | ios_base::out | ios_base::binary: | ||
| 640 | __mdstr = L"r+b"; | ||
| 641 | break; | ||
| 642 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary: | ||
| 643 | __mdstr = L"w+b"; | ||
| 644 | break; | ||
| 645 | case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: | ||
| 646 | case ios_base::in | ios_base::app | ios_base::binary: | ||
| 647 | __mdstr = L"a+b"; | ||
| 648 | break; | ||
| 649 | # if _LIBCPP_STD_VER >= 23 | ||
| 650 | case ios_base::out | ios_base::noreplace: | ||
| 651 | case ios_base::out | ios_base::trunc | ios_base::noreplace: | ||
| 652 | __mdstr = L"wx"; | ||
| 653 | break; | ||
| 654 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::noreplace: | ||
| 655 | __mdstr = L"w+x"; | ||
| 656 | break; | ||
| 657 | case ios_base::out | ios_base::binary | ios_base::noreplace: | ||
| 658 | case ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: | ||
| 659 | __mdstr = L"wbx"; | ||
| 660 | break; | ||
| 661 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: | ||
| 662 | __mdstr = L"w+bx"; | ||
| 663 | break; | ||
| 664 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 665 | default: | ||
| 666 | __rt = nullptr; | ||
| 667 | break; | ||
| 668 | } | ||
| 669 | if (__rt) { | ||
| 670 | __file_ = _wfopen(__s, __mdstr); | ||
| 671 | if (__file_) { | ||
| 672 | __om_ = __mode; | ||
| 673 | if (__mode & ios_base::ate) { | ||
| 674 | if (fseek(__file_, 0, SEEK_END)) { | ||
| 675 | fclose(__file_); | ||
| 676 | __file_ = nullptr; | ||
| 677 | __rt = nullptr; | ||
| 678 | } | ||
| 679 | } | ||
| 680 | } else | ||
| 681 | __rt = nullptr; | ||
| 682 | } | ||
| 683 | } | ||
| 684 | return __rt; | ||
| 685 | } | 719 | } |
| 686 | # endif | 720 | # endif |
| 687 | 721 | ||
| ... | @@ -834,6 +868,7 @@ template <class _CharT, class _Traits> | ... | @@ -834,6 +868,7 @@ template <class _CharT, class _Traits> |
| 834 | basic_streambuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n) { | 868 | basic_streambuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n) { |
| 835 | this->setg(nullptr, nullptr, nullptr); | 869 | this->setg(nullptr, nullptr, nullptr); |
| 836 | this->setp(nullptr, nullptr); | 870 | this->setp(nullptr, nullptr); |
| 871 | __request_unbuffered_mode(__s, __n); | ||
| 837 | if (__owns_eb_) | 872 | if (__owns_eb_) |
| 838 | delete[] __extbuf_; | 873 | delete[] __extbuf_; |
| 839 | if (__owns_ib_) | 874 | if (__owns_ib_) |
| ... | @@ -1067,8 +1102,9 @@ public: | ... | @@ -1067,8 +1102,9 @@ public: |
| 1067 | # endif | 1102 | # endif |
| 1068 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); | 1103 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); |
| 1069 | # if _LIBCPP_STD_VER >= 17 | 1104 | # if _LIBCPP_STD_VER >= 17 |
| 1070 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream( | 1105 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1071 | const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) | 1106 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY |
| 1107 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in) | ||
| 1072 | : basic_ifstream(__p.c_str(), __mode) {} | 1108 | : basic_ifstream(__p.c_str(), __mode) {} |
| 1073 | # endif // _LIBCPP_STD_VER >= 17 | 1109 | # endif // _LIBCPP_STD_VER >= 17 |
| 1074 | _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs); | 1110 | _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs); |
| ... | @@ -1221,8 +1257,9 @@ public: | ... | @@ -1221,8 +1257,9 @@ public: |
| 1221 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); | 1257 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); |
| 1222 | 1258 | ||
| 1223 | # if _LIBCPP_STD_VER >= 17 | 1259 | # if _LIBCPP_STD_VER >= 17 |
| 1224 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream( | 1260 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1225 | const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) | 1261 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY |
| 1262 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out) | ||
| 1226 | : basic_ofstream(__p.c_str(), __mode) {} | 1263 | : basic_ofstream(__p.c_str(), __mode) {} |
| 1227 | # endif // _LIBCPP_STD_VER >= 17 | 1264 | # endif // _LIBCPP_STD_VER >= 17 |
| 1228 | 1265 | ||
| ... | @@ -1380,8 +1417,9 @@ public: | ... | @@ -1380,8 +1417,9 @@ public: |
| 1380 | ios_base::openmode __mode = ios_base::in | ios_base::out); | 1417 | ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1381 | 1418 | ||
| 1382 | # if _LIBCPP_STD_VER >= 17 | 1419 | # if _LIBCPP_STD_VER >= 17 |
| 1420 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> | ||
| 1383 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream( | 1421 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream( |
| 1384 | const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) | 1422 | const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) |
| 1385 | : basic_fstream(__p.c_str(), __mode) {} | 1423 | : basic_fstream(__p.c_str(), __mode) {} |
| 1386 | # endif // _LIBCPP_STD_VER >= 17 | 1424 | # endif // _LIBCPP_STD_VER >= 17 |
| 1387 | 1425 |
lib/libcxx/include/functional+48-15| ... | @@ -77,6 +77,15 @@ template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; | ... | @@ -77,6 +77,15 @@ template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; |
| 77 | template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20 | 77 | template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20 |
| 78 | template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20 | 78 | template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20 |
| 79 | 79 | ||
| 80 | // [refwrap.comparisons], comparisons | ||
| 81 | friend constexpr bool operator==(reference_wrapper, reference_wrapper); // Since C++26 | ||
| 82 | friend constexpr bool operator==(reference_wrapper, const T&); // Since C++26 | ||
| 83 | friend constexpr bool operator==(reference_wrapper, reference_wrapper<const T>); // Since C++26 | ||
| 84 | |||
| 85 | friend constexpr auto operator<=>(reference_wrapper, reference_wrapper); // Since C++26 | ||
| 86 | friend constexpr auto operator<=>(reference_wrapper, const T&); // Since C++26 | ||
| 87 | friend constexpr auto operator<=>(reference_wrapper, reference_wrapper<const T>); // Since C++26 | ||
| 88 | |||
| 80 | template <class T> // <class T=void> in C++14 | 89 | template <class T> // <class T=void> in C++14 |
| 81 | struct plus { | 90 | struct plus { |
| 82 | T operator()(const T& x, const T& y) const; | 91 | T operator()(const T& x, const T& y) const; |
| ... | @@ -207,6 +216,12 @@ binary_negate<Predicate> not2(const Predicate& pred); | ... | @@ -207,6 +216,12 @@ binary_negate<Predicate> not2(const Predicate& pred); |
| 207 | template <class F> | 216 | template <class F> |
| 208 | constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20 | 217 | constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20 |
| 209 | 218 | ||
| 219 | // [func.bind.partial], function templates bind_front and bind_back | ||
| 220 | template<class F, class... Args> | ||
| 221 | constexpr unspecified bind_front(F&&, Args&&...); // C++20 | ||
| 222 | template<class F, class... Args> | ||
| 223 | constexpr unspecified bind_back(F&&, Args&&...); // C++23 | ||
| 224 | |||
| 210 | template<class T> struct is_bind_expression; | 225 | template<class T> struct is_bind_expression; |
| 211 | template<class T> struct is_placeholder; | 226 | template<class T> struct is_placeholder; |
| 212 | 227 | ||
| ... | @@ -512,42 +527,60 @@ POLICY: For non-variadic implementations, the number of arguments is limited | ... | @@ -512,42 +527,60 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 512 | 527 | ||
| 513 | */ | 528 | */ |
| 514 | 529 | ||
| 515 | #include <__algorithm/search.h> | ||
| 516 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 517 | #include <__compare/compare_three_way.h> | ||
| 518 | #include <__config> | 530 | #include <__config> |
| 531 | |||
| 519 | #include <__functional/binary_function.h> | 532 | #include <__functional/binary_function.h> |
| 520 | #include <__functional/binary_negate.h> | 533 | #include <__functional/binary_negate.h> |
| 521 | #include <__functional/bind.h> | 534 | #include <__functional/bind.h> |
| 522 | #include <__functional/bind_back.h> | ||
| 523 | #include <__functional/bind_front.h> | ||
| 524 | #include <__functional/binder1st.h> | 535 | #include <__functional/binder1st.h> |
| 525 | #include <__functional/binder2nd.h> | 536 | #include <__functional/binder2nd.h> |
| 526 | #include <__functional/boyer_moore_searcher.h> | ||
| 527 | #include <__functional/compose.h> | ||
| 528 | #include <__functional/default_searcher.h> | ||
| 529 | #include <__functional/function.h> | ||
| 530 | #include <__functional/hash.h> | 537 | #include <__functional/hash.h> |
| 531 | #include <__functional/identity.h> | ||
| 532 | #include <__functional/invoke.h> | ||
| 533 | #include <__functional/mem_fn.h> // TODO: deprecate | 538 | #include <__functional/mem_fn.h> // TODO: deprecate |
| 534 | #include <__functional/mem_fun_ref.h> | 539 | #include <__functional/mem_fun_ref.h> |
| 535 | #include <__functional/not_fn.h> | ||
| 536 | #include <__functional/operations.h> | 540 | #include <__functional/operations.h> |
| 537 | #include <__functional/pointer_to_binary_function.h> | 541 | #include <__functional/pointer_to_binary_function.h> |
| 538 | #include <__functional/pointer_to_unary_function.h> | 542 | #include <__functional/pointer_to_unary_function.h> |
| 539 | #include <__functional/ranges_operations.h> | ||
| 540 | #include <__functional/reference_wrapper.h> | 543 | #include <__functional/reference_wrapper.h> |
| 541 | #include <__functional/unary_function.h> | 544 | #include <__functional/unary_function.h> |
| 542 | #include <__functional/unary_negate.h> | 545 | #include <__functional/unary_negate.h> |
| 543 | #include <__type_traits/unwrap_ref.h> | 546 | |
| 544 | #include <__utility/forward.h> | 547 | #ifndef _LIBCPP_CXX03_LANG |
| 548 | # include <__functional/function.h> | ||
| 549 | #endif | ||
| 550 | |||
| 551 | #if _LIBCPP_STD_VER >= 17 | ||
| 552 | # include <__functional/boyer_moore_searcher.h> | ||
| 553 | # include <__functional/default_searcher.h> | ||
| 554 | # include <__functional/invoke.h> | ||
| 555 | # include <__functional/not_fn.h> | ||
| 556 | #endif | ||
| 557 | |||
| 558 | #if _LIBCPP_STD_VER >= 20 | ||
| 559 | # include <__functional/bind_back.h> | ||
| 560 | # include <__functional/bind_front.h> | ||
| 561 | # include <__functional/identity.h> | ||
| 562 | # include <__functional/ranges_operations.h> | ||
| 563 | # include <__type_traits/unwrap_ref.h> | ||
| 564 | #endif | ||
| 565 | |||
| 545 | #include <version> | 566 | #include <version> |
| 546 | 567 | ||
| 547 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 568 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 548 | # pragma GCC system_header | 569 | # pragma GCC system_header |
| 549 | #endif | 570 | #endif |
| 550 | 571 | ||
| 572 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG) | ||
| 573 | # include <limits> | ||
| 574 | # include <new> | ||
| 575 | #endif | ||
| 576 | |||
| 577 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | ||
| 578 | # include <array> | ||
| 579 | # include <initializer_list> | ||
| 580 | # include <unordered_map> | ||
| 581 | # include <vector> | ||
| 582 | #endif | ||
| 583 | |||
| 551 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 584 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 552 | # include <atomic> | 585 | # include <atomic> |
| 553 | # include <concepts> | 586 | # include <concepts> |
lib/libcxx/include/future+101-103| ... | @@ -364,45 +364,42 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; | ... | @@ -364,45 +364,42 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 364 | 364 | ||
| 365 | #include <__config> | 365 | #include <__config> |
| 366 | 366 | ||
| 367 | #ifdef _LIBCPP_HAS_NO_THREADS | 367 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 368 | # error "<future> is not supported since libc++ has been configured without support for threads." | 368 | |
| 369 | #endif | 369 | # include <__assert> |
| 370 | 370 | # include <__chrono/duration.h> | |
| 371 | #include <__assert> // all public C++ headers provide the assertion handler | 371 | # include <__chrono/time_point.h> |
| 372 | #include <__availability> | 372 | # include <__exception/exception_ptr.h> |
| 373 | #include <__chrono/duration.h> | 373 | # include <__memory/addressof.h> |
| 374 | #include <__chrono/time_point.h> | 374 | # include <__memory/allocator.h> |
| 375 | #include <__exception/exception_ptr.h> | 375 | # include <__memory/allocator_arg_t.h> |
| 376 | #include <__memory/addressof.h> | 376 | # include <__memory/allocator_destructor.h> |
| 377 | #include <__memory/allocator.h> | 377 | # include <__memory/allocator_traits.h> |
| 378 | #include <__memory/allocator_arg_t.h> | 378 | # include <__memory/compressed_pair.h> |
| 379 | #include <__memory/allocator_destructor.h> | 379 | # include <__memory/pointer_traits.h> |
| 380 | #include <__memory/allocator_traits.h> | 380 | # include <__memory/shared_ptr.h> |
| 381 | #include <__memory/compressed_pair.h> | 381 | # include <__memory/unique_ptr.h> |
| 382 | #include <__memory/pointer_traits.h> | 382 | # include <__memory/uses_allocator.h> |
| 383 | #include <__memory/shared_ptr.h> | 383 | # include <__system_error/error_category.h> |
| 384 | #include <__memory/unique_ptr.h> | 384 | # include <__system_error/error_code.h> |
| 385 | #include <__memory/uses_allocator.h> | 385 | # include <__system_error/error_condition.h> |
| 386 | #include <__system_error/error_category.h> | 386 | # include <__type_traits/aligned_storage.h> |
| 387 | #include <__system_error/error_code.h> | 387 | # include <__type_traits/strip_signature.h> |
| 388 | #include <__system_error/error_condition.h> | 388 | # include <__utility/auto_cast.h> |
| 389 | #include <__type_traits/aligned_storage.h> | 389 | # include <__utility/forward.h> |
| 390 | #include <__type_traits/strip_signature.h> | 390 | # include <__utility/move.h> |
| 391 | #include <__utility/auto_cast.h> | 391 | # include <mutex> |
| 392 | #include <__utility/forward.h> | 392 | # include <new> |
| 393 | #include <__utility/move.h> | 393 | # include <stdexcept> |
| 394 | #include <mutex> | 394 | # include <thread> |
| 395 | #include <new> | 395 | # include <version> |
| 396 | #include <stdexcept> | 396 | |
| 397 | #include <thread> | 397 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 398 | #include <version> | 398 | # pragma GCC system_header |
| 399 | 399 | # endif | |
| 400 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 401 | # pragma GCC system_header | ||
| 402 | #endif | ||
| 403 | 400 | ||
| 404 | _LIBCPP_PUSH_MACROS | 401 | _LIBCPP_PUSH_MACROS |
| 405 | #include <__undef_macros> | 402 | # include <__undef_macros> |
| 406 | 403 | ||
| 407 | _LIBCPP_BEGIN_NAMESPACE_STD | 404 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 408 | 405 | ||
| ... | @@ -414,32 +411,32 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) | ... | @@ -414,32 +411,32 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) |
| 414 | template <> | 411 | template <> |
| 415 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {}; | 412 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {}; |
| 416 | 413 | ||
| 417 | #ifdef _LIBCPP_CXX03_LANG | 414 | # ifdef _LIBCPP_CXX03_LANG |
| 418 | template <> | 415 | template <> |
| 419 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {}; | 416 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {}; |
| 420 | #endif | 417 | # endif |
| 421 | 418 | ||
| 422 | // enum class launch | 419 | // enum class launch |
| 423 | _LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred}; | 420 | _LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred}; |
| 424 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) | 421 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) |
| 425 | 422 | ||
| 426 | #ifndef _LIBCPP_CXX03_LANG | 423 | # ifndef _LIBCPP_CXX03_LANG |
| 427 | 424 | ||
| 428 | typedef underlying_type<launch>::type __launch_underlying_type; | 425 | typedef underlying_type<launch>::type __launch_underlying_type; |
| 429 | 426 | ||
| 430 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator&(launch __x, launch __y) { | 427 | inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator&(launch __x, launch __y) { |
| 431 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y)); | 428 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y)); |
| 432 | } | 429 | } |
| 433 | 430 | ||
| 434 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator|(launch __x, launch __y) { | 431 | inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator|(launch __x, launch __y) { |
| 435 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) | static_cast<__launch_underlying_type>(__y)); | 432 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) | static_cast<__launch_underlying_type>(__y)); |
| 436 | } | 433 | } |
| 437 | 434 | ||
| 438 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator^(launch __x, launch __y) { | 435 | inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator^(launch __x, launch __y) { |
| 439 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) ^ static_cast<__launch_underlying_type>(__y)); | 436 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) ^ static_cast<__launch_underlying_type>(__y)); |
| 440 | } | 437 | } |
| 441 | 438 | ||
| 442 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator~(launch __x) { | 439 | inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator~(launch __x) { |
| 443 | return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3); | 440 | return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3); |
| 444 | } | 441 | } |
| 445 | 442 | ||
| ... | @@ -458,7 +455,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { | ... | @@ -458,7 +455,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { |
| 458 | return __x; | 455 | return __x; |
| 459 | } | 456 | } |
| 460 | 457 | ||
| 461 | #endif // !_LIBCPP_CXX03_LANG | 458 | # endif // !_LIBCPP_CXX03_LANG |
| 462 | 459 | ||
| 463 | // enum class future_status | 460 | // enum class future_status |
| 464 | _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; | 461 | _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; |
| ... | @@ -485,9 +482,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { | ... | @@ -485,9 +482,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { |
| 485 | friend class promise; | 482 | friend class promise; |
| 486 | 483 | ||
| 487 | public: | 484 | public: |
| 488 | #if _LIBCPP_STD_VER >= 17 | 485 | # if _LIBCPP_STD_VER >= 17 |
| 489 | _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} | 486 | _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} |
| 490 | #endif | 487 | # endif |
| 491 | 488 | ||
| 492 | _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } | 489 | _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } |
| 493 | 490 | ||
| ... | @@ -497,12 +494,12 @@ public: | ... | @@ -497,12 +494,12 @@ public: |
| 497 | 494 | ||
| 498 | // Declared above std::future_error | 495 | // Declared above std::future_error |
| 499 | void __throw_future_error(future_errc __ev) { | 496 | void __throw_future_error(future_errc __ev) { |
| 500 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 497 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 501 | throw future_error(make_error_code(__ev)); | 498 | throw future_error(make_error_code(__ev)); |
| 502 | #else | 499 | # else |
| 503 | (void)__ev; | 500 | (void)__ev; |
| 504 | _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode"); | 501 | _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode"); |
| 505 | #endif | 502 | # endif |
| 506 | } | 503 | } |
| 507 | 504 | ||
| 508 | class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count { | 505 | class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count { |
| ... | @@ -776,15 +773,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f | ... | @@ -776,15 +773,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f |
| 776 | 773 | ||
| 777 | template <class _Rp, class _Fp> | 774 | template <class _Rp, class _Fp> |
| 778 | void __deferred_assoc_state<_Rp, _Fp>::__execute() { | 775 | void __deferred_assoc_state<_Rp, _Fp>::__execute() { |
| 779 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 776 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 780 | try { | 777 | try { |
| 781 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 778 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 782 | this->set_value(__func_()); | 779 | this->set_value(__func_()); |
| 783 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 780 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 784 | } catch (...) { | 781 | } catch (...) { |
| 785 | this->set_exception(current_exception()); | 782 | this->set_exception(current_exception()); |
| 786 | } | 783 | } |
| 787 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 784 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 788 | } | 785 | } |
| 789 | 786 | ||
| 790 | template <class _Fp> | 787 | template <class _Fp> |
| ... | @@ -806,16 +803,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __ | ... | @@ -806,16 +803,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __ |
| 806 | 803 | ||
| 807 | template <class _Fp> | 804 | template <class _Fp> |
| 808 | void __deferred_assoc_state<void, _Fp>::__execute() { | 805 | void __deferred_assoc_state<void, _Fp>::__execute() { |
| 809 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 806 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 810 | try { | 807 | try { |
| 811 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 808 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 812 | __func_(); | 809 | __func_(); |
| 813 | this->set_value(); | 810 | this->set_value(); |
| 814 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 811 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 815 | } catch (...) { | 812 | } catch (...) { |
| 816 | this->set_exception(current_exception()); | 813 | this->set_exception(current_exception()); |
| 817 | } | 814 | } |
| 818 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 815 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 819 | } | 816 | } |
| 820 | 817 | ||
| 821 | template <class _Rp, class _Fp> | 818 | template <class _Rp, class _Fp> |
| ... | @@ -837,15 +834,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s | ... | @@ -837,15 +834,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s |
| 837 | 834 | ||
| 838 | template <class _Rp, class _Fp> | 835 | template <class _Rp, class _Fp> |
| 839 | void __async_assoc_state<_Rp, _Fp>::__execute() { | 836 | void __async_assoc_state<_Rp, _Fp>::__execute() { |
| 840 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 837 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 841 | try { | 838 | try { |
| 842 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 839 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 843 | this->set_value(__func_()); | 840 | this->set_value(__func_()); |
| 844 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 841 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 845 | } catch (...) { | 842 | } catch (...) { |
| 846 | this->set_exception(current_exception()); | 843 | this->set_exception(current_exception()); |
| 847 | } | 844 | } |
| 848 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 845 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 849 | } | 846 | } |
| 850 | 847 | ||
| 851 | template <class _Rp, class _Fp> | 848 | template <class _Rp, class _Fp> |
| ... | @@ -873,16 +870,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_( | ... | @@ -873,16 +870,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_( |
| 873 | 870 | ||
| 874 | template <class _Fp> | 871 | template <class _Fp> |
| 875 | void __async_assoc_state<void, _Fp>::__execute() { | 872 | void __async_assoc_state<void, _Fp>::__execute() { |
| 876 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 873 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 877 | try { | 874 | try { |
| 878 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 875 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 879 | __func_(); | 876 | __func_(); |
| 880 | this->set_value(); | 877 | this->set_value(); |
| 881 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 878 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 882 | } catch (...) { | 879 | } catch (...) { |
| 883 | this->set_exception(current_exception()); | 880 | this->set_exception(current_exception()); |
| 884 | } | 881 | } |
| 885 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 882 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 886 | } | 883 | } |
| 887 | 884 | ||
| 888 | template <class _Fp> | 885 | template <class _Fp> |
| ... | @@ -1385,11 +1382,10 @@ class __packaged_task_base; | ... | @@ -1385,11 +1382,10 @@ class __packaged_task_base; |
| 1385 | 1382 | ||
| 1386 | template <class _Rp, class... _ArgTypes> | 1383 | template <class _Rp, class... _ArgTypes> |
| 1387 | class __packaged_task_base<_Rp(_ArgTypes...)> { | 1384 | class __packaged_task_base<_Rp(_ArgTypes...)> { |
| 1388 | __packaged_task_base(const __packaged_task_base&); | ||
| 1389 | __packaged_task_base& operator=(const __packaged_task_base&); | ||
| 1390 | |||
| 1391 | public: | 1385 | public: |
| 1392 | _LIBCPP_HIDE_FROM_ABI __packaged_task_base() {} | 1386 | _LIBCPP_HIDE_FROM_ABI __packaged_task_base() {} |
| 1387 | __packaged_task_base(const __packaged_task_base&) = delete; | ||
| 1388 | __packaged_task_base& operator=(const __packaged_task_base&) = delete; | ||
| 1393 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL | 1389 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL |
| 1394 | virtual ~__packaged_task_base() {} | 1390 | virtual ~__packaged_task_base() {} |
| 1395 | virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0; | 1391 | virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0; |
| ... | @@ -1605,9 +1601,11 @@ private: | ... | @@ -1605,9 +1601,11 @@ private: |
| 1605 | public: | 1601 | public: |
| 1606 | // construction and destruction | 1602 | // construction and destruction |
| 1607 | _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} | 1603 | _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} |
| 1608 | template <class _Fp, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> > | 1604 | |
| 1605 | template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> | ||
| 1609 | _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} | 1606 | _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} |
| 1610 | template <class _Fp, class _Allocator, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> > | 1607 | |
| 1608 | template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> | ||
| 1611 | _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) | 1609 | _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) |
| 1612 | : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} | 1610 | : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} |
| 1613 | // ~packaged_task() = default; | 1611 | // ~packaged_task() = default; |
| ... | @@ -1648,15 +1646,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { | ... | @@ -1648,15 +1646,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1648 | __throw_future_error(future_errc::no_state); | 1646 | __throw_future_error(future_errc::no_state); |
| 1649 | if (__p_.__state_->__has_value()) | 1647 | if (__p_.__state_->__has_value()) |
| 1650 | __throw_future_error(future_errc::promise_already_satisfied); | 1648 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1651 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1649 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1652 | try { | 1650 | try { |
| 1653 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1651 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1654 | __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...)); | 1652 | __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...)); |
| 1655 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1653 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1656 | } catch (...) { | 1654 | } catch (...) { |
| 1657 | __p_.set_exception(current_exception()); | 1655 | __p_.set_exception(current_exception()); |
| 1658 | } | 1656 | } |
| 1659 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1657 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1660 | } | 1658 | } |
| 1661 | 1659 | ||
| 1662 | template <class _Rp, class... _ArgTypes> | 1660 | template <class _Rp, class... _ArgTypes> |
| ... | @@ -1665,15 +1663,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ | ... | @@ -1665,15 +1663,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ |
| 1665 | __throw_future_error(future_errc::no_state); | 1663 | __throw_future_error(future_errc::no_state); |
| 1666 | if (__p_.__state_->__has_value()) | 1664 | if (__p_.__state_->__has_value()) |
| 1667 | __throw_future_error(future_errc::promise_already_satisfied); | 1665 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1668 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1666 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1669 | try { | 1667 | try { |
| 1670 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1668 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1671 | __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...)); | 1669 | __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...)); |
| 1672 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1670 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1673 | } catch (...) { | 1671 | } catch (...) { |
| 1674 | __p_.set_exception_at_thread_exit(current_exception()); | 1672 | __p_.set_exception_at_thread_exit(current_exception()); |
| 1675 | } | 1673 | } |
| 1676 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1674 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1677 | } | 1675 | } |
| 1678 | 1676 | ||
| 1679 | template <class _Rp, class... _ArgTypes> | 1677 | template <class _Rp, class... _ArgTypes> |
| ... | @@ -1695,9 +1693,9 @@ private: | ... | @@ -1695,9 +1693,9 @@ private: |
| 1695 | public: | 1693 | public: |
| 1696 | // construction and destruction | 1694 | // construction and destruction |
| 1697 | _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} | 1695 | _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} |
| 1698 | template <class _Fp, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> > | 1696 | template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> |
| 1699 | _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} | 1697 | _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} |
| 1700 | template <class _Fp, class _Allocator, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> > | 1698 | template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> |
| 1701 | _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) | 1699 | _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) |
| 1702 | : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} | 1700 | : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} |
| 1703 | // ~packaged_task() = default; | 1701 | // ~packaged_task() = default; |
| ... | @@ -1732,7 +1730,7 @@ public: | ... | @@ -1732,7 +1730,7 @@ public: |
| 1732 | _LIBCPP_HIDE_FROM_ABI void reset(); | 1730 | _LIBCPP_HIDE_FROM_ABI void reset(); |
| 1733 | }; | 1731 | }; |
| 1734 | 1732 | ||
| 1735 | #if _LIBCPP_STD_VER >= 17 | 1733 | # if _LIBCPP_STD_VER >= 17 |
| 1736 | 1734 | ||
| 1737 | template <class _Rp, class... _Args> | 1735 | template <class _Rp, class... _Args> |
| 1738 | packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; | 1736 | packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; |
| ... | @@ -1740,7 +1738,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; | ... | @@ -1740,7 +1738,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; |
| 1740 | template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> | 1738 | template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> |
| 1741 | packaged_task(_Fp) -> packaged_task<_Stripped>; | 1739 | packaged_task(_Fp) -> packaged_task<_Stripped>; |
| 1742 | 1740 | ||
| 1743 | #endif | 1741 | # endif |
| 1744 | 1742 | ||
| 1745 | template <class... _ArgTypes> | 1743 | template <class... _ArgTypes> |
| 1746 | void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { | 1744 | void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| ... | @@ -1748,16 +1746,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { | ... | @@ -1748,16 +1746,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1748 | __throw_future_error(future_errc::no_state); | 1746 | __throw_future_error(future_errc::no_state); |
| 1749 | if (__p_.__state_->__has_value()) | 1747 | if (__p_.__state_->__has_value()) |
| 1750 | __throw_future_error(future_errc::promise_already_satisfied); | 1748 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1751 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1749 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1752 | try { | 1750 | try { |
| 1753 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1751 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1754 | __f_(std::forward<_ArgTypes>(__args)...); | 1752 | __f_(std::forward<_ArgTypes>(__args)...); |
| 1755 | __p_.set_value(); | 1753 | __p_.set_value(); |
| 1756 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1754 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1757 | } catch (...) { | 1755 | } catch (...) { |
| 1758 | __p_.set_exception(current_exception()); | 1756 | __p_.set_exception(current_exception()); |
| 1759 | } | 1757 | } |
| 1760 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1758 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1761 | } | 1759 | } |
| 1762 | 1760 | ||
| 1763 | template <class... _ArgTypes> | 1761 | template <class... _ArgTypes> |
| ... | @@ -1766,16 +1764,16 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _ | ... | @@ -1766,16 +1764,16 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _ |
| 1766 | __throw_future_error(future_errc::no_state); | 1764 | __throw_future_error(future_errc::no_state); |
| 1767 | if (__p_.__state_->__has_value()) | 1765 | if (__p_.__state_->__has_value()) |
| 1768 | __throw_future_error(future_errc::promise_already_satisfied); | 1766 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1769 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1767 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1770 | try { | 1768 | try { |
| 1771 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1769 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1772 | __f_(std::forward<_ArgTypes>(__args)...); | 1770 | __f_(std::forward<_ArgTypes>(__args)...); |
| 1773 | __p_.set_value_at_thread_exit(); | 1771 | __p_.set_value_at_thread_exit(); |
| 1774 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1772 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1775 | } catch (...) { | 1773 | } catch (...) { |
| 1776 | __p_.set_exception_at_thread_exit(current_exception()); | 1774 | __p_.set_exception_at_thread_exit(current_exception()); |
| 1777 | } | 1775 | } |
| 1778 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1776 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1779 | } | 1777 | } |
| 1780 | 1778 | ||
| 1781 | template <class... _ArgTypes> | 1779 | template <class... _ArgTypes> |
| ... | @@ -1809,7 +1807,7 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { | ... | @@ -1809,7 +1807,7 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { |
| 1809 | return future<_Rp>(__h.get()); | 1807 | return future<_Rp>(__h.get()); |
| 1810 | } | 1808 | } |
| 1811 | 1809 | ||
| 1812 | #ifndef _LIBCPP_CXX03_LANG | 1810 | # ifndef _LIBCPP_CXX03_LANG |
| 1813 | 1811 | ||
| 1814 | template <class _Fp, class... _Args> | 1812 | template <class _Fp, class... _Args> |
| 1815 | class _LIBCPP_HIDDEN __async_func { | 1813 | class _LIBCPP_HIDDEN __async_func { |
| ... | @@ -1840,24 +1838,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch | ... | @@ -1840,24 +1838,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch |
| 1840 | } | 1838 | } |
| 1841 | 1839 | ||
| 1842 | template <class _Fp, class... _Args> | 1840 | template <class _Fp, class... _Args> |
| 1843 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | 1841 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> |
| 1844 | future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> | 1842 | async(launch __policy, _Fp&& __f, _Args&&... __args) { |
| 1845 | async(launch __policy, _Fp&& __f, _Args&&... __args) { | ||
| 1846 | typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; | 1843 | typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; |
| 1847 | typedef typename _BF::_Rp _Rp; | 1844 | typedef typename _BF::_Rp _Rp; |
| 1848 | 1845 | ||
| 1849 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1846 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1850 | try { | 1847 | try { |
| 1851 | # endif | 1848 | # endif |
| 1852 | if (__does_policy_contain(__policy, launch::async)) | 1849 | if (__does_policy_contain(__policy, launch::async)) |
| 1853 | return std::__make_async_assoc_state<_Rp>( | 1850 | return std::__make_async_assoc_state<_Rp>( |
| 1854 | _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); | 1851 | _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); |
| 1855 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1852 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1856 | } catch (...) { | 1853 | } catch (...) { |
| 1857 | if (__policy == launch::async) | 1854 | if (__policy == launch::async) |
| 1858 | throw; | 1855 | throw; |
| 1859 | } | 1856 | } |
| 1860 | # endif | 1857 | # endif |
| 1861 | 1858 | ||
| 1862 | if (__does_policy_contain(__policy, launch::deferred)) | 1859 | if (__does_policy_contain(__policy, launch::deferred)) |
| 1863 | return std::__make_deferred_assoc_state<_Rp>( | 1860 | return std::__make_deferred_assoc_state<_Rp>( |
| ... | @@ -1866,13 +1863,12 @@ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | ... | @@ -1866,13 +1863,12 @@ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI |
| 1866 | } | 1863 | } |
| 1867 | 1864 | ||
| 1868 | template <class _Fp, class... _Args> | 1865 | template <class _Fp, class... _Args> |
| 1869 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI | 1866 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> |
| 1870 | future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> | 1867 | async(_Fp&& __f, _Args&&... __args) { |
| 1871 | async(_Fp&& __f, _Args&&... __args) { | ||
| 1872 | return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...); | 1868 | return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...); |
| 1873 | } | 1869 | } |
| 1874 | 1870 | ||
| 1875 | #endif // C++03 | 1871 | # endif // C++03 |
| 1876 | 1872 | ||
| 1877 | // shared_future | 1873 | // shared_future |
| 1878 | 1874 | ||
| ... | @@ -2049,6 +2045,8 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -2049,6 +2045,8 @@ _LIBCPP_END_NAMESPACE_STD |
| 2049 | 2045 | ||
| 2050 | _LIBCPP_POP_MACROS | 2046 | _LIBCPP_POP_MACROS |
| 2051 | 2047 | ||
| 2048 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 2049 | |||
| 2052 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | 2050 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 |
| 2053 | # include <chrono> | 2051 | # include <chrono> |
| 2054 | #endif | 2052 | #endif |
lib/libcxx/include/initializer_list-1| ... | @@ -42,7 +42,6 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in | ... | @@ -42,7 +42,6 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in |
| 42 | 42 | ||
| 43 | */ | 43 | */ |
| 44 | 44 | ||
| 45 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 46 | #include <__config> | 45 | #include <__config> |
| 47 | #include <cstddef> | 46 | #include <cstddef> |
| 48 | 47 |
lib/libcxx/include/iomanip+1-2| ... | @@ -42,7 +42,6 @@ template <class charT, class traits, class Allocator> | ... | @@ -42,7 +42,6 @@ template <class charT, class traits, class Allocator> |
| 42 | 42 | ||
| 43 | */ | 43 | */ |
| 44 | 44 | ||
| 45 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 46 | #include <__config> | 45 | #include <__config> |
| 47 | #include <istream> | 46 | #include <istream> |
| 48 | #include <version> | 47 | #include <version> |
| ... | @@ -464,7 +463,7 @@ struct _LIBCPP_HIDDEN __quoted_output_proxy { | ... | @@ -464,7 +463,7 @@ struct _LIBCPP_HIDDEN __quoted_output_proxy { |
| 464 | _LIBCPP_HIDE_FROM_ABI explicit __quoted_output_proxy(const _CharT* __f, const _CharT* __l, _CharT __d, _CharT __e) | 463 | _LIBCPP_HIDE_FROM_ABI explicit __quoted_output_proxy(const _CharT* __f, const _CharT* __l, _CharT __d, _CharT __e) |
| 465 | : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {} | 464 | : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {} |
| 466 | 465 | ||
| 467 | template <class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value>* = nullptr> | 466 | template <class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value, int> = 0> |
| 468 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>& | 467 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>& |
| 469 | operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) { | 468 | operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) { |
| 470 | return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_); | 469 | return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_); |
lib/libcxx/include/ios+94-49| ... | @@ -213,37 +213,34 @@ storage-class-specifier const error_category& iostream_category() noexcept; | ... | @@ -213,37 +213,34 @@ storage-class-specifier const error_category& iostream_category() noexcept; |
| 213 | 213 | ||
| 214 | #include <__config> | 214 | #include <__config> |
| 215 | 215 | ||
| 216 | #if defined(_LIBCPP_HAS_NO_LOCALIZATION) | 216 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 217 | # error "The iostreams library is not supported since libc++ has been configured without support for localization." | 217 | |
| 218 | #endif | 218 | # include <__fwd/ios.h> |
| 219 | 219 | # include <__ios/fpos.h> | |
| 220 | #include <__assert> // all public C++ headers provide the assertion handler | 220 | # include <__locale> |
| 221 | #include <__fwd/ios.h> | 221 | # include <__system_error/error_category.h> |
| 222 | #include <__ios/fpos.h> | 222 | # include <__system_error/error_code.h> |
| 223 | #include <__locale> | 223 | # include <__system_error/error_condition.h> |
| 224 | #include <__system_error/error_category.h> | 224 | # include <__system_error/system_error.h> |
| 225 | #include <__system_error/error_code.h> | 225 | # include <__utility/swap.h> |
| 226 | #include <__system_error/error_condition.h> | 226 | # include <__verbose_abort> |
| 227 | #include <__system_error/system_error.h> | 227 | # include <version> |
| 228 | #include <__utility/swap.h> | ||
| 229 | #include <__verbose_abort> | ||
| 230 | #include <version> | ||
| 231 | 228 | ||
| 232 | // standard-mandated includes | 229 | // standard-mandated includes |
| 233 | 230 | ||
| 234 | // [ios.syn] | 231 | // [ios.syn] |
| 235 | #include <iosfwd> | 232 | # include <iosfwd> |
| 236 | 233 | ||
| 237 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | 234 | # if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
| 238 | # include <__atomic/atomic.h> // for __xindex_ | 235 | # include <__atomic/atomic.h> // for __xindex_ |
| 239 | #endif | 236 | # endif |
| 240 | 237 | ||
| 241 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 238 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 242 | # pragma GCC system_header | 239 | # pragma GCC system_header |
| 243 | #endif | 240 | # endif |
| 244 | 241 | ||
| 245 | _LIBCPP_PUSH_MACROS | 242 | _LIBCPP_PUSH_MACROS |
| 246 | #include <__undef_macros> | 243 | # include <__undef_macros> |
| 247 | 244 | ||
| 248 | _LIBCPP_BEGIN_NAMESPACE_STD | 245 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 249 | 246 | ||
| ... | @@ -286,20 +283,20 @@ public: | ... | @@ -286,20 +283,20 @@ public: |
| 286 | static const openmode in = 0x08; | 283 | static const openmode in = 0x08; |
| 287 | static const openmode out = 0x10; | 284 | static const openmode out = 0x10; |
| 288 | static const openmode trunc = 0x20; | 285 | static const openmode trunc = 0x20; |
| 289 | #if _LIBCPP_STD_VER >= 23 | 286 | # if _LIBCPP_STD_VER >= 23 |
| 290 | static const openmode noreplace = 0x40; | 287 | static const openmode noreplace = 0x40; |
| 291 | #endif | 288 | # endif |
| 292 | 289 | ||
| 293 | enum seekdir { beg, cur, end }; | 290 | enum seekdir { beg, cur, end }; |
| 294 | 291 | ||
| 295 | #if _LIBCPP_STD_VER <= 14 | 292 | # if _LIBCPP_STD_VER <= 14 |
| 296 | typedef iostate io_state; | 293 | typedef iostate io_state; |
| 297 | typedef openmode open_mode; | 294 | typedef openmode open_mode; |
| 298 | typedef seekdir seek_dir; | 295 | typedef seekdir seek_dir; |
| 299 | 296 | ||
| 300 | typedef std::streamoff streamoff; | 297 | typedef std::streamoff streamoff; |
| 301 | typedef std::streampos streampos; | 298 | typedef std::streampos streampos; |
| 302 | #endif | 299 | # endif |
| 303 | 300 | ||
| 304 | class _LIBCPP_EXPORTED_FROM_ABI Init; | 301 | class _LIBCPP_EXPORTED_FROM_ABI Init; |
| 305 | 302 | ||
| ... | @@ -360,7 +357,13 @@ public: | ... | @@ -360,7 +357,13 @@ public: |
| 360 | } | 357 | } |
| 361 | 358 | ||
| 362 | protected: | 359 | protected: |
| 363 | _LIBCPP_HIDE_FROM_ABI ios_base() { // purposefully does no initialization | 360 | _LIBCPP_HIDE_FROM_ABI ios_base() : __loc_(nullptr) { |
| 361 | // Purposefully does no initialization | ||
| 362 | // | ||
| 363 | // Except for the locale, this is a sentinel to avoid destroying | ||
| 364 | // an uninitialized object. See | ||
| 365 | // test/libcxx/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp | ||
| 366 | // for the details. | ||
| 364 | } | 367 | } |
| 365 | 368 | ||
| 366 | void init(void* __sb); | 369 | void init(void* __sb); |
| ... | @@ -393,11 +396,11 @@ private: | ... | @@ -393,11 +396,11 @@ private: |
| 393 | size_t __event_cap_; | 396 | size_t __event_cap_; |
| 394 | // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only | 397 | // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only |
| 395 | // enabled with clang. | 398 | // enabled with clang. |
| 396 | #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) | 399 | # if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) |
| 397 | static atomic<int> __xindex_; | 400 | static atomic<int> __xindex_; |
| 398 | #else | 401 | # else |
| 399 | static int __xindex_; | 402 | static int __xindex_; |
| 400 | #endif | 403 | # endif |
| 401 | long* __iarray_; | 404 | long* __iarray_; |
| 402 | size_t __iarray_size_; | 405 | size_t __iarray_size_; |
| 403 | size_t __iarray_cap_; | 406 | size_t __iarray_cap_; |
| ... | @@ -413,10 +416,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) | ... | @@ -413,10 +416,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) |
| 413 | template <> | 416 | template <> |
| 414 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {}; | 417 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {}; |
| 415 | 418 | ||
| 416 | #ifdef _LIBCPP_CXX03_LANG | 419 | # ifdef _LIBCPP_CXX03_LANG |
| 417 | template <> | 420 | template <> |
| 418 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {}; | 421 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {}; |
| 419 | #endif | 422 | # endif |
| 420 | 423 | ||
| 421 | _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; | 424 | _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; |
| 422 | 425 | ||
| ... | @@ -437,11 +440,11 @@ public: | ... | @@ -437,11 +440,11 @@ public: |
| 437 | }; | 440 | }; |
| 438 | 441 | ||
| 439 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { | 442 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { |
| 440 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 443 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 441 | throw ios_base::failure(__msg); | 444 | throw ios_base::failure(__msg); |
| 442 | #else | 445 | # else |
| 443 | _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg); | 446 | _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 444 | #endif | 447 | # endif |
| 445 | } | 448 | } |
| 446 | 449 | ||
| 447 | class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init { | 450 | class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init { |
| ... | @@ -516,6 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) { | ... | @@ -516,6 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) { |
| 516 | clear(__rdstate_); | 519 | clear(__rdstate_); |
| 517 | } | 520 | } |
| 518 | 521 | ||
| 522 | template <class _Traits> | ||
| 523 | // Attribute 'packed' is used to keep the layout compatible with the previous | ||
| 524 | // definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS. | ||
| 525 | struct _LIBCPP_PACKED _FillHelper { | ||
| 526 | _LIBCPP_HIDE_FROM_ABI void __init() { __set_ = false; } | ||
| 527 | _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) { | ||
| 528 | __set_ = true; | ||
| 529 | __fill_val_ = __x; | ||
| 530 | return *this; | ||
| 531 | } | ||
| 532 | _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __set_; } | ||
| 533 | _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; } | ||
| 534 | |||
| 535 | private: | ||
| 536 | typename _Traits::int_type __fill_val_; | ||
| 537 | bool __set_; | ||
| 538 | }; | ||
| 539 | |||
| 540 | template <class _Traits> | ||
| 541 | struct _LIBCPP_PACKED _SentinelValueFill { | ||
| 542 | _LIBCPP_HIDE_FROM_ABI void __init() { __fill_val_ = _Traits::eof(); } | ||
| 543 | _LIBCPP_HIDE_FROM_ABI _SentinelValueFill& operator=(typename _Traits::int_type __x) { | ||
| 544 | __fill_val_ = __x; | ||
| 545 | return *this; | ||
| 546 | } | ||
| 547 | _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __fill_val_ != _Traits::eof(); } | ||
| 548 | _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; } | ||
| 549 | |||
| 550 | private: | ||
| 551 | typename _Traits::int_type __fill_val_; | ||
| 552 | }; | ||
| 553 | |||
| 519 | template <class _CharT, class _Traits> | 554 | template <class _CharT, class _Traits> |
| 520 | class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base { | 555 | class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base { |
| 521 | public: | 556 | public: |
| ... | @@ -527,16 +562,16 @@ public: | ... | @@ -527,16 +562,16 @@ public: |
| 527 | typedef typename traits_type::pos_type pos_type; | 562 | typedef typename traits_type::pos_type pos_type; |
| 528 | typedef typename traits_type::off_type off_type; | 563 | typedef typename traits_type::off_type off_type; |
| 529 | 564 | ||
| 530 | static_assert((is_same<_CharT, typename traits_type::char_type>::value), | 565 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 531 | "traits_type::char_type must be the same type as CharT"); | 566 | "traits_type::char_type must be the same type as CharT"); |
| 532 | 567 | ||
| 533 | #ifdef _LIBCPP_CXX03_LANG | 568 | # ifdef _LIBCPP_CXX03_LANG |
| 534 | // Preserve the ability to compare with literal 0, | 569 | // Preserve the ability to compare with literal 0, |
| 535 | // and implicitly convert to bool, but not implicitly convert to int. | 570 | // and implicitly convert to bool, but not implicitly convert to int. |
| 536 | _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; } | 571 | _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; } |
| 537 | #else | 572 | # else |
| 538 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } | 573 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } |
| 539 | #endif | 574 | # endif |
| 540 | 575 | ||
| 541 | _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } | 576 | _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } |
| 542 | _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } | 577 | _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } |
| ... | @@ -572,7 +607,9 @@ public: | ... | @@ -572,7 +607,9 @@ public: |
| 572 | _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const; | 607 | _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const; |
| 573 | 608 | ||
| 574 | protected: | 609 | protected: |
| 575 | _LIBCPP_HIDE_FROM_ABI basic_ios() { // purposefully does no initialization | 610 | _LIBCPP_HIDE_FROM_ABI basic_ios() { |
| 611 | // purposefully does no initialization | ||
| 612 | // since the destructor does nothing this does not have ios_base issues. | ||
| 576 | } | 613 | } |
| 577 | _LIBCPP_HIDE_FROM_ABI void init(basic_streambuf<char_type, traits_type>* __sb); | 614 | _LIBCPP_HIDE_FROM_ABI void init(basic_streambuf<char_type, traits_type>* __sb); |
| 578 | 615 | ||
| ... | @@ -583,7 +620,13 @@ protected: | ... | @@ -583,7 +620,13 @@ protected: |
| 583 | 620 | ||
| 584 | private: | 621 | private: |
| 585 | basic_ostream<char_type, traits_type>* __tie_; | 622 | basic_ostream<char_type, traits_type>* __tie_; |
| 586 | mutable int_type __fill_; | 623 | |
| 624 | #if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE) | ||
| 625 | using _FillType = _FillHelper<traits_type>; | ||
| 626 | #else | ||
| 627 | using _FillType = _SentinelValueFill<traits_type>; | ||
| 628 | #endif | ||
| 629 | mutable _FillType __fill_; | ||
| 587 | }; | 630 | }; |
| 588 | 631 | ||
| 589 | template <class _CharT, class _Traits> | 632 | template <class _CharT, class _Traits> |
| ... | @@ -598,7 +641,7 @@ template <class _CharT, class _Traits> | ... | @@ -598,7 +641,7 @@ template <class _CharT, class _Traits> |
| 598 | inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) { | 641 | inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) { |
| 599 | ios_base::init(__sb); | 642 | ios_base::init(__sb); |
| 600 | __tie_ = nullptr; | 643 | __tie_ = nullptr; |
| 601 | __fill_ = traits_type::eof(); | 644 | __fill_.__init(); |
| 602 | } | 645 | } |
| 603 | 646 | ||
| 604 | template <class _CharT, class _Traits> | 647 | template <class _CharT, class _Traits> |
| ... | @@ -648,16 +691,16 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c) | ... | @@ -648,16 +691,16 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c) |
| 648 | 691 | ||
| 649 | template <class _CharT, class _Traits> | 692 | template <class _CharT, class _Traits> |
| 650 | inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const { | 693 | inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const { |
| 651 | if (traits_type::eq_int_type(traits_type::eof(), __fill_)) | 694 | if (!__fill_.__is_set()) |
| 652 | __fill_ = widen(' '); | 695 | __fill_ = widen(' '); |
| 653 | return __fill_; | 696 | return __fill_.__get(); |
| 654 | } | 697 | } |
| 655 | 698 | ||
| 656 | template <class _CharT, class _Traits> | 699 | template <class _CharT, class _Traits> |
| 657 | inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) { | 700 | inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) { |
| 658 | if (traits_type::eq_int_type(traits_type::eof(), __fill_)) | 701 | if (!__fill_.__is_set()) |
| 659 | __fill_ = widen(' '); | 702 | __fill_ = widen(' '); |
| 660 | char_type __r = __fill_; | 703 | char_type __r = __fill_.__get(); |
| 661 | __fill_ = __ch; | 704 | __fill_ = __ch; |
| 662 | return __r; | 705 | return __r; |
| 663 | } | 706 | } |
| ... | @@ -697,9 +740,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st | ... | @@ -697,9 +740,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st |
| 697 | 740 | ||
| 698 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>; | 741 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>; |
| 699 | 742 | ||
| 700 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 743 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 701 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>; | 744 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>; |
| 702 | #endif | 745 | # endif |
| 703 | 746 | ||
| 704 | _LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) { | 747 | _LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) { |
| 705 | __str.setf(ios_base::boolalpha); | 748 | __str.setf(ios_base::boolalpha); |
| ... | @@ -825,6 +868,8 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -825,6 +868,8 @@ _LIBCPP_END_NAMESPACE_STD |
| 825 | 868 | ||
| 826 | _LIBCPP_POP_MACROS | 869 | _LIBCPP_POP_MACROS |
| 827 | 870 | ||
| 871 | #endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 872 | |||
| 828 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 873 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 829 | # include <atomic> | 874 | # include <atomic> |
| 830 | # include <concepts> | 875 | # include <concepts> |
lib/libcxx/include/iosfwd+6-13| ... | @@ -25,7 +25,6 @@ template<> struct char_traits<wchar_t>; | ... | @@ -25,7 +25,6 @@ template<> struct char_traits<wchar_t>; |
| 25 | 25 | ||
| 26 | template<class T> class allocator; | 26 | template<class T> class allocator; |
| 27 | 27 | ||
| 28 | class ios_base; | ||
| 29 | template <class charT, class traits = char_traits<charT> > class basic_ios; | 28 | template <class charT, class traits = char_traits<charT> > class basic_ios; |
| 30 | 29 | ||
| 31 | template <class charT, class traits = char_traits<charT> > class basic_streambuf; | 30 | template <class charT, class traits = char_traits<charT> > class basic_streambuf; |
| ... | @@ -106,11 +105,11 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 | ... | @@ -106,11 +105,11 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 |
| 106 | 105 | ||
| 107 | */ | 106 | */ |
| 108 | 107 | ||
| 109 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 110 | #include <__config> | 108 | #include <__config> |
| 111 | #include <__fwd/fstream.h> | 109 | #include <__fwd/fstream.h> |
| 112 | #include <__fwd/ios.h> | 110 | #include <__fwd/ios.h> |
| 113 | #include <__fwd/istream.h> | 111 | #include <__fwd/istream.h> |
| 112 | #include <__fwd/memory.h> | ||
| 114 | #include <__fwd/ostream.h> | 113 | #include <__fwd/ostream.h> |
| 115 | #include <__fwd/sstream.h> | 114 | #include <__fwd/sstream.h> |
| 116 | #include <__fwd/streambuf.h> | 115 | #include <__fwd/streambuf.h> |
| ... | @@ -124,8 +123,6 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 | ... | @@ -124,8 +123,6 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 |
| 124 | 123 | ||
| 125 | _LIBCPP_BEGIN_NAMESPACE_STD | 124 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 126 | 125 | ||
| 127 | class _LIBCPP_EXPORTED_FROM_ABI ios_base; | ||
| 128 | |||
| 129 | template <class _CharT, class _Traits = char_traits<_CharT> > | 126 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 130 | class _LIBCPP_TEMPLATE_VIS istreambuf_iterator; | 127 | class _LIBCPP_TEMPLATE_VIS istreambuf_iterator; |
| 131 | template <class _CharT, class _Traits = char_traits<_CharT> > | 128 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| ... | @@ -143,7 +140,7 @@ typedef fpos<mbstate_t> u8streampos; | ... | @@ -143,7 +140,7 @@ typedef fpos<mbstate_t> u8streampos; |
| 143 | typedef fpos<mbstate_t> u16streampos; | 140 | typedef fpos<mbstate_t> u16streampos; |
| 144 | typedef fpos<mbstate_t> u32streampos; | 141 | typedef fpos<mbstate_t> u32streampos; |
| 145 | 142 | ||
| 146 | #if _LIBCPP_STD_VER >= 20 | 143 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) |
| 147 | 144 | ||
| 148 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>> | 145 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>> |
| 149 | class basic_syncbuf; | 146 | class basic_syncbuf; |
| ... | @@ -161,11 +158,7 @@ using osyncstream = basic_osyncstream<char>; | ... | @@ -161,11 +158,7 @@ using osyncstream = basic_osyncstream<char>; |
| 161 | using wosyncstream = basic_osyncstream<wchar_t>; | 158 | using wosyncstream = basic_osyncstream<wchar_t>; |
| 162 | # endif | 159 | # endif |
| 163 | 160 | ||
| 164 | #endif // _LIBCPP_STD_VER >=20 | 161 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) |
| 165 | |||
| 166 | // Include other forward declarations here | ||
| 167 | template <class _Tp, class _Alloc = allocator<_Tp> > | ||
| 168 | class _LIBCPP_TEMPLATE_VIS vector; | ||
| 169 | 162 | ||
| 170 | template <class _CharT, class _Traits> | 163 | template <class _CharT, class _Traits> |
| 171 | class __save_flags { | 164 | class __save_flags { |
| ... | @@ -176,10 +169,10 @@ class __save_flags { | ... | @@ -176,10 +169,10 @@ class __save_flags { |
| 176 | fmtflags __fmtflags_; | 169 | fmtflags __fmtflags_; |
| 177 | _CharT __fill_; | 170 | _CharT __fill_; |
| 178 | 171 | ||
| 179 | __save_flags(const __save_flags&); | ||
| 180 | __save_flags& operator=(const __save_flags&); | ||
| 181 | |||
| 182 | public: | 172 | public: |
| 173 | __save_flags(const __save_flags&) = delete; | ||
| 174 | __save_flags& operator=(const __save_flags&) = delete; | ||
| 175 | |||
| 183 | _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream) | 176 | _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream) |
| 184 | : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {} | 177 | : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {} |
| 185 | _LIBCPP_HIDE_FROM_ABI ~__save_flags() { | 178 | _LIBCPP_HIDE_FROM_ABI ~__save_flags() { |
lib/libcxx/include/iostream-1| ... | @@ -33,7 +33,6 @@ extern wostream wclog; | ... | @@ -33,7 +33,6 @@ extern wostream wclog; |
| 33 | 33 | ||
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 37 | #include <__config> | 36 | #include <__config> |
| 38 | #include <version> | 37 | #include <version> |
| 39 | 38 |
lib/libcxx/include/istream+11-7| ... | @@ -158,16 +158,18 @@ template <class Stream, class T> | ... | @@ -158,16 +158,18 @@ template <class Stream, class T> |
| 158 | 158 | ||
| 159 | */ | 159 | */ |
| 160 | 160 | ||
| 161 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 162 | #include <__config> | 161 | #include <__config> |
| 163 | #include <__fwd/istream.h> | 162 | #include <__fwd/istream.h> |
| 164 | #include <__iterator/istreambuf_iterator.h> | 163 | #include <__iterator/istreambuf_iterator.h> |
| 164 | #include <__ostream/basic_ostream.h> | ||
| 165 | #include <__type_traits/conjunction.h> | 165 | #include <__type_traits/conjunction.h> |
| 166 | #include <__type_traits/enable_if.h> | 166 | #include <__type_traits/enable_if.h> |
| 167 | #include <__type_traits/is_base_of.h> | 167 | #include <__type_traits/is_base_of.h> |
| 168 | #include <__utility/declval.h> | 168 | #include <__utility/declval.h> |
| 169 | #include <__utility/forward.h> | 169 | #include <__utility/forward.h> |
| 170 | #include <ostream> | 170 | #include <bitset> |
| 171 | #include <ios> | ||
| 172 | #include <locale> | ||
| 171 | #include <version> | 173 | #include <version> |
| 172 | 174 | ||
| 173 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 175 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -214,10 +216,10 @@ protected: | ... | @@ -214,10 +216,10 @@ protected: |
| 214 | basic_ios<char_type, traits_type>::swap(__rhs); | 216 | basic_ios<char_type, traits_type>::swap(__rhs); |
| 215 | } | 217 | } |
| 216 | 218 | ||
| 219 | public: | ||
| 217 | basic_istream(const basic_istream& __rhs) = delete; | 220 | basic_istream(const basic_istream& __rhs) = delete; |
| 218 | basic_istream& operator=(const basic_istream& __rhs) = delete; | 221 | basic_istream& operator=(const basic_istream& __rhs) = delete; |
| 219 | 222 | ||
| 220 | public: | ||
| 221 | // 27.7.1.1.3 Prefix/suffix: | 223 | // 27.7.1.1.3 Prefix/suffix: |
| 222 | class _LIBCPP_TEMPLATE_VIS sentry; | 224 | class _LIBCPP_TEMPLATE_VIS sentry; |
| 223 | 225 | ||
| ... | @@ -1009,17 +1011,18 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { | ... | @@ -1009,17 +1011,18 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { |
| 1009 | template <class _CharT, class _Traits> | 1011 | template <class _CharT, class _Traits> |
| 1010 | int basic_istream<_CharT, _Traits>::sync() { | 1012 | int basic_istream<_CharT, _Traits>::sync() { |
| 1011 | ios_base::iostate __state = ios_base::goodbit; | 1013 | ios_base::iostate __state = ios_base::goodbit; |
| 1012 | int __r = 0; | ||
| 1013 | sentry __sen(*this, true); | 1014 | sentry __sen(*this, true); |
| 1015 | if (this->rdbuf() == nullptr) | ||
| 1016 | return -1; | ||
| 1017 | |||
| 1018 | int __r = 0; | ||
| 1014 | if (__sen) { | 1019 | if (__sen) { |
| 1015 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1020 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1016 | try { | 1021 | try { |
| 1017 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1022 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1018 | if (this->rdbuf() == nullptr) | ||
| 1019 | return -1; | ||
| 1020 | if (this->rdbuf()->pubsync() == -1) { | 1023 | if (this->rdbuf()->pubsync() == -1) { |
| 1021 | __state |= ios_base::badbit; | 1024 | __state |= ios_base::badbit; |
| 1022 | return -1; | 1025 | __r = -1; |
| 1023 | } | 1026 | } |
| 1024 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1027 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1025 | } catch (...) { | 1028 | } catch (...) { |
| ... | @@ -1361,6 +1364,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -1361,6 +1364,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 1361 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 1364 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 1362 | # include <concepts> | 1365 | # include <concepts> |
| 1363 | # include <iosfwd> | 1366 | # include <iosfwd> |
| 1367 | # include <ostream> | ||
| 1364 | # include <type_traits> | 1368 | # include <type_traits> |
| 1365 | #endif | 1369 | #endif |
| 1366 | 1370 |
lib/libcxx/include/iterator+38-24| ... | @@ -475,6 +475,11 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17 | ... | @@ -475,6 +475,11 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17 |
| 475 | template <class Iterator> // constexpr in C++17 | 475 | template <class Iterator> // constexpr in C++17 |
| 476 | constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i); | 476 | constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i); |
| 477 | 477 | ||
| 478 | template<class Iterator1, class Iterator2> | ||
| 479 | requires (!sized_sentinel_for<Iterator1, Iterator2>) | ||
| 480 | inline constexpr bool disable_sized_sentinel_for<move_iterator<Iterator1>, // since C++20 | ||
| 481 | move_iterator<Iterator2>> = true; | ||
| 482 | |||
| 478 | template<semiregular S> | 483 | template<semiregular S> |
| 479 | class move_sentinel { | 484 | class move_sentinel { |
| 480 | public: | 485 | public: |
| ... | @@ -674,48 +679,53 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; | ... | @@ -674,48 +679,53 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 674 | 679 | ||
| 675 | */ | 680 | */ |
| 676 | 681 | ||
| 677 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 678 | #include <__config> | 682 | #include <__config> |
| 679 | #include <__iterator/access.h> | 683 | #include <__iterator/access.h> |
| 680 | #include <__iterator/advance.h> | 684 | #include <__iterator/advance.h> |
| 681 | #include <__iterator/back_insert_iterator.h> | 685 | #include <__iterator/back_insert_iterator.h> |
| 682 | #include <__iterator/bounded_iter.h> | ||
| 683 | #include <__iterator/common_iterator.h> | ||
| 684 | #include <__iterator/concepts.h> | ||
| 685 | #include <__iterator/counted_iterator.h> | ||
| 686 | #include <__iterator/data.h> | ||
| 687 | #include <__iterator/default_sentinel.h> | ||
| 688 | #include <__iterator/distance.h> | 686 | #include <__iterator/distance.h> |
| 689 | #include <__iterator/empty.h> | ||
| 690 | #include <__iterator/erase_if_container.h> | ||
| 691 | #include <__iterator/front_insert_iterator.h> | 687 | #include <__iterator/front_insert_iterator.h> |
| 692 | #include <__iterator/incrementable_traits.h> | ||
| 693 | #include <__iterator/indirectly_comparable.h> | ||
| 694 | #include <__iterator/insert_iterator.h> | 688 | #include <__iterator/insert_iterator.h> |
| 695 | #include <__iterator/istream_iterator.h> | 689 | #include <__iterator/istream_iterator.h> |
| 696 | #include <__iterator/istreambuf_iterator.h> | 690 | #include <__iterator/istreambuf_iterator.h> |
| 697 | #include <__iterator/iter_move.h> | ||
| 698 | #include <__iterator/iter_swap.h> | ||
| 699 | #include <__iterator/iterator.h> | 691 | #include <__iterator/iterator.h> |
| 700 | #include <__iterator/iterator_traits.h> | 692 | #include <__iterator/iterator_traits.h> |
| 701 | #include <__iterator/mergeable.h> | ||
| 702 | #include <__iterator/move_iterator.h> | 693 | #include <__iterator/move_iterator.h> |
| 703 | #include <__iterator/move_sentinel.h> | ||
| 704 | #include <__iterator/next.h> | 694 | #include <__iterator/next.h> |
| 705 | #include <__iterator/ostream_iterator.h> | 695 | #include <__iterator/ostream_iterator.h> |
| 706 | #include <__iterator/ostreambuf_iterator.h> | 696 | #include <__iterator/ostreambuf_iterator.h> |
| 707 | #include <__iterator/permutable.h> | ||
| 708 | #include <__iterator/prev.h> | 697 | #include <__iterator/prev.h> |
| 709 | #include <__iterator/projected.h> | ||
| 710 | #include <__iterator/readable_traits.h> | ||
| 711 | #include <__iterator/reverse_access.h> | ||
| 712 | #include <__iterator/reverse_iterator.h> | 698 | #include <__iterator/reverse_iterator.h> |
| 713 | #include <__iterator/size.h> | ||
| 714 | #include <__iterator/sortable.h> | ||
| 715 | #include <__iterator/unreachable_sentinel.h> | ||
| 716 | #include <__iterator/wrap_iter.h> | 699 | #include <__iterator/wrap_iter.h> |
| 717 | #include <__memory/addressof.h> | 700 | |
| 718 | #include <__memory/pointer_traits.h> | 701 | #if _LIBCPP_STD_VER >= 14 |
| 702 | # include <__iterator/reverse_access.h> | ||
| 703 | #endif | ||
| 704 | |||
| 705 | #if _LIBCPP_STD_VER >= 17 | ||
| 706 | # include <__iterator/data.h> | ||
| 707 | # include <__iterator/empty.h> | ||
| 708 | # include <__iterator/size.h> | ||
| 709 | #endif | ||
| 710 | |||
| 711 | #if _LIBCPP_STD_VER >= 20 | ||
| 712 | # include <__iterator/common_iterator.h> | ||
| 713 | # include <__iterator/concepts.h> | ||
| 714 | # include <__iterator/counted_iterator.h> | ||
| 715 | # include <__iterator/default_sentinel.h> | ||
| 716 | # include <__iterator/incrementable_traits.h> | ||
| 717 | # include <__iterator/indirectly_comparable.h> | ||
| 718 | # include <__iterator/iter_move.h> | ||
| 719 | # include <__iterator/iter_swap.h> | ||
| 720 | # include <__iterator/mergeable.h> | ||
| 721 | # include <__iterator/move_sentinel.h> | ||
| 722 | # include <__iterator/permutable.h> | ||
| 723 | # include <__iterator/projected.h> | ||
| 724 | # include <__iterator/readable_traits.h> | ||
| 725 | # include <__iterator/sortable.h> | ||
| 726 | # include <__iterator/unreachable_sentinel.h> | ||
| 727 | #endif | ||
| 728 | |||
| 719 | #include <version> | 729 | #include <version> |
| 720 | 730 | ||
| 721 | // standard-mandated includes | 731 | // standard-mandated includes |
| ... | @@ -728,6 +738,10 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; | ... | @@ -728,6 +738,10 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 728 | # pragma GCC system_header | 738 | # pragma GCC system_header |
| 729 | #endif | 739 | #endif |
| 730 | 740 | ||
| 741 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | ||
| 742 | # include <variant> | ||
| 743 | #endif | ||
| 744 | |||
| 731 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 745 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 732 | # include <cstdlib> | 746 | # include <cstdlib> |
| 733 | # include <exception> | 747 | # include <exception> |
lib/libcxx/include/latch+27-21| ... | @@ -42,31 +42,28 @@ namespace std | ... | @@ -42,31 +42,28 @@ namespace std |
| 42 | 42 | ||
| 43 | #include <__config> | 43 | #include <__config> |
| 44 | 44 | ||
| 45 | #ifdef _LIBCPP_HAS_NO_THREADS | 45 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 46 | # error "<latch> is not supported since libc++ has been configured without support for threads." | ||
| 47 | #endif | ||
| 48 | 46 | ||
| 49 | #include <__assert> // all public C++ headers provide the assertion handler | 47 | # include <__assert> |
| 50 | #include <__atomic/atomic_base.h> | 48 | # include <__atomic/atomic_base.h> |
| 51 | #include <__atomic/atomic_sync.h> | 49 | # include <__atomic/atomic_sync.h> |
| 52 | #include <__atomic/memory_order.h> | 50 | # include <__atomic/memory_order.h> |
| 53 | #include <__availability> | 51 | # include <cstddef> |
| 54 | #include <cstddef> | 52 | # include <limits> |
| 55 | #include <limits> | 53 | # include <version> |
| 56 | #include <version> | 54 | |
| 57 | 55 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 58 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 56 | # pragma GCC system_header |
| 59 | # pragma GCC system_header | 57 | # endif |
| 60 | #endif | ||
| 61 | 58 | ||
| 62 | _LIBCPP_PUSH_MACROS | 59 | _LIBCPP_PUSH_MACROS |
| 63 | #include <__undef_macros> | 60 | # include <__undef_macros> |
| 64 | 61 | ||
| 65 | #if _LIBCPP_STD_VER >= 14 | 62 | # if _LIBCPP_STD_VER >= 14 |
| 66 | 63 | ||
| 67 | _LIBCPP_BEGIN_NAMESPACE_STD | 64 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 68 | 65 | ||
| 69 | class latch { | 66 | class _LIBCPP_DEPRECATED_ATOMIC_SYNC latch { |
| 70 | __atomic_base<ptrdiff_t> __a_; | 67 | __atomic_base<ptrdiff_t> __a_; |
| 71 | 68 | ||
| 72 | public: | 69 | public: |
| ... | @@ -97,9 +94,13 @@ public: | ... | @@ -97,9 +94,13 @@ public: |
| 97 | if (__old == __update) | 94 | if (__old == __update) |
| 98 | __a_.notify_all(); | 95 | __a_.notify_all(); |
| 99 | } | 96 | } |
| 100 | inline _LIBCPP_HIDE_FROM_ABI bool try_wait() const noexcept { return 0 == __a_.load(memory_order_acquire); } | 97 | inline _LIBCPP_HIDE_FROM_ABI bool try_wait() const noexcept { |
| 98 | auto __value = __a_.load(memory_order_acquire); | ||
| 99 | return try_wait_impl(__value); | ||
| 100 | } | ||
| 101 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const { | 101 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const { |
| 102 | __cxx_atomic_wait(&__a_.__a_, [this]() -> bool { return try_wait(); }); | 102 | std::__atomic_wait_unless( |
| 103 | __a_, [this](ptrdiff_t& __value) -> bool { return try_wait_impl(__value); }, memory_order_acquire); | ||
| 103 | } | 104 | } |
| 104 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) { | 105 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) { |
| 105 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value"); | 106 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value"); |
| ... | @@ -108,14 +109,19 @@ public: | ... | @@ -108,14 +109,19 @@ public: |
| 108 | count_down(__update); | 109 | count_down(__update); |
| 109 | wait(); | 110 | wait(); |
| 110 | } | 111 | } |
| 112 | |||
| 113 | private: | ||
| 114 | _LIBCPP_HIDE_FROM_ABI bool try_wait_impl(ptrdiff_t& __value) const noexcept { return __value == 0; } | ||
| 111 | }; | 115 | }; |
| 112 | 116 | ||
| 113 | _LIBCPP_END_NAMESPACE_STD | 117 | _LIBCPP_END_NAMESPACE_STD |
| 114 | 118 | ||
| 115 | #endif // _LIBCPP_STD_VER >= 14 | 119 | # endif // _LIBCPP_STD_VER >= 14 |
| 116 | 120 | ||
| 117 | _LIBCPP_POP_MACROS | 121 | _LIBCPP_POP_MACROS |
| 118 | 122 | ||
| 123 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 124 | |||
| 119 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 125 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 120 | # include <atomic> | 126 | # include <atomic> |
| 121 | #endif | 127 | #endif |
lib/libcxx/include/limits+104-342| ... | @@ -102,7 +102,6 @@ template<> class numeric_limits<cv long double>; | ... | @@ -102,7 +102,6 @@ template<> class numeric_limits<cv long double>; |
| 102 | 102 | ||
| 103 | */ | 103 | */ |
| 104 | 104 | ||
| 105 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 106 | #include <__config> | 105 | #include <__config> |
| 107 | #include <__type_traits/is_arithmetic.h> | 106 | #include <__type_traits/is_arithmetic.h> |
| 108 | #include <__type_traits/is_signed.h> | 107 | #include <__type_traits/is_signed.h> |
| ... | @@ -138,9 +137,9 @@ protected: | ... | @@ -138,9 +137,9 @@ protected: |
| 138 | typedef _Tp type; | 137 | typedef _Tp type; |
| 139 | 138 | ||
| 140 | static _LIBCPP_CONSTEXPR const bool is_specialized = false; | 139 | static _LIBCPP_CONSTEXPR const bool is_specialized = false; |
| 141 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } | 140 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } |
| 142 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } | 141 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } |
| 143 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } | 142 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } |
| 144 | 143 | ||
| 145 | static _LIBCPP_CONSTEXPR const int digits = 0; | 144 | static _LIBCPP_CONSTEXPR const int digits = 0; |
| 146 | static _LIBCPP_CONSTEXPR const int digits10 = 0; | 145 | static _LIBCPP_CONSTEXPR const int digits10 = 0; |
| ... | @@ -149,8 +148,8 @@ protected: | ... | @@ -149,8 +148,8 @@ protected: |
| 149 | static _LIBCPP_CONSTEXPR const bool is_integer = false; | 148 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 150 | static _LIBCPP_CONSTEXPR const bool is_exact = false; | 149 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 151 | static _LIBCPP_CONSTEXPR const int radix = 0; | 150 | static _LIBCPP_CONSTEXPR const int radix = 0; |
| 152 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } | 151 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } |
| 153 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } | 152 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } |
| 154 | 153 | ||
| 155 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; | 154 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; |
| 156 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; | 155 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; |
| ... | @@ -162,10 +161,10 @@ protected: | ... | @@ -162,10 +161,10 @@ protected: |
| 162 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; | 161 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; |
| 163 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; | 162 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; |
| 164 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; | 163 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 165 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } | 164 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } |
| 166 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } | 165 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } |
| 167 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } | 166 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } |
| 168 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } | 167 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } |
| 169 | 168 | ||
| 170 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; | 169 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 171 | static _LIBCPP_CONSTEXPR const bool is_bounded = false; | 170 | static _LIBCPP_CONSTEXPR const bool is_bounded = false; |
| ... | @@ -199,15 +198,15 @@ protected: | ... | @@ -199,15 +198,15 @@ protected: |
| 199 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; | 198 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; |
| 200 | static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value; | 199 | static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value; |
| 201 | static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); | 200 | static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); |
| 202 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | 201 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } |
| 203 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | 202 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } |
| 204 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | 203 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } |
| 205 | 204 | ||
| 206 | static _LIBCPP_CONSTEXPR const bool is_integer = true; | 205 | static _LIBCPP_CONSTEXPR const bool is_integer = true; |
| 207 | static _LIBCPP_CONSTEXPR const bool is_exact = true; | 206 | static _LIBCPP_CONSTEXPR const bool is_exact = true; |
| 208 | static _LIBCPP_CONSTEXPR const int radix = 2; | 207 | static _LIBCPP_CONSTEXPR const int radix = 2; |
| 209 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } | 208 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } |
| 210 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } | 209 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } |
| 211 | 210 | ||
| 212 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; | 211 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; |
| 213 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; | 212 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; |
| ... | @@ -219,10 +218,10 @@ protected: | ... | @@ -219,10 +218,10 @@ protected: |
| 219 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; | 218 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; |
| 220 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; | 219 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; |
| 221 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; | 220 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 222 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } | 221 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } |
| 223 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } | 222 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } |
| 224 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } | 223 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } |
| 225 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } | 224 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } |
| 226 | 225 | ||
| 227 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; | 226 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 228 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; | 227 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| ... | @@ -250,15 +249,15 @@ protected: | ... | @@ -250,15 +249,15 @@ protected: |
| 250 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; | 249 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; |
| 251 | static _LIBCPP_CONSTEXPR const type __min = false; | 250 | static _LIBCPP_CONSTEXPR const type __min = false; |
| 252 | static _LIBCPP_CONSTEXPR const type __max = true; | 251 | static _LIBCPP_CONSTEXPR const type __max = true; |
| 253 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | 252 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } |
| 254 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | 253 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } |
| 255 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | 254 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } |
| 256 | 255 | ||
| 257 | static _LIBCPP_CONSTEXPR const bool is_integer = true; | 256 | static _LIBCPP_CONSTEXPR const bool is_integer = true; |
| 258 | static _LIBCPP_CONSTEXPR const bool is_exact = true; | 257 | static _LIBCPP_CONSTEXPR const bool is_exact = true; |
| 259 | static _LIBCPP_CONSTEXPR const int radix = 2; | 258 | static _LIBCPP_CONSTEXPR const int radix = 2; |
| 260 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } | 259 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } |
| 261 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } | 260 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } |
| 262 | 261 | ||
| 263 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; | 262 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; |
| 264 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; | 263 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; |
| ... | @@ -270,10 +269,10 @@ protected: | ... | @@ -270,10 +269,10 @@ protected: |
| 270 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; | 269 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; |
| 271 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; | 270 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; |
| 272 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; | 271 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 273 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } | 272 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } |
| 274 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } | 273 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } |
| 275 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } | 274 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } |
| 276 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } | 275 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } |
| 277 | 276 | ||
| 278 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; | 277 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 279 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; | 278 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| ... | @@ -295,15 +294,15 @@ protected: | ... | @@ -295,15 +294,15 @@ protected: |
| 295 | static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__; | 294 | static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__; |
| 296 | static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__; | 295 | static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__; |
| 297 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; | 296 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; |
| 298 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } | 297 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } |
| 299 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } | 298 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } |
| 300 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | 299 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } |
| 301 | 300 | ||
| 302 | static _LIBCPP_CONSTEXPR const bool is_integer = false; | 301 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 303 | static _LIBCPP_CONSTEXPR const bool is_exact = false; | 302 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 304 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; | 303 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; |
| 305 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } | 304 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } |
| 306 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } | 305 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } |
| 307 | 306 | ||
| 308 | static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__; | 307 | static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__; |
| 309 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__; | 308 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__; |
| ... | @@ -315,10 +314,18 @@ protected: | ... | @@ -315,10 +314,18 @@ protected: |
| 315 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; | 314 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; |
| 316 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; | 315 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; |
| 317 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; | 316 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 318 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_valf(); } | 317 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { |
| 319 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanf(""); } | 318 | return __builtin_huge_valf(); |
| 320 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansf(""); } | 319 | } |
| 321 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __FLT_DENORM_MIN__; } | 320 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { |
| 321 | return __builtin_nanf(""); | ||
| 322 | } | ||
| 323 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | ||
| 324 | return __builtin_nansf(""); | ||
| 325 | } | ||
| 326 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | ||
| 327 | return __FLT_DENORM_MIN__; | ||
| 328 | } | ||
| 322 | 329 | ||
| 323 | static _LIBCPP_CONSTEXPR const bool is_iec559 = true; | 330 | static _LIBCPP_CONSTEXPR const bool is_iec559 = true; |
| 324 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; | 331 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| ... | @@ -344,15 +351,15 @@ protected: | ... | @@ -344,15 +351,15 @@ protected: |
| 344 | static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__; | 351 | static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__; |
| 345 | static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__; | 352 | static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__; |
| 346 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; | 353 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; |
| 347 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } | 354 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } |
| 348 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } | 355 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } |
| 349 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | 356 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } |
| 350 | 357 | ||
| 351 | static _LIBCPP_CONSTEXPR const bool is_integer = false; | 358 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 352 | static _LIBCPP_CONSTEXPR const bool is_exact = false; | 359 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 353 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; | 360 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; |
| 354 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } | 361 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } |
| 355 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } | 362 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } |
| 356 | 363 | ||
| 357 | static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__; | 364 | static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__; |
| 358 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__; | 365 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__; |
| ... | @@ -364,10 +371,18 @@ protected: | ... | @@ -364,10 +371,18 @@ protected: |
| 364 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; | 371 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; |
| 365 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; | 372 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; |
| 366 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; | 373 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 367 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_val(); } | 374 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { |
| 368 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nan(""); } | 375 | return __builtin_huge_val(); |
| 369 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nans(""); } | 376 | } |
| 370 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __DBL_DENORM_MIN__; } | 377 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { |
| 378 | return __builtin_nan(""); | ||
| 379 | } | ||
| 380 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | ||
| 381 | return __builtin_nans(""); | ||
| 382 | } | ||
| 383 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | ||
| 384 | return __DBL_DENORM_MIN__; | ||
| 385 | } | ||
| 371 | 386 | ||
| 372 | static _LIBCPP_CONSTEXPR const bool is_iec559 = true; | 387 | static _LIBCPP_CONSTEXPR const bool is_iec559 = true; |
| 373 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; | 388 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| ... | @@ -393,15 +408,15 @@ protected: | ... | @@ -393,15 +408,15 @@ protected: |
| 393 | static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__; | 408 | static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__; |
| 394 | static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__; | 409 | static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__; |
| 395 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; | 410 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; |
| 396 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } | 411 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } |
| 397 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } | 412 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } |
| 398 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | 413 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } |
| 399 | 414 | ||
| 400 | static _LIBCPP_CONSTEXPR const bool is_integer = false; | 415 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 401 | static _LIBCPP_CONSTEXPR const bool is_exact = false; | 416 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 402 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; | 417 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; |
| 403 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } | 418 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } |
| 404 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } | 419 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } |
| 405 | 420 | ||
| 406 | static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__; | 421 | static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__; |
| 407 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__; | 422 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__; |
| ... | @@ -413,10 +428,18 @@ protected: | ... | @@ -413,10 +428,18 @@ protected: |
| 413 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; | 428 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; |
| 414 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; | 429 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; |
| 415 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; | 430 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 416 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_vall(); } | 431 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { |
| 417 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanl(""); } | 432 | return __builtin_huge_vall(); |
| 418 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansl(""); } | 433 | } |
| 419 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __LDBL_DENORM_MIN__; } | 434 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { |
| 435 | return __builtin_nanl(""); | ||
| 436 | } | ||
| 437 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | ||
| 438 | return __builtin_nansl(""); | ||
| 439 | } | ||
| 440 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | ||
| 441 | return __LDBL_DENORM_MIN__; | ||
| 442 | } | ||
| 420 | 443 | ||
| 421 | #if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) | 444 | #if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) |
| 422 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; | 445 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| ... | @@ -436,15 +459,15 @@ protected: | ... | @@ -436,15 +459,15 @@ protected: |
| 436 | }; | 459 | }; |
| 437 | 460 | ||
| 438 | template <class _Tp> | 461 | template <class _Tp> |
| 439 | class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<__remove_cv_t<_Tp> > { | 462 | class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> { |
| 440 | typedef __libcpp_numeric_limits<__remove_cv_t<_Tp> > __base; | 463 | typedef __libcpp_numeric_limits<_Tp> __base; |
| 441 | typedef typename __base::type type; | 464 | typedef typename __base::type type; |
| 442 | 465 | ||
| 443 | public: | 466 | public: |
| 444 | static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; | 467 | static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; |
| 445 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } | 468 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } |
| 446 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } | 469 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } |
| 447 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } | 470 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } |
| 448 | 471 | ||
| 449 | static _LIBCPP_CONSTEXPR const int digits = __base::digits; | 472 | static _LIBCPP_CONSTEXPR const int digits = __base::digits; |
| 450 | static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; | 473 | static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; |
| ... | @@ -453,8 +476,12 @@ public: | ... | @@ -453,8 +476,12 @@ public: |
| 453 | static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; | 476 | static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; |
| 454 | static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; | 477 | static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; |
| 455 | static _LIBCPP_CONSTEXPR const int radix = __base::radix; | 478 | static _LIBCPP_CONSTEXPR const int radix = __base::radix; |
| 456 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } | 479 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { |
| 457 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); } | 480 | return __base::epsilon(); |
| 481 | } | ||
| 482 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { | ||
| 483 | return __base::round_error(); | ||
| 484 | } | ||
| 458 | 485 | ||
| 459 | static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; | 486 | static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; |
| 460 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; | 487 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; |
| ... | @@ -468,10 +495,18 @@ public: | ... | @@ -468,10 +495,18 @@ public: |
| 468 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; | 495 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; |
| 469 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; | 496 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; |
| 470 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 497 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 471 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); } | 498 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { |
| 472 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } | 499 | return __base::infinity(); |
| 473 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } | 500 | } |
| 474 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); } | 501 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { |
| 502 | return __base::quiet_NaN(); | ||
| 503 | } | ||
| 504 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | ||
| 505 | return __base::signaling_NaN(); | ||
| 506 | } | ||
| 507 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | ||
| 508 | return __base::denorm_min(); | ||
| 509 | } | ||
| 475 | 510 | ||
| 476 | static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; | 511 | static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; |
| 477 | static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; | 512 | static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; |
| ... | @@ -530,286 +565,13 @@ template <class _Tp> | ... | @@ -530,286 +565,13 @@ template <class _Tp> |
| 530 | _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; | 565 | _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; |
| 531 | 566 | ||
| 532 | template <class _Tp> | 567 | template <class _Tp> |
| 533 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : private numeric_limits<_Tp> { | 568 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {}; |
| 534 | typedef numeric_limits<_Tp> __base; | ||
| 535 | typedef _Tp type; | ||
| 536 | |||
| 537 | public: | ||
| 538 | static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; | ||
| 539 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } | ||
| 540 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } | ||
| 541 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } | ||
| 542 | |||
| 543 | static _LIBCPP_CONSTEXPR const int digits = __base::digits; | ||
| 544 | static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; | ||
| 545 | static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; | ||
| 546 | static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; | ||
| 547 | static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; | ||
| 548 | static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; | ||
| 549 | static _LIBCPP_CONSTEXPR const int radix = __base::radix; | ||
| 550 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } | ||
| 551 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); } | ||
| 552 | |||
| 553 | static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; | ||
| 554 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; | ||
| 555 | static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; | ||
| 556 | static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; | ||
| 557 | |||
| 558 | static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; | ||
| 559 | static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; | ||
| 560 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; | ||
| 561 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 562 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; | ||
| 563 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; | ||
| 564 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 565 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); } | ||
| 566 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } | ||
| 567 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } | ||
| 568 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); } | ||
| 569 | |||
| 570 | static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; | ||
| 571 | static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; | ||
| 572 | static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; | ||
| 573 | |||
| 574 | static _LIBCPP_CONSTEXPR const bool traps = __base::traps; | ||
| 575 | static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; | ||
| 576 | static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; | ||
| 577 | }; | ||
| 578 | |||
| 579 | template <class _Tp> | ||
| 580 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_specialized; | ||
| 581 | template <class _Tp> | ||
| 582 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits; | ||
| 583 | template <class _Tp> | ||
| 584 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits10; | ||
| 585 | template <class _Tp> | ||
| 586 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_digits10; | ||
| 587 | template <class _Tp> | ||
| 588 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_signed; | ||
| 589 | template <class _Tp> | ||
| 590 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_integer; | ||
| 591 | template <class _Tp> | ||
| 592 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_exact; | ||
| 593 | template <class _Tp> | ||
| 594 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::radix; | ||
| 595 | template <class _Tp> | ||
| 596 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent; | ||
| 597 | template <class _Tp> | ||
| 598 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent10; | ||
| 599 | template <class _Tp> | ||
| 600 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent; | ||
| 601 | template <class _Tp> | ||
| 602 | _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent10; | ||
| 603 | template <class _Tp> | ||
| 604 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_infinity; | ||
| 605 | template <class _Tp> | ||
| 606 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_quiet_NaN; | ||
| 607 | template <class _Tp> | ||
| 608 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_signaling_NaN; | ||
| 609 | template <class _Tp> | ||
| 610 | _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const _Tp>::has_denorm; | ||
| 611 | template <class _Tp> | ||
| 612 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_denorm_loss; | ||
| 613 | template <class _Tp> | ||
| 614 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_iec559; | ||
| 615 | template <class _Tp> | ||
| 616 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_bounded; | ||
| 617 | template <class _Tp> | ||
| 618 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_modulo; | ||
| 619 | template <class _Tp> | ||
| 620 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::traps; | ||
| 621 | template <class _Tp> | ||
| 622 | _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::tinyness_before; | ||
| 623 | template <class _Tp> | ||
| 624 | _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style; | ||
| 625 | |||
| 626 | template <class _Tp> | ||
| 627 | class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : private numeric_limits<_Tp> { | ||
| 628 | typedef numeric_limits<_Tp> __base; | ||
| 629 | typedef _Tp type; | ||
| 630 | |||
| 631 | public: | ||
| 632 | static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; | ||
| 633 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } | ||
| 634 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } | ||
| 635 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } | ||
| 636 | |||
| 637 | static _LIBCPP_CONSTEXPR const int digits = __base::digits; | ||
| 638 | static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; | ||
| 639 | static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; | ||
| 640 | static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; | ||
| 641 | static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; | ||
| 642 | static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; | ||
| 643 | static _LIBCPP_CONSTEXPR const int radix = __base::radix; | ||
| 644 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } | ||
| 645 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); } | ||
| 646 | |||
| 647 | static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; | ||
| 648 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; | ||
| 649 | static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; | ||
| 650 | static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; | ||
| 651 | |||
| 652 | static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; | ||
| 653 | static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; | ||
| 654 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; | ||
| 655 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 656 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; | ||
| 657 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; | ||
| 658 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 659 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); } | ||
| 660 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } | ||
| 661 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } | ||
| 662 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); } | ||
| 663 | |||
| 664 | static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; | ||
| 665 | static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; | ||
| 666 | static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; | ||
| 667 | |||
| 668 | static _LIBCPP_CONSTEXPR const bool traps = __base::traps; | ||
| 669 | static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; | ||
| 670 | static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; | ||
| 671 | }; | ||
| 672 | |||
| 673 | template <class _Tp> | ||
| 674 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_specialized; | ||
| 675 | template <class _Tp> | ||
| 676 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits; | ||
| 677 | template <class _Tp> | ||
| 678 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits10; | ||
| 679 | template <class _Tp> | ||
| 680 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_digits10; | ||
| 681 | template <class _Tp> | ||
| 682 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_signed; | ||
| 683 | template <class _Tp> | ||
| 684 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_integer; | ||
| 685 | template <class _Tp> | ||
| 686 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_exact; | ||
| 687 | template <class _Tp> | ||
| 688 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::radix; | ||
| 689 | template <class _Tp> | ||
| 690 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent; | ||
| 691 | template <class _Tp> | ||
| 692 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent10; | ||
| 693 | template <class _Tp> | ||
| 694 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent; | ||
| 695 | template <class _Tp> | ||
| 696 | _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent10; | ||
| 697 | template <class _Tp> | ||
| 698 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_infinity; | ||
| 699 | template <class _Tp> | ||
| 700 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_quiet_NaN; | ||
| 701 | template <class _Tp> | ||
| 702 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_signaling_NaN; | ||
| 703 | template <class _Tp> | ||
| 704 | _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<volatile _Tp>::has_denorm; | ||
| 705 | template <class _Tp> | ||
| 706 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_denorm_loss; | ||
| 707 | template <class _Tp> | ||
| 708 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_iec559; | ||
| 709 | template <class _Tp> | ||
| 710 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_bounded; | ||
| 711 | template <class _Tp> | ||
| 712 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_modulo; | ||
| 713 | template <class _Tp> | ||
| 714 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::traps; | ||
| 715 | template <class _Tp> | ||
| 716 | _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::tinyness_before; | ||
| 717 | template <class _Tp> | ||
| 718 | _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style; | ||
| 719 | 569 | ||
| 720 | template <class _Tp> | 570 | template <class _Tp> |
| 721 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : private numeric_limits<_Tp> { | 571 | class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {}; |
| 722 | typedef numeric_limits<_Tp> __base; | ||
| 723 | typedef _Tp type; | ||
| 724 | |||
| 725 | public: | ||
| 726 | static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; | ||
| 727 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } | ||
| 728 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } | ||
| 729 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } | ||
| 730 | 572 | ||
| 731 | static _LIBCPP_CONSTEXPR const int digits = __base::digits; | ||
| 732 | static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; | ||
| 733 | static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; | ||
| 734 | static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; | ||
| 735 | static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; | ||
| 736 | static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; | ||
| 737 | static _LIBCPP_CONSTEXPR const int radix = __base::radix; | ||
| 738 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } | ||
| 739 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); } | ||
| 740 | |||
| 741 | static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; | ||
| 742 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; | ||
| 743 | static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; | ||
| 744 | static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; | ||
| 745 | |||
| 746 | static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; | ||
| 747 | static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; | ||
| 748 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; | ||
| 749 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 750 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; | ||
| 751 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; | ||
| 752 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 753 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); } | ||
| 754 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } | ||
| 755 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } | ||
| 756 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); } | ||
| 757 | |||
| 758 | static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; | ||
| 759 | static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; | ||
| 760 | static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; | ||
| 761 | |||
| 762 | static _LIBCPP_CONSTEXPR const bool traps = __base::traps; | ||
| 763 | static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; | ||
| 764 | static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; | ||
| 765 | }; | ||
| 766 | |||
| 767 | template <class _Tp> | ||
| 768 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_specialized; | ||
| 769 | template <class _Tp> | ||
| 770 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits; | ||
| 771 | template <class _Tp> | ||
| 772 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10; | ||
| 773 | template <class _Tp> | ||
| 774 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10; | ||
| 775 | template <class _Tp> | ||
| 776 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed; | ||
| 777 | template <class _Tp> | ||
| 778 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_integer; | ||
| 779 | template <class _Tp> | ||
| 780 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_exact; | ||
| 781 | template <class _Tp> | ||
| 782 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::radix; | ||
| 783 | template <class _Tp> | ||
| 784 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent; | ||
| 785 | template <class _Tp> | ||
| 786 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent10; | ||
| 787 | template <class _Tp> | ||
| 788 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent; | ||
| 789 | template <class _Tp> | ||
| 790 | _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent10; | ||
| 791 | template <class _Tp> | ||
| 792 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_infinity; | ||
| 793 | template <class _Tp> | ||
| 794 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_quiet_NaN; | ||
| 795 | template <class _Tp> | ||
| 796 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_signaling_NaN; | ||
| 797 | template <class _Tp> | ||
| 798 | _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm; | ||
| 799 | template <class _Tp> | ||
| 800 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_denorm_loss; | ||
| 801 | template <class _Tp> | ||
| 802 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_iec559; | ||
| 803 | template <class _Tp> | ||
| 804 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_bounded; | ||
| 805 | template <class _Tp> | ||
| 806 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_modulo; | ||
| 807 | template <class _Tp> | ||
| 808 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::traps; | ||
| 809 | template <class _Tp> | ||
| 810 | _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::tinyness_before; | ||
| 811 | template <class _Tp> | 573 | template <class _Tp> |
| 812 | _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const volatile _Tp>::round_style; | 574 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {}; |
| 813 | 575 | ||
| 814 | _LIBCPP_END_NAMESPACE_STD | 576 | _LIBCPP_END_NAMESPACE_STD |
| 815 | 577 |
lib/libcxx/include/list+40-62| ... | @@ -202,8 +202,7 @@ template <class T, class Allocator, class Predicate> | ... | @@ -202,8 +202,7 @@ template <class T, class Allocator, class Predicate> |
| 202 | #include <__algorithm/lexicographical_compare.h> | 202 | #include <__algorithm/lexicographical_compare.h> |
| 203 | #include <__algorithm/lexicographical_compare_three_way.h> | 203 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 204 | #include <__algorithm/min.h> | 204 | #include <__algorithm/min.h> |
| 205 | #include <__assert> // all public C++ headers provide the assertion handler | 205 | #include <__assert> |
| 206 | #include <__availability> | ||
| 207 | #include <__config> | 206 | #include <__config> |
| 208 | #include <__format/enable_insertable.h> | 207 | #include <__format/enable_insertable.h> |
| 209 | #include <__iterator/distance.h> | 208 | #include <__iterator/distance.h> |
| ... | @@ -227,9 +226,8 @@ template <class T, class Allocator, class Predicate> | ... | @@ -227,9 +226,8 @@ template <class T, class Allocator, class Predicate> |
| 227 | #include <__ranges/from_range.h> | 226 | #include <__ranges/from_range.h> |
| 228 | #include <__type_traits/conditional.h> | 227 | #include <__type_traits/conditional.h> |
| 229 | #include <__type_traits/is_allocator.h> | 228 | #include <__type_traits/is_allocator.h> |
| 230 | #include <__type_traits/is_nothrow_default_constructible.h> | 229 | #include <__type_traits/is_nothrow_assignable.h> |
| 231 | #include <__type_traits/is_nothrow_move_assignable.h> | 230 | #include <__type_traits/is_nothrow_constructible.h> |
| 232 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 233 | #include <__type_traits/is_pointer.h> | 231 | #include <__type_traits/is_pointer.h> |
| 234 | #include <__type_traits/is_same.h> | 232 | #include <__type_traits/is_same.h> |
| 235 | #include <__type_traits/type_identity.h> | 233 | #include <__type_traits/type_identity.h> |
| ... | @@ -467,10 +465,10 @@ public: | ... | @@ -467,10 +465,10 @@ public: |
| 467 | 465 | ||
| 468 | template <class _Tp, class _Alloc> | 466 | template <class _Tp, class _Alloc> |
| 469 | class __list_imp { | 467 | class __list_imp { |
| 470 | __list_imp(const __list_imp&); | ||
| 471 | __list_imp& operator=(const __list_imp&); | ||
| 472 | |||
| 473 | public: | 468 | public: |
| 469 | __list_imp(const __list_imp&) = delete; | ||
| 470 | __list_imp& operator=(const __list_imp&) = delete; | ||
| 471 | |||
| 474 | typedef _Alloc allocator_type; | 472 | typedef _Alloc allocator_type; |
| 475 | typedef allocator_traits<allocator_type> __alloc_traits; | 473 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 476 | typedef typename __alloc_traits::size_type size_type; | 474 | typedef typename __alloc_traits::size_type size_type; |
| ... | @@ -495,9 +493,8 @@ protected: | ... | @@ -495,9 +493,8 @@ protected: |
| 495 | 493 | ||
| 496 | typedef __rebind_alloc<__alloc_traits, __node_base> __node_base_allocator; | 494 | typedef __rebind_alloc<__alloc_traits, __node_base> __node_base_allocator; |
| 497 | typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer; | 495 | typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer; |
| 498 | static_assert((!is_same<allocator_type, __node_allocator>::value), | 496 | static_assert(!is_same<allocator_type, __node_allocator>::value, |
| 499 | "internal allocator type must differ from user-specified " | 497 | "internal allocator type must differ from user-specified type; otherwise overload resolution breaks"); |
| 500 | "type; otherwise overload resolution breaks"); | ||
| 501 | 498 | ||
| 502 | __node_base __end_; | 499 | __node_base __end_; |
| 503 | __compressed_pair<size_type, __node_allocator> __size_alloc_; | 500 | __compressed_pair<size_type, __node_allocator> __size_alloc_; |
| ... | @@ -535,7 +532,7 @@ protected: | ... | @@ -535,7 +532,7 @@ protected: |
| 535 | #if _LIBCPP_STD_VER >= 14 | 532 | #if _LIBCPP_STD_VER >= 14 |
| 536 | _NOEXCEPT; | 533 | _NOEXCEPT; |
| 537 | #else | 534 | #else |
| 538 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value); | 535 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 539 | #endif | 536 | #endif |
| 540 | 537 | ||
| 541 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) { | 538 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) { |
| ... | @@ -568,7 +565,6 @@ protected: | ... | @@ -568,7 +565,6 @@ protected: |
| 568 | return __guard.__release_ptr(); | 565 | return __guard.__release_ptr(); |
| 569 | } | 566 | } |
| 570 | 567 | ||
| 571 | template <class... _Args> | ||
| 572 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { | 568 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { |
| 573 | // For the same reason as above, we use the allocator's destroy() method for the value_type, | 569 | // For the same reason as above, we use the allocator's destroy() method for the value_type, |
| 574 | // but not for the node itself. | 570 | // but not for the node itself. |
| ... | @@ -642,7 +638,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) | ... | @@ -642,7 +638,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 642 | #if _LIBCPP_STD_VER >= 14 | 638 | #if _LIBCPP_STD_VER >= 14 |
| 643 | _NOEXCEPT | 639 | _NOEXCEPT |
| 644 | #else | 640 | #else |
| 645 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) | 641 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 646 | #endif | 642 | #endif |
| 647 | { | 643 | { |
| 648 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( | 644 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( |
| ... | @@ -677,7 +673,8 @@ class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> { | ... | @@ -677,7 +673,8 @@ class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> { |
| 677 | public: | 673 | public: |
| 678 | typedef _Tp value_type; | 674 | typedef _Tp value_type; |
| 679 | typedef _Alloc allocator_type; | 675 | typedef _Alloc allocator_type; |
| 680 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), | 676 | static_assert(__check_valid_allocator<allocator_type>::value); |
| 677 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, | ||
| 681 | "Allocator::value_type must be same type as value_type"); | 678 | "Allocator::value_type must be same type as value_type"); |
| 682 | typedef value_type& reference; | 679 | typedef value_type& reference; |
| 683 | typedef const value_type& const_reference; | 680 | typedef const value_type& const_reference; |
| ... | @@ -695,10 +692,6 @@ public: | ... | @@ -695,10 +692,6 @@ public: |
| 695 | typedef void __remove_return_type; | 692 | typedef void __remove_return_type; |
| 696 | #endif | 693 | #endif |
| 697 | 694 | ||
| 698 | static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value, | ||
| 699 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 700 | "original allocator"); | ||
| 701 | |||
| 702 | _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} | 695 | _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} |
| 703 | _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : base(__a) {} | 696 | _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : base(__a) {} |
| 704 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n); | 697 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n); |
| ... | @@ -706,21 +699,17 @@ public: | ... | @@ -706,21 +699,17 @@ public: |
| 706 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); | 699 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); |
| 707 | #endif | 700 | #endif |
| 708 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); | 701 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); |
| 709 | template <class = __enable_if_t<__is_allocator<_Alloc>::value> > | 702 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 710 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a) { | 703 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a) { |
| 711 | for (; __n > 0; --__n) | 704 | for (; __n > 0; --__n) |
| 712 | push_back(__x); | 705 | push_back(__x); |
| 713 | } | 706 | } |
| 714 | 707 | ||
| 715 | template <class _InpIter> | 708 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 716 | _LIBCPP_HIDE_FROM_ABI | 709 | _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l); |
| 717 | list(_InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0); | 710 | |
| 718 | template <class _InpIter> | 711 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 719 | _LIBCPP_HIDE_FROM_ABI | 712 | _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a); |
| 720 | list(_InpIter __f, | ||
| 721 | _InpIter __l, | ||
| 722 | const allocator_type& __a, | ||
| 723 | __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0); | ||
| 724 | 713 | ||
| 725 | #if _LIBCPP_STD_VER >= 23 | 714 | #if _LIBCPP_STD_VER >= 23 |
| 726 | template <_ContainerCompatibleRange<_Tp> _Range> | 715 | template <_ContainerCompatibleRange<_Tp> _Range> |
| ... | @@ -750,9 +739,8 @@ public: | ... | @@ -750,9 +739,8 @@ public: |
| 750 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } | 739 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } |
| 751 | #endif // _LIBCPP_CXX03_LANG | 740 | #endif // _LIBCPP_CXX03_LANG |
| 752 | 741 | ||
| 753 | template <class _InpIter> | 742 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 754 | _LIBCPP_HIDE_FROM_ABI void | 743 | _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l); |
| 755 | assign(_InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0); | ||
| 756 | 744 | ||
| 757 | #if _LIBCPP_STD_VER >= 23 | 745 | #if _LIBCPP_STD_VER >= 23 |
| 758 | template <_ContainerCompatibleRange<_Tp> _Range> | 746 | template <_ContainerCompatibleRange<_Tp> _Range> |
| ... | @@ -766,7 +754,7 @@ public: | ... | @@ -766,7 +754,7 @@ public: |
| 766 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; | 754 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; |
| 767 | 755 | ||
| 768 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return base::__sz(); } | 756 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return base::__sz(); } |
| 769 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); } | 757 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); } |
| 770 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 758 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 771 | return std::min<size_type>(base::__node_alloc_max_size(), numeric_limits<difference_type >::max()); | 759 | return std::min<size_type>(base::__node_alloc_max_size(), numeric_limits<difference_type >::max()); |
| 772 | } | 760 | } |
| ... | @@ -854,12 +842,9 @@ public: | ... | @@ -854,12 +842,9 @@ public: |
| 854 | 842 | ||
| 855 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x); | 843 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x); |
| 856 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x); | 844 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x); |
| 857 | template <class _InpIter> | 845 | |
| 858 | _LIBCPP_HIDE_FROM_ABI iterator | 846 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 859 | insert(const_iterator __p, | 847 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l); |
| 860 | _InpIter __f, | ||
| 861 | _InpIter __l, | ||
| 862 | __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0); | ||
| 863 | 848 | ||
| 864 | #if _LIBCPP_STD_VER >= 23 | 849 | #if _LIBCPP_STD_VER >= 23 |
| 865 | template <_ContainerCompatibleRange<_Tp> _Range> | 850 | template <_ContainerCompatibleRange<_Tp> _Range> |
| ... | @@ -872,8 +857,7 @@ public: | ... | @@ -872,8 +857,7 @@ public: |
| 872 | #if _LIBCPP_STD_VER >= 14 | 857 | #if _LIBCPP_STD_VER >= 14 |
| 873 | _NOEXCEPT | 858 | _NOEXCEPT |
| 874 | #else | 859 | #else |
| 875 | _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || | 860 | _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) |
| 876 | __is_nothrow_swappable<__node_allocator>::value) | ||
| 877 | #endif | 861 | #endif |
| 878 | { | 862 | { |
| 879 | base::swap(__c); | 863 | base::swap(__c); |
| ... | @@ -1024,19 +1008,15 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { | ... | @@ -1024,19 +1008,15 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { |
| 1024 | } | 1008 | } |
| 1025 | 1009 | ||
| 1026 | template <class _Tp, class _Alloc> | 1010 | template <class _Tp, class _Alloc> |
| 1027 | template <class _InpIter> | 1011 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1028 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) { | 1012 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) { |
| 1029 | for (; __f != __l; ++__f) | 1013 | for (; __f != __l; ++__f) |
| 1030 | __emplace_back(*__f); | 1014 | __emplace_back(*__f); |
| 1031 | } | 1015 | } |
| 1032 | 1016 | ||
| 1033 | template <class _Tp, class _Alloc> | 1017 | template <class _Tp, class _Alloc> |
| 1034 | template <class _InpIter> | 1018 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1035 | list<_Tp, _Alloc>::list(_InpIter __f, | 1019 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : base(__a) { |
| 1036 | _InpIter __l, | ||
| 1037 | const allocator_type& __a, | ||
| 1038 | __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) | ||
| 1039 | : base(__a) { | ||
| 1040 | for (; __f != __l; ++__f) | 1020 | for (; __f != __l; ++__f) |
| 1041 | __emplace_back(*__f); | 1021 | __emplace_back(*__f); |
| 1042 | } | 1022 | } |
| ... | @@ -1069,7 +1049,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) { | ... | @@ -1069,7 +1049,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) { |
| 1069 | } | 1049 | } |
| 1070 | 1050 | ||
| 1071 | template <class _Tp, class _Alloc> | 1051 | template <class _Tp, class _Alloc> |
| 1072 | inline list<_Tp, _Alloc>::list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value) | 1052 | inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value) |
| 1073 | : base(std::move(__c.__node_alloc())) { | 1053 | : base(std::move(__c.__node_alloc())) { |
| 1074 | splice(end(), __c); | 1054 | splice(end(), __c); |
| 1075 | } | 1055 | } |
| ... | @@ -1085,9 +1065,9 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ | ... | @@ -1085,9 +1065,9 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ |
| 1085 | } | 1065 | } |
| 1086 | 1066 | ||
| 1087 | template <class _Tp, class _Alloc> | 1067 | template <class _Tp, class _Alloc> |
| 1088 | inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) | 1068 | inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept( |
| 1089 | _NOEXCEPT_(__node_alloc_traits::propagate_on_container_move_assignment::value&& | 1069 | __node_alloc_traits::propagate_on_container_move_assignment::value && |
| 1090 | is_nothrow_move_assignable<__node_allocator>::value) { | 1070 | is_nothrow_move_assignable<__node_allocator>::value) { |
| 1091 | __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>()); | 1071 | __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>()); |
| 1092 | return *this; | 1072 | return *this; |
| 1093 | } | 1073 | } |
| ... | @@ -1102,8 +1082,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { | ... | @@ -1102,8 +1082,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { |
| 1102 | } | 1082 | } |
| 1103 | 1083 | ||
| 1104 | template <class _Tp, class _Alloc> | 1084 | template <class _Tp, class _Alloc> |
| 1105 | void list<_Tp, _Alloc>::__move_assign(list& __c, true_type) | 1085 | void list<_Tp, _Alloc>::__move_assign(list& __c, |
| 1106 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { | 1086 | true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) { |
| 1107 | clear(); | 1087 | clear(); |
| 1108 | base::__move_assign_alloc(__c); | 1088 | base::__move_assign_alloc(__c); |
| 1109 | splice(end(), __c); | 1089 | splice(end(), __c); |
| ... | @@ -1121,9 +1101,8 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { | ... | @@ -1121,9 +1101,8 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { |
| 1121 | } | 1101 | } |
| 1122 | 1102 | ||
| 1123 | template <class _Tp, class _Alloc> | 1103 | template <class _Tp, class _Alloc> |
| 1124 | template <class _InpIter> | 1104 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1125 | void list<_Tp, _Alloc>::assign( | 1105 | void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) { |
| 1126 | _InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) { | ||
| 1127 | __assign_with_sentinel(__f, __l); | 1106 | __assign_with_sentinel(__f, __l); |
| 1128 | } | 1107 | } |
| 1129 | 1108 | ||
| ... | @@ -1201,9 +1180,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ | ... | @@ -1201,9 +1180,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1201 | } | 1180 | } |
| 1202 | 1181 | ||
| 1203 | template <class _Tp, class _Alloc> | 1182 | template <class _Tp, class _Alloc> |
| 1204 | template <class _InpIter> | 1183 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1205 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert( | 1184 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) { |
| 1206 | const_iterator __p, _InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) { | ||
| 1207 | return __insert_with_sentinel(__p, __f, __l); | 1185 | return __insert_with_sentinel(__p, __f, __l); |
| 1208 | } | 1186 | } |
| 1209 | 1187 | ||
| ... | @@ -1702,7 +1680,7 @@ template <class _Tp, class _Allocator> | ... | @@ -1702,7 +1680,7 @@ template <class _Tp, class _Allocator> |
| 1702 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> | 1680 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 1703 | operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) { | 1681 | operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) { |
| 1704 | return std::lexicographical_compare_three_way( | 1682 | return std::lexicographical_compare_three_way( |
| 1705 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>); | 1683 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1706 | } | 1684 | } |
| 1707 | 1685 | ||
| 1708 | #endif // _LIBCPP_STD_VER <= 17 | 1686 | #endif // _LIBCPP_STD_VER <= 17 |
lib/libcxx/include/locale+195-160| ... | @@ -84,7 +84,7 @@ template <class charT> charT tolower(charT c, const locale& loc); | ... | @@ -84,7 +84,7 @@ template <class charT> charT tolower(charT c, const locale& loc); |
| 84 | template<class Codecvt, class Elem = wchar_t, | 84 | template<class Codecvt, class Elem = wchar_t, |
| 85 | class Wide_alloc = allocator<Elem>, | 85 | class Wide_alloc = allocator<Elem>, |
| 86 | class Byte_alloc = allocator<char>> | 86 | class Byte_alloc = allocator<char>> |
| 87 | class wstring_convert | 87 | class wstring_convert // Removed in C++26 |
| 88 | { | 88 | { |
| 89 | public: | 89 | public: |
| 90 | typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string; | 90 | typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string; |
| ... | @@ -119,7 +119,7 @@ public: | ... | @@ -119,7 +119,7 @@ public: |
| 119 | }; | 119 | }; |
| 120 | 120 | ||
| 121 | template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>> | 121 | template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>> |
| 122 | class wbuffer_convert | 122 | class wbuffer_convert // Removed in C++26 |
| 123 | : public basic_streambuf<Elem, Tr> | 123 | : public basic_streambuf<Elem, Tr> |
| 124 | { | 124 | { |
| 125 | public: | 125 | public: |
| ... | @@ -187,67 +187,74 @@ template <class charT> class messages_byname; | ... | @@ -187,67 +187,74 @@ template <class charT> class messages_byname; |
| 187 | 187 | ||
| 188 | */ | 188 | */ |
| 189 | 189 | ||
| 190 | #include <__algorithm/copy.h> | ||
| 191 | #include <__algorithm/equal.h> | ||
| 192 | #include <__algorithm/find.h> | ||
| 193 | #include <__algorithm/max.h> | ||
| 194 | #include <__algorithm/reverse.h> | ||
| 195 | #include <__algorithm/unwrap_iter.h> | ||
| 196 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 197 | #include <__config> | 190 | #include <__config> |
| 198 | #include <__iterator/access.h> | 191 | |
| 199 | #include <__iterator/back_insert_iterator.h> | 192 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 200 | #include <__iterator/istreambuf_iterator.h> | 193 | |
| 201 | #include <__iterator/ostreambuf_iterator.h> | 194 | # include <__algorithm/copy.h> |
| 202 | #include <__locale> | 195 | # include <__algorithm/equal.h> |
| 203 | #include <__memory/unique_ptr.h> | 196 | # include <__algorithm/find.h> |
| 204 | #include <__type_traits/make_unsigned.h> | 197 | # include <__algorithm/max.h> |
| 205 | #include <cerrno> | 198 | # include <__algorithm/reverse.h> |
| 206 | #include <cstdio> | 199 | # include <__algorithm/unwrap_iter.h> |
| 207 | #include <cstdlib> | 200 | # include <__assert> |
| 208 | #include <ctime> | 201 | # include <__iterator/access.h> |
| 209 | #include <ios> | 202 | # include <__iterator/back_insert_iterator.h> |
| 210 | #include <limits> | 203 | # include <__iterator/istreambuf_iterator.h> |
| 211 | #include <new> | 204 | # include <__iterator/ostreambuf_iterator.h> |
| 212 | #include <streambuf> | 205 | # include <__locale> |
| 213 | #include <version> | 206 | # include <__memory/unique_ptr.h> |
| 207 | # include <__type_traits/make_unsigned.h> | ||
| 208 | # include <cerrno> | ||
| 209 | # include <cstdio> | ||
| 210 | # include <cstdlib> | ||
| 211 | # include <ctime> | ||
| 212 | # include <ios> | ||
| 213 | # include <limits> | ||
| 214 | # include <new> | ||
| 215 | # include <streambuf> | ||
| 216 | # include <version> | ||
| 214 | 217 | ||
| 215 | // TODO: Fix __bsd_locale_defaults.h | 218 | // TODO: Fix __bsd_locale_defaults.h |
| 216 | // NOLINTBEGIN(libcpp-robust-against-adl) | 219 | // NOLINTBEGIN(libcpp-robust-against-adl) |
| 217 | 220 | ||
| 218 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | 221 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 219 | // Most unix variants have catopen. These are the specific ones that don't. | 222 | // Most unix variants have catopen. These are the specific ones that don't. |
| 220 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | 223 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) |
| 221 | # define _LIBCPP_HAS_CATOPEN 1 | 224 | # define _LIBCPP_HAS_CATOPEN 1 |
| 222 | # include <nl_types.h> | 225 | # include <nl_types.h> |
| 226 | # endif | ||
| 223 | # endif | 227 | # endif |
| 224 | #endif | ||
| 225 | 228 | ||
| 226 | #ifdef _LIBCPP_LOCALE__L_EXTENSIONS | 229 | # ifdef _LIBCPP_LOCALE__L_EXTENSIONS |
| 227 | # include <__locale_dir/locale_base_api/bsd_locale_defaults.h> | 230 | # include <__locale_dir/locale_base_api/bsd_locale_defaults.h> |
| 228 | #else | 231 | # else |
| 229 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> | 232 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> |
| 230 | #endif | 233 | # endif |
| 231 | 234 | ||
| 232 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 235 | # if defined(__APPLE__) || defined(__FreeBSD__) |
| 233 | # pragma GCC system_header | 236 | # include <xlocale.h> |
| 234 | #endif | 237 | # endif |
| 238 | |||
| 239 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 240 | # pragma GCC system_header | ||
| 241 | # endif | ||
| 235 | 242 | ||
| 236 | _LIBCPP_PUSH_MACROS | 243 | _LIBCPP_PUSH_MACROS |
| 237 | #include <__undef_macros> | 244 | # include <__undef_macros> |
| 238 | 245 | ||
| 239 | _LIBCPP_BEGIN_NAMESPACE_STD | 246 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 240 | 247 | ||
| 241 | #if defined(__APPLE__) || defined(__FreeBSD__) | 248 | # if defined(__APPLE__) || defined(__FreeBSD__) |
| 242 | # define _LIBCPP_GET_C_LOCALE 0 | 249 | # define _LIBCPP_GET_C_LOCALE 0 |
| 243 | #elif defined(__NetBSD__) | 250 | # elif defined(__NetBSD__) |
| 244 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE | 251 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE |
| 245 | #else | 252 | # else |
| 246 | # define _LIBCPP_GET_C_LOCALE __cloc() | 253 | # define _LIBCPP_GET_C_LOCALE __cloc() |
| 247 | // Get the C locale object | 254 | // Get the C locale object |
| 248 | _LIBCPP_EXPORTED_FROM_ABI locale_t __cloc(); | 255 | _LIBCPP_EXPORTED_FROM_ABI locale_t __cloc(); |
| 249 | # define __cloc_defined | 256 | # define __cloc_defined |
| 250 | #endif | 257 | # endif |
| 251 | 258 | ||
| 252 | // __scan_keyword | 259 | // __scan_keyword |
| 253 | // Scans [__b, __e) until a match is found in the basic_strings range | 260 | // Scans [__b, __e) until a match is found in the basic_strings range |
| ... | @@ -368,7 +375,11 @@ struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base { | ... | @@ -368,7 +375,11 @@ struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base { |
| 368 | static const int __num_get_buf_sz = 40; | 375 | static const int __num_get_buf_sz = 40; |
| 369 | 376 | ||
| 370 | static int __get_base(ios_base&); | 377 | static int __get_base(ios_base&); |
| 371 | static const char __src[33]; | 378 | static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN" |
| 379 | // count of leading characters in __src used for parsing integers ("012..X+-") | ||
| 380 | static const size_t __int_chr_cnt = 26; | ||
| 381 | // count of leading characters in __src used for parsing floating-point values ("012..-pP") | ||
| 382 | static const size_t __fp_chr_cnt = 28; | ||
| 372 | }; | 383 | }; |
| 373 | 384 | ||
| 374 | _LIBCPP_EXPORTED_FROM_ABI void | 385 | _LIBCPP_EXPORTED_FROM_ABI void |
| ... | @@ -391,7 +402,7 @@ struct __num_get : protected __num_get_base { | ... | @@ -391,7 +402,7 @@ struct __num_get : protected __num_get_base { |
| 391 | unsigned*& __g_end, | 402 | unsigned*& __g_end, |
| 392 | unsigned& __dc, | 403 | unsigned& __dc, |
| 393 | _CharT* __atoms); | 404 | _CharT* __atoms); |
| 394 | #ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | 405 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
| 395 | static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); | 406 | static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); |
| 396 | static int __stage2_int_loop( | 407 | static int __stage2_int_loop( |
| 397 | _CharT __ct, | 408 | _CharT __ct, |
| ... | @@ -405,7 +416,7 @@ struct __num_get : protected __num_get_base { | ... | @@ -405,7 +416,7 @@ struct __num_get : protected __num_get_base { |
| 405 | unsigned*& __g_end, | 416 | unsigned*& __g_end, |
| 406 | _CharT* __atoms); | 417 | _CharT* __atoms); |
| 407 | 418 | ||
| 408 | #else | 419 | # else |
| 409 | static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { | 420 | static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { |
| 410 | locale __loc = __iob.getloc(); | 421 | locale __loc = __iob.getloc(); |
| 411 | const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); | 422 | const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); |
| ... | @@ -431,7 +442,7 @@ private: | ... | @@ -431,7 +442,7 @@ private: |
| 431 | template <typename _Tp> | 442 | template <typename _Tp> |
| 432 | const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const { | 443 | const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const { |
| 433 | locale __loc = __iob.getloc(); | 444 | locale __loc = __iob.getloc(); |
| 434 | use_facet<ctype<_Tp> >(__loc).widen(__src, __src + 26, __atoms); | 445 | use_facet<ctype<_Tp> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms); |
| 435 | return __atoms; | 446 | return __atoms; |
| 436 | } | 447 | } |
| 437 | 448 | ||
| ... | @@ -440,25 +451,25 @@ private: | ... | @@ -440,25 +451,25 @@ private: |
| 440 | (void)__atoms; | 451 | (void)__atoms; |
| 441 | return __src; | 452 | return __src; |
| 442 | } | 453 | } |
| 443 | #endif | 454 | # endif |
| 444 | }; | 455 | }; |
| 445 | 456 | ||
| 446 | #ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | 457 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
| 447 | template <class _CharT> | 458 | template <class _CharT> |
| 448 | string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { | 459 | string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { |
| 449 | locale __loc = __iob.getloc(); | 460 | locale __loc = __iob.getloc(); |
| 450 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms); | 461 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms); |
| 451 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); | 462 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); |
| 452 | __thousands_sep = __np.thousands_sep(); | 463 | __thousands_sep = __np.thousands_sep(); |
| 453 | return __np.grouping(); | 464 | return __np.grouping(); |
| 454 | } | 465 | } |
| 455 | #endif | 466 | # endif |
| 456 | 467 | ||
| 457 | template <class _CharT> | 468 | template <class _CharT> |
| 458 | string __num_get<_CharT>::__stage2_float_prep( | 469 | string __num_get<_CharT>::__stage2_float_prep( |
| 459 | ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) { | 470 | ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) { |
| 460 | locale __loc = __iob.getloc(); | 471 | locale __loc = __iob.getloc(); |
| 461 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms); | 472 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __fp_chr_cnt, __atoms); |
| 462 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); | 473 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); |
| 463 | __decimal_point = __np.decimal_point(); | 474 | __decimal_point = __np.decimal_point(); |
| 464 | __thousands_sep = __np.thousands_sep(); | 475 | __thousands_sep = __np.thousands_sep(); |
| ... | @@ -467,16 +478,16 @@ string __num_get<_CharT>::__stage2_float_prep( | ... | @@ -467,16 +478,16 @@ string __num_get<_CharT>::__stage2_float_prep( |
| 467 | 478 | ||
| 468 | template <class _CharT> | 479 | template <class _CharT> |
| 469 | int | 480 | int |
| 470 | #ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | 481 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
| 471 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, | 482 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, |
| 472 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, | 483 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, |
| 473 | unsigned* __g, unsigned*& __g_end, _CharT* __atoms) | 484 | unsigned* __g, unsigned*& __g_end, _CharT* __atoms) |
| 474 | #else | 485 | # else |
| 475 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, | 486 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, |
| 476 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, | 487 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, |
| 477 | unsigned* __g, unsigned*& __g_end, const _CharT* __atoms) | 488 | unsigned* __g, unsigned*& __g_end, const _CharT* __atoms) |
| 478 | 489 | ||
| 479 | #endif | 490 | # endif |
| 480 | { | 491 | { |
| 481 | if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { | 492 | if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { |
| 482 | *__a_end++ = __ct == __atoms[24] ? '+' : '-'; | 493 | *__a_end++ = __ct == __atoms[24] ? '+' : '-'; |
| ... | @@ -490,7 +501,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& | ... | @@ -490,7 +501,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& |
| 490 | } | 501 | } |
| 491 | return 0; | 502 | return 0; |
| 492 | } | 503 | } |
| 493 | ptrdiff_t __f = std::find(__atoms, __atoms + 26, __ct) - __atoms; | 504 | ptrdiff_t __f = std::find(__atoms, __atoms + __int_chr_cnt, __ct) - __atoms; |
| 494 | if (__f >= 24) | 505 | if (__f >= 24) |
| 495 | return -1; | 506 | return -1; |
| 496 | switch (__base) { | 507 | switch (__base) { |
| ... | @@ -546,8 +557,8 @@ int __num_get<_CharT>::__stage2_float_loop( | ... | @@ -546,8 +557,8 @@ int __num_get<_CharT>::__stage2_float_loop( |
| 546 | } | 557 | } |
| 547 | return 0; | 558 | return 0; |
| 548 | } | 559 | } |
| 549 | ptrdiff_t __f = std::find(__atoms, __atoms + 32, __ct) - __atoms; | 560 | ptrdiff_t __f = std::find(__atoms, __atoms + __num_get_base::__fp_chr_cnt, __ct) - __atoms; |
| 550 | if (__f >= 32) | 561 | if (__f >= static_cast<ptrdiff_t>(__num_get_base::__fp_chr_cnt)) |
| 551 | return -1; | 562 | return -1; |
| 552 | char __x = __src[__f]; | 563 | char __x = __src[__f]; |
| 553 | if (__x == '-' || __x == '+') { | 564 | if (__x == '-' || __x == '+') { |
| ... | @@ -575,9 +586,9 @@ int __num_get<_CharT>::__stage2_float_loop( | ... | @@ -575,9 +586,9 @@ int __num_get<_CharT>::__stage2_float_loop( |
| 575 | } | 586 | } |
| 576 | 587 | ||
| 577 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; | 588 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; |
| 578 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 589 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 579 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; | 590 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; |
| 580 | #endif | 591 | # endif |
| 581 | 592 | ||
| 582 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | 593 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 583 | class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { | 594 | class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { |
| ... | @@ -846,15 +857,15 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed( | ... | @@ -846,15 +857,15 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed( |
| 846 | int __base = this->__get_base(__iob); | 857 | int __base = this->__get_base(__iob); |
| 847 | // Stage 2 | 858 | // Stage 2 |
| 848 | char_type __thousands_sep; | 859 | char_type __thousands_sep; |
| 849 | const int __atoms_size = 26; | 860 | const int __atoms_size = __num_get_base::__int_chr_cnt; |
| 850 | #ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | 861 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
| 851 | char_type __atoms1[__atoms_size]; | 862 | char_type __atoms1[__atoms_size]; |
| 852 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | 863 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); |
| 853 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | 864 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); |
| 854 | #else | 865 | # else |
| 855 | char_type __atoms[__atoms_size]; | 866 | char_type __atoms[__atoms_size]; |
| 856 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); | 867 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); |
| 857 | #endif | 868 | # endif |
| 858 | string __buf; | 869 | string __buf; |
| 859 | __buf.resize(__buf.capacity()); | 870 | __buf.resize(__buf.capacity()); |
| 860 | char* __a = &__buf[0]; | 871 | char* __a = &__buf[0]; |
| ... | @@ -895,15 +906,15 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned( | ... | @@ -895,15 +906,15 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned( |
| 895 | int __base = this->__get_base(__iob); | 906 | int __base = this->__get_base(__iob); |
| 896 | // Stage 2 | 907 | // Stage 2 |
| 897 | char_type __thousands_sep; | 908 | char_type __thousands_sep; |
| 898 | const int __atoms_size = 26; | 909 | const int __atoms_size = __num_get_base::__int_chr_cnt; |
| 899 | #ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | 910 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
| 900 | char_type __atoms1[__atoms_size]; | 911 | char_type __atoms1[__atoms_size]; |
| 901 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | 912 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); |
| 902 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | 913 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); |
| 903 | #else | 914 | # else |
| 904 | char_type __atoms[__atoms_size]; | 915 | char_type __atoms[__atoms_size]; |
| 905 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); | 916 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); |
| 906 | #endif | 917 | # endif |
| 907 | string __buf; | 918 | string __buf; |
| 908 | __buf.resize(__buf.capacity()); | 919 | __buf.resize(__buf.capacity()); |
| 909 | char* __a = &__buf[0]; | 920 | char* __a = &__buf[0]; |
| ... | @@ -942,7 +953,7 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( | ... | @@ -942,7 +953,7 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( |
| 942 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const { | 953 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const { |
| 943 | // Stage 1, nothing to do | 954 | // Stage 1, nothing to do |
| 944 | // Stage 2 | 955 | // Stage 2 |
| 945 | char_type __atoms[32]; | 956 | char_type __atoms[__num_get_base::__fp_chr_cnt]; |
| 946 | char_type __decimal_point; | 957 | char_type __decimal_point; |
| 947 | char_type __thousands_sep; | 958 | char_type __thousands_sep; |
| 948 | string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep); | 959 | string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep); |
| ... | @@ -951,10 +962,11 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( | ... | @@ -951,10 +962,11 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( |
| 951 | char* __a = &__buf[0]; | 962 | char* __a = &__buf[0]; |
| 952 | char* __a_end = __a; | 963 | char* __a_end = __a; |
| 953 | unsigned __g[__num_get_base::__num_get_buf_sz]; | 964 | unsigned __g[__num_get_base::__num_get_buf_sz]; |
| 954 | unsigned* __g_end = __g; | 965 | unsigned* __g_end = __g; |
| 955 | unsigned __dc = 0; | 966 | unsigned __dc = 0; |
| 956 | bool __in_units = true; | 967 | bool __in_units = true; |
| 957 | char __exp = 'E'; | 968 | char __exp = 'E'; |
| 969 | bool __is_leading_parsed = false; | ||
| 958 | for (; __b != __e; ++__b) { | 970 | for (; __b != __e; ++__b) { |
| 959 | if (__a_end == __a + __buf.size()) { | 971 | if (__a_end == __a + __buf.size()) { |
| 960 | size_t __tmp = __buf.size(); | 972 | size_t __tmp = __buf.size(); |
| ... | @@ -977,6 +989,21 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( | ... | @@ -977,6 +989,21 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( |
| 977 | __dc, | 989 | __dc, |
| 978 | __atoms)) | 990 | __atoms)) |
| 979 | break; | 991 | break; |
| 992 | |||
| 993 | // the leading character excluding the sign must be a decimal digit | ||
| 994 | if (!__is_leading_parsed) { | ||
| 995 | if (__a_end - __a >= 1 && __a[0] != '-' && __a[0] != '+') { | ||
| 996 | if (('0' <= __a[0] && __a[0] <= '9') || __a[0] == '.') | ||
| 997 | __is_leading_parsed = true; | ||
| 998 | else | ||
| 999 | break; | ||
| 1000 | } else if (__a_end - __a >= 2 && (__a[0] == '-' || __a[0] == '+')) { | ||
| 1001 | if (('0' <= __a[1] && __a[1] <= '9') || __a[1] == '.') | ||
| 1002 | __is_leading_parsed = true; | ||
| 1003 | else | ||
| 1004 | break; | ||
| 1005 | } | ||
| 1006 | } | ||
| 980 | } | 1007 | } |
| 981 | if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz) | 1008 | if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz) |
| 982 | *__g_end++ = __dc; | 1009 | *__g_end++ = __dc; |
| ... | @@ -996,10 +1023,11 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( | ... | @@ -996,10 +1023,11 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( |
| 996 | // Stage 1 | 1023 | // Stage 1 |
| 997 | int __base = 16; | 1024 | int __base = 16; |
| 998 | // Stage 2 | 1025 | // Stage 2 |
| 999 | char_type __atoms[26]; | 1026 | char_type __atoms[__num_get_base::__int_chr_cnt]; |
| 1000 | char_type __thousands_sep = char_type(); | 1027 | char_type __thousands_sep = char_type(); |
| 1001 | string __grouping; | 1028 | string __grouping; |
| 1002 | std::use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src, __num_get_base::__src + 26, __atoms); | 1029 | std::use_facet<ctype<_CharT> >(__iob.getloc()) |
| 1030 | .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms); | ||
| 1003 | string __buf; | 1031 | string __buf; |
| 1004 | __buf.resize(__buf.capacity()); | 1032 | __buf.resize(__buf.capacity()); |
| 1005 | char* __a = &__buf[0]; | 1033 | char* __a = &__buf[0]; |
| ... | @@ -1029,9 +1057,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( | ... | @@ -1029,9 +1057,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( |
| 1029 | } | 1057 | } |
| 1030 | 1058 | ||
| 1031 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; | 1059 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; |
| 1032 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 1060 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1033 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; | 1061 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; |
| 1034 | #endif | 1062 | # endif |
| 1035 | 1063 | ||
| 1036 | struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { | 1064 | struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { |
| 1037 | protected: | 1065 | protected: |
| ... | @@ -1147,9 +1175,9 @@ void __num_put<_CharT>::__widen_and_group_float( | ... | @@ -1147,9 +1175,9 @@ void __num_put<_CharT>::__widen_and_group_float( |
| 1147 | } | 1175 | } |
| 1148 | 1176 | ||
| 1149 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; | 1177 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; |
| 1150 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 1178 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1151 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; | 1179 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; |
| 1152 | #endif | 1180 | # endif |
| 1153 | 1181 | ||
| 1154 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | 1182 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 1155 | class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { | 1183 | class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { |
| ... | @@ -1434,9 +1462,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty | ... | @@ -1434,9 +1462,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty |
| 1434 | } | 1462 | } |
| 1435 | 1463 | ||
| 1436 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; | 1464 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; |
| 1437 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 1465 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1438 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; | 1466 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; |
| 1439 | #endif | 1467 | # endif |
| 1440 | 1468 | ||
| 1441 | template <class _CharT, class _InputIterator> | 1469 | template <class _CharT, class _InputIterator> |
| 1442 | _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( | 1470 | _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( |
| ... | @@ -1501,7 +1529,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const; | ... | @@ -1501,7 +1529,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const; |
| 1501 | template <> | 1529 | template <> |
| 1502 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const; | 1530 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const; |
| 1503 | 1531 | ||
| 1504 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 1532 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1505 | template <> | 1533 | template <> |
| 1506 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const; | 1534 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const; |
| 1507 | template <> | 1535 | template <> |
| ... | @@ -1516,7 +1544,7 @@ template <> | ... | @@ -1516,7 +1544,7 @@ template <> |
| 1516 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const; | 1544 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const; |
| 1517 | template <> | 1545 | template <> |
| 1518 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const; | 1546 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const; |
| 1519 | #endif | 1547 | # endif |
| 1520 | 1548 | ||
| 1521 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | 1549 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 1522 | class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { | 1550 | class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { |
| ... | @@ -1970,9 +1998,9 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get( | ... | @@ -1970,9 +1998,9 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get( |
| 1970 | } | 1998 | } |
| 1971 | 1999 | ||
| 1972 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; | 2000 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; |
| 1973 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2001 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1974 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; | 2002 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; |
| 1975 | #endif | 2003 | # endif |
| 1976 | 2004 | ||
| 1977 | class _LIBCPP_EXPORTED_FROM_ABI __time_get { | 2005 | class _LIBCPP_EXPORTED_FROM_ABI __time_get { |
| 1978 | protected: | 2006 | protected: |
| ... | @@ -2008,31 +2036,32 @@ private: | ... | @@ -2008,31 +2036,32 @@ private: |
| 2008 | string_type __analyze(char __fmt, const ctype<_CharT>&); | 2036 | string_type __analyze(char __fmt, const ctype<_CharT>&); |
| 2009 | }; | 2037 | }; |
| 2010 | 2038 | ||
| 2011 | #define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ | 2039 | # define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ |
| 2012 | template <> \ | 2040 | template <> \ |
| 2013 | _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ | 2041 | _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ |
| 2014 | template <> \ | 2042 | template <> \ |
| 2015 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | 2043 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ |
| 2016 | template <> \ | 2044 | template <> \ |
| 2017 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | 2045 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ |
| 2018 | template <> \ | 2046 | template <> \ |
| 2019 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | 2047 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ |
| 2020 | template <> \ | 2048 | template <> \ |
| 2021 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ | 2049 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ |
| 2022 | char, const ctype<_CharT>&); \ | 2050 | char, const ctype<_CharT>&); \ |
| 2023 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ | 2051 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ |
| 2024 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | 2052 | const; \ |
| 2025 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | 2053 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ |
| 2026 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | 2054 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ |
| 2027 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ | 2055 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ |
| 2028 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ | 2056 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ |
| 2029 | /**/ | 2057 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ |
| 2058 | /**/ | ||
| 2030 | 2059 | ||
| 2031 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) | 2060 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) |
| 2032 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2061 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2033 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) | 2062 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) |
| 2034 | #endif | 2063 | # endif |
| 2035 | #undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION | 2064 | # undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION |
| 2036 | 2065 | ||
| 2037 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | 2066 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 2038 | class _LIBCPP_TEMPLATE_VIS time_get_byname | 2067 | class _LIBCPP_TEMPLATE_VIS time_get_byname |
| ... | @@ -2065,9 +2094,9 @@ private: | ... | @@ -2065,9 +2094,9 @@ private: |
| 2065 | }; | 2094 | }; |
| 2066 | 2095 | ||
| 2067 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; | 2096 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; |
| 2068 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2097 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2069 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; | 2098 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; |
| 2070 | #endif | 2099 | # endif |
| 2071 | 2100 | ||
| 2072 | class _LIBCPP_EXPORTED_FROM_ABI __time_put { | 2101 | class _LIBCPP_EXPORTED_FROM_ABI __time_put { |
| 2073 | locale_t __loc_; | 2102 | locale_t __loc_; |
| ... | @@ -2078,9 +2107,9 @@ protected: | ... | @@ -2078,9 +2107,9 @@ protected: |
| 2078 | __time_put(const string& __nm); | 2107 | __time_put(const string& __nm); |
| 2079 | ~__time_put(); | 2108 | ~__time_put(); |
| 2080 | void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; | 2109 | void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; |
| 2081 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2110 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2082 | void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; | 2111 | void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; |
| 2083 | #endif | 2112 | # endif |
| 2084 | }; | 2113 | }; |
| 2085 | 2114 | ||
| 2086 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | 2115 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| ... | @@ -2154,9 +2183,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put( | ... | @@ -2154,9 +2183,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put( |
| 2154 | } | 2183 | } |
| 2155 | 2184 | ||
| 2156 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; | 2185 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; |
| 2157 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2186 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2158 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; | 2187 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; |
| 2159 | #endif | 2188 | # endif |
| 2160 | 2189 | ||
| 2161 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | 2190 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 2162 | class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { | 2191 | class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { |
| ... | @@ -2172,9 +2201,9 @@ protected: | ... | @@ -2172,9 +2201,9 @@ protected: |
| 2172 | }; | 2201 | }; |
| 2173 | 2202 | ||
| 2174 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; | 2203 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; |
| 2175 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2204 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2176 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; | 2205 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; |
| 2177 | #endif | 2206 | # endif |
| 2178 | 2207 | ||
| 2179 | // money_base | 2208 | // money_base |
| 2180 | 2209 | ||
| ... | @@ -2239,10 +2268,10 @@ const bool moneypunct<_CharT, _International>::intl; | ... | @@ -2239,10 +2268,10 @@ const bool moneypunct<_CharT, _International>::intl; |
| 2239 | 2268 | ||
| 2240 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; | 2269 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; |
| 2241 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; | 2270 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; |
| 2242 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2271 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2243 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; | 2272 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; |
| 2244 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; | 2273 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; |
| 2245 | #endif | 2274 | # endif |
| 2246 | 2275 | ||
| 2247 | // moneypunct_byname | 2276 | // moneypunct_byname |
| 2248 | 2277 | ||
| ... | @@ -2297,14 +2326,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*); | ... | @@ -2297,14 +2326,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*); |
| 2297 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; | 2326 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; |
| 2298 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; | 2327 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; |
| 2299 | 2328 | ||
| 2300 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2329 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2301 | template <> | 2330 | template <> |
| 2302 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*); | 2331 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*); |
| 2303 | template <> | 2332 | template <> |
| 2304 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*); | 2333 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*); |
| 2305 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; | 2334 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; |
| 2306 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; | 2335 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; |
| 2307 | #endif | 2336 | # endif |
| 2308 | 2337 | ||
| 2309 | // money_get | 2338 | // money_get |
| 2310 | 2339 | ||
| ... | @@ -2365,9 +2394,9 @@ void __money_get<_CharT>::__gather_info( | ... | @@ -2365,9 +2394,9 @@ void __money_get<_CharT>::__gather_info( |
| 2365 | } | 2394 | } |
| 2366 | 2395 | ||
| 2367 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; | 2396 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; |
| 2368 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2397 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2369 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; | 2398 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; |
| 2370 | #endif | 2399 | # endif |
| 2371 | 2400 | ||
| 2372 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | 2401 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 2373 | class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { | 2402 | class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { |
| ... | @@ -2675,9 +2704,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get( | ... | @@ -2675,9 +2704,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get( |
| 2675 | } | 2704 | } |
| 2676 | 2705 | ||
| 2677 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; | 2706 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; |
| 2678 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2707 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2679 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; | 2708 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; |
| 2680 | #endif | 2709 | # endif |
| 2681 | 2710 | ||
| 2682 | // money_put | 2711 | // money_put |
| 2683 | 2712 | ||
| ... | @@ -2853,9 +2882,9 @@ void __money_put<_CharT>::__format( | ... | @@ -2853,9 +2882,9 @@ void __money_put<_CharT>::__format( |
| 2853 | } | 2882 | } |
| 2854 | 2883 | ||
| 2855 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; | 2884 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; |
| 2856 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 2885 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2857 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; | 2886 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; |
| 2858 | #endif | 2887 | # endif |
| 2859 | 2888 | ||
| 2860 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | 2889 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 2861 | class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { | 2890 | class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { |
| ... | @@ -2999,9 +3028,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put( | ... | @@ -2999,9 +3028,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put( |
| 2999 | } | 3028 | } |
| 3000 | 3029 | ||
| 3001 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; | 3030 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; |
| 3002 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 3031 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3003 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; | 3032 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; |
| 3004 | #endif | 3033 | # endif |
| 3005 | 3034 | ||
| 3006 | // messages | 3035 | // messages |
| 3007 | 3036 | ||
| ... | @@ -3045,18 +3074,18 @@ locale::id messages<_CharT>::id; | ... | @@ -3045,18 +3074,18 @@ locale::id messages<_CharT>::id; |
| 3045 | 3074 | ||
| 3046 | template <class _CharT> | 3075 | template <class _CharT> |
| 3047 | typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { | 3076 | typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { |
| 3048 | #ifdef _LIBCPP_HAS_CATOPEN | 3077 | # ifdef _LIBCPP_HAS_CATOPEN |
| 3049 | return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); | 3078 | return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); |
| 3050 | #else // !_LIBCPP_HAS_CATOPEN | 3079 | # else // !_LIBCPP_HAS_CATOPEN |
| 3051 | (void)__nm; | 3080 | (void)__nm; |
| 3052 | return -1; | 3081 | return -1; |
| 3053 | #endif // _LIBCPP_HAS_CATOPEN | 3082 | # endif // _LIBCPP_HAS_CATOPEN |
| 3054 | } | 3083 | } |
| 3055 | 3084 | ||
| 3056 | template <class _CharT> | 3085 | template <class _CharT> |
| 3057 | typename messages<_CharT>::string_type | 3086 | typename messages<_CharT>::string_type |
| 3058 | messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { | 3087 | messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { |
| 3059 | #ifdef _LIBCPP_HAS_CATOPEN | 3088 | # ifdef _LIBCPP_HAS_CATOPEN |
| 3060 | string __ndflt; | 3089 | string __ndflt; |
| 3061 | __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()( | 3090 | __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()( |
| 3062 | std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); | 3091 | std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); |
| ... | @@ -3066,27 +3095,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& | ... | @@ -3066,27 +3095,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& |
| 3066 | string_type __w; | 3095 | string_type __w; |
| 3067 | __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n)); | 3096 | __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n)); |
| 3068 | return __w; | 3097 | return __w; |
| 3069 | #else // !_LIBCPP_HAS_CATOPEN | 3098 | # else // !_LIBCPP_HAS_CATOPEN |
| 3070 | (void)__c; | 3099 | (void)__c; |
| 3071 | (void)__set; | 3100 | (void)__set; |
| 3072 | (void)__msgid; | 3101 | (void)__msgid; |
| 3073 | return __dflt; | 3102 | return __dflt; |
| 3074 | #endif // _LIBCPP_HAS_CATOPEN | 3103 | # endif // _LIBCPP_HAS_CATOPEN |
| 3075 | } | 3104 | } |
| 3076 | 3105 | ||
| 3077 | template <class _CharT> | 3106 | template <class _CharT> |
| 3078 | void messages<_CharT>::do_close(catalog __c) const { | 3107 | void messages<_CharT>::do_close(catalog __c) const { |
| 3079 | #ifdef _LIBCPP_HAS_CATOPEN | 3108 | # ifdef _LIBCPP_HAS_CATOPEN |
| 3080 | catclose((nl_catd)__c); | 3109 | catclose((nl_catd)__c); |
| 3081 | #else // !_LIBCPP_HAS_CATOPEN | 3110 | # else // !_LIBCPP_HAS_CATOPEN |
| 3082 | (void)__c; | 3111 | (void)__c; |
| 3083 | #endif // _LIBCPP_HAS_CATOPEN | 3112 | # endif // _LIBCPP_HAS_CATOPEN |
| 3084 | } | 3113 | } |
| 3085 | 3114 | ||
| 3086 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; | 3115 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; |
| 3087 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 3116 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3088 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; | 3117 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; |
| 3089 | #endif | 3118 | # endif |
| 3090 | 3119 | ||
| 3091 | template <class _CharT> | 3120 | template <class _CharT> |
| 3092 | class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { | 3121 | class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { |
| ... | @@ -3103,9 +3132,11 @@ protected: | ... | @@ -3103,9 +3132,11 @@ protected: |
| 3103 | }; | 3132 | }; |
| 3104 | 3133 | ||
| 3105 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; | 3134 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; |
| 3106 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 3135 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3107 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; | 3136 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; |
| 3108 | #endif | 3137 | # endif |
| 3138 | |||
| 3139 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 3109 | 3140 | ||
| 3110 | template <class _Codecvt, | 3141 | template <class _Codecvt, |
| 3111 | class _Elem = wchar_t, | 3142 | class _Elem = wchar_t, |
| ... | @@ -3125,25 +3156,25 @@ private: | ... | @@ -3125,25 +3156,25 @@ private: |
| 3125 | state_type __cvtstate_; | 3156 | state_type __cvtstate_; |
| 3126 | size_t __cvtcount_; | 3157 | size_t __cvtcount_; |
| 3127 | 3158 | ||
| 3128 | wstring_convert(const wstring_convert& __wc); | ||
| 3129 | wstring_convert& operator=(const wstring_convert& __wc); | ||
| 3130 | |||
| 3131 | public: | 3159 | public: |
| 3132 | #ifndef _LIBCPP_CXX03_LANG | 3160 | # ifndef _LIBCPP_CXX03_LANG |
| 3133 | _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {} | 3161 | _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {} |
| 3134 | _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt); | 3162 | _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt); |
| 3135 | #else | 3163 | # else |
| 3136 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt); | 3164 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt); |
| 3137 | #endif | 3165 | # endif |
| 3138 | 3166 | ||
| 3139 | _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state); | 3167 | _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state); |
| 3140 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | 3168 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
| 3141 | wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); | 3169 | wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); |
| 3142 | #ifndef _LIBCPP_CXX03_LANG | 3170 | # ifndef _LIBCPP_CXX03_LANG |
| 3143 | _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc); | 3171 | _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc); |
| 3144 | #endif | 3172 | # endif |
| 3145 | _LIBCPP_HIDE_FROM_ABI ~wstring_convert(); | 3173 | _LIBCPP_HIDE_FROM_ABI ~wstring_convert(); |
| 3146 | 3174 | ||
| 3175 | wstring_convert(const wstring_convert& __wc) = delete; | ||
| 3176 | wstring_convert& operator=(const wstring_convert& __wc) = delete; | ||
| 3177 | |||
| 3147 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); } | 3178 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); } |
| 3148 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) { | 3179 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) { |
| 3149 | return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr)); | 3180 | return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr)); |
| ... | @@ -3183,7 +3214,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert( | ... | @@ -3183,7 +3214,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert( |
| 3183 | __cvtptr_ = new _Codecvt; | 3214 | __cvtptr_ = new _Codecvt; |
| 3184 | } | 3215 | } |
| 3185 | 3216 | ||
| 3186 | #ifndef _LIBCPP_CXX03_LANG | 3217 | # ifndef _LIBCPP_CXX03_LANG |
| 3187 | 3218 | ||
| 3188 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | 3219 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> |
| 3189 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) | 3220 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) |
| ... | @@ -3195,7 +3226,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert | ... | @@ -3195,7 +3226,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert |
| 3195 | __wc.__cvtptr_ = nullptr; | 3226 | __wc.__cvtptr_ = nullptr; |
| 3196 | } | 3227 | } |
| 3197 | 3228 | ||
| 3198 | #endif // _LIBCPP_CXX03_LANG | 3229 | # endif // _LIBCPP_CXX03_LANG |
| 3199 | 3230 | ||
| 3200 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 3231 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 3201 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | 3232 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> |
| ... | @@ -3348,18 +3379,15 @@ private: | ... | @@ -3348,18 +3379,15 @@ private: |
| 3348 | bool __owns_ib_; | 3379 | bool __owns_ib_; |
| 3349 | bool __always_noconv_; | 3380 | bool __always_noconv_; |
| 3350 | 3381 | ||
| 3351 | wbuffer_convert(const wbuffer_convert&); | ||
| 3352 | wbuffer_convert& operator=(const wbuffer_convert&); | ||
| 3353 | |||
| 3354 | public: | 3382 | public: |
| 3355 | #ifndef _LIBCPP_CXX03_LANG | 3383 | # ifndef _LIBCPP_CXX03_LANG |
| 3356 | _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} | 3384 | _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} |
| 3357 | explicit _LIBCPP_HIDE_FROM_ABI | 3385 | explicit _LIBCPP_HIDE_FROM_ABI |
| 3358 | wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); | 3386 | wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); |
| 3359 | #else | 3387 | # else |
| 3360 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | 3388 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
| 3361 | wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); | 3389 | wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); |
| 3362 | #endif | 3390 | # endif |
| 3363 | 3391 | ||
| 3364 | _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); | 3392 | _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); |
| 3365 | 3393 | ||
| ... | @@ -3370,6 +3398,9 @@ public: | ... | @@ -3370,6 +3398,9 @@ public: |
| 3370 | return __r; | 3398 | return __r; |
| 3371 | } | 3399 | } |
| 3372 | 3400 | ||
| 3401 | wbuffer_convert(const wbuffer_convert&) = delete; | ||
| 3402 | wbuffer_convert& operator=(const wbuffer_convert&) = delete; | ||
| 3403 | |||
| 3373 | _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; } | 3404 | _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; } |
| 3374 | 3405 | ||
| 3375 | protected: | 3406 | protected: |
| ... | @@ -3712,12 +3743,16 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__ | ... | @@ -3712,12 +3743,16 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__ |
| 3712 | 3743 | ||
| 3713 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 3744 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 3714 | 3745 | ||
| 3746 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 3747 | |||
| 3715 | _LIBCPP_END_NAMESPACE_STD | 3748 | _LIBCPP_END_NAMESPACE_STD |
| 3716 | 3749 | ||
| 3717 | _LIBCPP_POP_MACROS | 3750 | _LIBCPP_POP_MACROS |
| 3718 | 3751 | ||
| 3719 | // NOLINTEND(libcpp-robust-against-adl) | 3752 | // NOLINTEND(libcpp-robust-against-adl) |
| 3720 | 3753 | ||
| 3754 | #endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 3755 | |||
| 3721 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 3756 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 3722 | # include <atomic> | 3757 | # include <atomic> |
| 3723 | # include <concepts> | 3758 | # include <concepts> |
lib/libcxx/include/locale.h-4| ... | @@ -35,10 +35,6 @@ Functions: | ... | @@ -35,10 +35,6 @@ Functions: |
| 35 | 35 | ||
| 36 | #include <__config> | 36 | #include <__config> |
| 37 | 37 | ||
| 38 | #if defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 39 | # error "<locale.h> is not supported since libc++ has been configured without support for localization." | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 43 | # pragma GCC system_header | 39 | # pragma GCC system_header |
| 44 | #endif | 40 | #endif |
lib/libcxx/include/map+58-76| ... | @@ -574,8 +574,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -574,8 +574,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 574 | #include <__algorithm/equal.h> | 574 | #include <__algorithm/equal.h> |
| 575 | #include <__algorithm/lexicographical_compare.h> | 575 | #include <__algorithm/lexicographical_compare.h> |
| 576 | #include <__algorithm/lexicographical_compare_three_way.h> | 576 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 577 | #include <__assert> // all public C++ headers provide the assertion handler | 577 | #include <__assert> |
| 578 | #include <__availability> | ||
| 579 | #include <__config> | 578 | #include <__config> |
| 580 | #include <__functional/binary_function.h> | 579 | #include <__functional/binary_function.h> |
| 581 | #include <__functional/is_transparent.h> | 580 | #include <__functional/is_transparent.h> |
| ... | @@ -642,7 +641,7 @@ public: | ... | @@ -642,7 +641,7 @@ public: |
| 642 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { | 641 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { |
| 643 | return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first); | 642 | return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first); |
| 644 | } | 643 | } |
| 645 | _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) { | 644 | _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { |
| 646 | using std::swap; | 645 | using std::swap; |
| 647 | swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); | 646 | swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); |
| 648 | } | 647 | } |
| ... | @@ -680,7 +679,7 @@ public: | ... | @@ -680,7 +679,7 @@ public: |
| 680 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { | 679 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { |
| 681 | return __comp_(__x, __y.__get_value().first); | 680 | return __comp_(__x, __y.__get_value().first); |
| 682 | } | 681 | } |
| 683 | void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) { | 682 | void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { |
| 684 | using std::swap; | 683 | using std::swap; |
| 685 | swap(__comp_, __y.__comp_); | 684 | swap(__comp_, __y.__comp_); |
| 686 | } | 685 | } |
| ... | @@ -716,8 +715,6 @@ public: | ... | @@ -716,8 +715,6 @@ public: |
| 716 | private: | 715 | private: |
| 717 | allocator_type& __na_; | 716 | allocator_type& __na_; |
| 718 | 717 | ||
| 719 | __map_node_destructor& operator=(const __map_node_destructor&); | ||
| 720 | |||
| 721 | public: | 718 | public: |
| 722 | bool __first_constructed; | 719 | bool __first_constructed; |
| 723 | bool __second_constructed; | 720 | bool __second_constructed; |
| ... | @@ -736,6 +733,8 @@ public: | ... | @@ -736,6 +733,8 @@ public: |
| 736 | } | 733 | } |
| 737 | #endif // _LIBCPP_CXX03_LANG | 734 | #endif // _LIBCPP_CXX03_LANG |
| 738 | 735 | ||
| 736 | __map_node_destructor& operator=(const __map_node_destructor&) = delete; | ||
| 737 | |||
| 739 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 738 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 740 | if (__second_constructed) | 739 | if (__second_constructed) |
| 741 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second)); | 740 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second)); |
| ... | @@ -803,13 +802,12 @@ public: | ... | @@ -803,13 +802,12 @@ public: |
| 803 | return *this; | 802 | return *this; |
| 804 | } | 803 | } |
| 805 | 804 | ||
| 806 | template <class _ValueTp, class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> > | 805 | template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0> |
| 807 | _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) { | 806 | _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) { |
| 808 | __ref() = std::forward<_ValueTp>(__v); | 807 | __ref() = std::forward<_ValueTp>(__v); |
| 809 | return *this; | 808 | return *this; |
| 810 | } | 809 | } |
| 811 | 810 | ||
| 812 | private: | ||
| 813 | __value_type() = delete; | 811 | __value_type() = delete; |
| 814 | ~__value_type() = delete; | 812 | ~__value_type() = delete; |
| 815 | __value_type(const __value_type&) = delete; | 813 | __value_type(const __value_type&) = delete; |
| ... | @@ -831,11 +829,10 @@ public: | ... | @@ -831,11 +829,10 @@ public: |
| 831 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } | 829 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } |
| 832 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } | 830 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } |
| 833 | 831 | ||
| 834 | private: | 832 | __value_type() = delete; |
| 835 | __value_type(); | 833 | __value_type(__value_type const&) = delete; |
| 836 | __value_type(__value_type const&); | 834 | __value_type& operator=(__value_type const&) = delete; |
| 837 | __value_type& operator=(__value_type const&); | 835 | ~__value_type() = delete; |
| 838 | ~__value_type(); | ||
| 839 | }; | 836 | }; |
| 840 | 837 | ||
| 841 | #endif // _LIBCPP_CXX03_LANG | 838 | #endif // _LIBCPP_CXX03_LANG |
| ... | @@ -975,7 +972,7 @@ public: | ... | @@ -975,7 +972,7 @@ public: |
| 975 | typedef value_type& reference; | 972 | typedef value_type& reference; |
| 976 | typedef const value_type& const_reference; | 973 | typedef const value_type& const_reference; |
| 977 | 974 | ||
| 978 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 975 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| 979 | "Allocator::value_type must be same type as value_type"); | 976 | "Allocator::value_type must be same type as value_type"); |
| 980 | 977 | ||
| 981 | class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { | 978 | class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { |
| ... | @@ -1000,9 +997,7 @@ private: | ... | @@ -1000,9 +997,7 @@ private: |
| 1000 | typedef typename __base::__node_traits __node_traits; | 997 | typedef typename __base::__node_traits __node_traits; |
| 1001 | typedef allocator_traits<allocator_type> __alloc_traits; | 998 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1002 | 999 | ||
| 1003 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | 1000 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 1004 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 1005 | "original allocator"); | ||
| 1006 | 1001 | ||
| 1007 | __base __tree_; | 1002 | __base __tree_; |
| 1008 | 1003 | ||
| ... | @@ -1093,12 +1088,12 @@ public: | ... | @@ -1093,12 +1088,12 @@ public: |
| 1093 | 1088 | ||
| 1094 | #ifndef _LIBCPP_CXX03_LANG | 1089 | #ifndef _LIBCPP_CXX03_LANG |
| 1095 | 1090 | ||
| 1096 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) | 1091 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) |
| 1097 | : __tree_(std::move(__m.__tree_)) {} | 1092 | : __tree_(std::move(__m.__tree_)) {} |
| 1098 | 1093 | ||
| 1099 | _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a); | 1094 | _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a); |
| 1100 | 1095 | ||
| 1101 | _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { | 1096 | _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) { |
| 1102 | __tree_ = std::move(__m.__tree_); | 1097 | __tree_ = std::move(__m.__tree_); |
| 1103 | return *this; | 1098 | return *this; |
| 1104 | } | 1099 | } |
| ... | @@ -1149,7 +1144,7 @@ public: | ... | @@ -1149,7 +1144,7 @@ public: |
| 1149 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 1144 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1150 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1145 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1151 | 1146 | ||
| 1152 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 1147 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 1153 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 1148 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1154 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 1149 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1155 | 1150 | ||
| ... | @@ -1176,12 +1171,12 @@ public: | ... | @@ -1176,12 +1171,12 @@ public: |
| 1176 | return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...); | 1171 | return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...); |
| 1177 | } | 1172 | } |
| 1178 | 1173 | ||
| 1179 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | 1174 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1180 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) { | 1175 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) { |
| 1181 | return __tree_.__insert_unique(std::forward<_Pp>(__p)); | 1176 | return __tree_.__insert_unique(std::forward<_Pp>(__p)); |
| 1182 | } | 1177 | } |
| 1183 | 1178 | ||
| 1184 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | 1179 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1185 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { | 1180 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { |
| 1186 | return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p)); | 1181 | return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p)); |
| 1187 | } | 1182 | } |
| ... | @@ -1360,18 +1355,16 @@ public: | ... | @@ -1360,18 +1355,16 @@ public: |
| 1360 | } | 1355 | } |
| 1361 | #endif | 1356 | #endif |
| 1362 | 1357 | ||
| 1363 | _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) { | 1358 | _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); } |
| 1364 | __tree_.swap(__m.__tree_); | ||
| 1365 | } | ||
| 1366 | 1359 | ||
| 1367 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 1360 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1368 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 1361 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1369 | #if _LIBCPP_STD_VER >= 14 | 1362 | #if _LIBCPP_STD_VER >= 14 |
| 1370 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1363 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1371 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1364 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1372 | return __tree_.find(__k); | 1365 | return __tree_.find(__k); |
| 1373 | } | 1366 | } |
| 1374 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1367 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1375 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1368 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1376 | return __tree_.find(__k); | 1369 | return __tree_.find(__k); |
| 1377 | } | 1370 | } |
| ... | @@ -1379,7 +1372,7 @@ public: | ... | @@ -1379,7 +1372,7 @@ public: |
| 1379 | 1372 | ||
| 1380 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } | 1373 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } |
| 1381 | #if _LIBCPP_STD_VER >= 14 | 1374 | #if _LIBCPP_STD_VER >= 14 |
| 1382 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1375 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1383 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1376 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1384 | return __tree_.__count_multi(__k); | 1377 | return __tree_.__count_multi(__k); |
| 1385 | } | 1378 | } |
| ... | @@ -1387,7 +1380,7 @@ public: | ... | @@ -1387,7 +1380,7 @@ public: |
| 1387 | 1380 | ||
| 1388 | #if _LIBCPP_STD_VER >= 20 | 1381 | #if _LIBCPP_STD_VER >= 20 |
| 1389 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1382 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1390 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1383 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1391 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1384 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1392 | return find(__k) != end(); | 1385 | return find(__k) != end(); |
| 1393 | } | 1386 | } |
| ... | @@ -1396,12 +1389,12 @@ public: | ... | @@ -1396,12 +1389,12 @@ public: |
| 1396 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 1389 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 1397 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 1390 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 1398 | #if _LIBCPP_STD_VER >= 14 | 1391 | #if _LIBCPP_STD_VER >= 14 |
| 1399 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1392 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1400 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 1393 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1401 | return __tree_.lower_bound(__k); | 1394 | return __tree_.lower_bound(__k); |
| 1402 | } | 1395 | } |
| 1403 | 1396 | ||
| 1404 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1397 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1405 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 1398 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1406 | return __tree_.lower_bound(__k); | 1399 | return __tree_.lower_bound(__k); |
| 1407 | } | 1400 | } |
| ... | @@ -1410,11 +1403,11 @@ public: | ... | @@ -1410,11 +1403,11 @@ public: |
| 1410 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 1403 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 1411 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 1404 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 1412 | #if _LIBCPP_STD_VER >= 14 | 1405 | #if _LIBCPP_STD_VER >= 14 |
| 1413 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1406 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1414 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 1407 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1415 | return __tree_.upper_bound(__k); | 1408 | return __tree_.upper_bound(__k); |
| 1416 | } | 1409 | } |
| 1417 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1410 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1418 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 1411 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1419 | return __tree_.upper_bound(__k); | 1412 | return __tree_.upper_bound(__k); |
| 1420 | } | 1413 | } |
| ... | @@ -1427,11 +1420,11 @@ public: | ... | @@ -1427,11 +1420,11 @@ public: |
| 1427 | return __tree_.__equal_range_unique(__k); | 1420 | return __tree_.__equal_range_unique(__k); |
| 1428 | } | 1421 | } |
| 1429 | #if _LIBCPP_STD_VER >= 14 | 1422 | #if _LIBCPP_STD_VER >= 14 |
| 1430 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1423 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1431 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1424 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1432 | return __tree_.__equal_range_multi(__k); | 1425 | return __tree_.__equal_range_multi(__k); |
| 1433 | } | 1426 | } |
| 1434 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1427 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1435 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1428 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1436 | return __tree_.__equal_range_multi(__k); | 1429 | return __tree_.__equal_range_multi(__k); |
| 1437 | } | 1430 | } |
| ... | @@ -1478,8 +1471,9 @@ template <class _Key, | ... | @@ -1478,8 +1471,9 @@ template <class _Key, |
| 1478 | class _Allocator = allocator<pair<const _Key, _Tp>>, | 1471 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 1479 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 1472 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 1480 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1473 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1481 | map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) | 1474 | map(initializer_list<pair<_Key, _Tp>>, |
| 1482 | -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; | 1475 | _Compare = _Compare(), |
| 1476 | _Allocator = _Allocator()) -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; | ||
| 1483 | 1477 | ||
| 1484 | template <class _InputIterator, | 1478 | template <class _InputIterator, |
| 1485 | class _Allocator, | 1479 | class _Allocator, |
| ... | @@ -1498,8 +1492,8 @@ map(from_range_t, _Range&&, _Allocator) | ... | @@ -1498,8 +1492,8 @@ map(from_range_t, _Range&&, _Allocator) |
| 1498 | # endif | 1492 | # endif |
| 1499 | 1493 | ||
| 1500 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1494 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1501 | map(initializer_list<pair<_Key, _Tp>>, _Allocator) | 1495 | map(initializer_list<pair<_Key, _Tp>>, |
| 1502 | -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; | 1496 | _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 1503 | #endif | 1497 | #endif |
| 1504 | 1498 | ||
| 1505 | #ifndef _LIBCPP_CXX03_LANG | 1499 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -1623,12 +1617,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, | ... | @@ -1623,12 +1617,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, |
| 1623 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1617 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1624 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>> | 1618 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>> |
| 1625 | operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { | 1619 | operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) { |
| 1626 | return std::lexicographical_compare_three_way( | 1620 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1627 | __x.begin(), | ||
| 1628 | __x.end(), | ||
| 1629 | __y.begin(), | ||
| 1630 | __y.end(), | ||
| 1631 | std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>); | ||
| 1632 | } | 1621 | } |
| 1633 | 1622 | ||
| 1634 | #endif // #if _LIBCPP_STD_VER <= 17 | 1623 | #endif // #if _LIBCPP_STD_VER <= 17 |
| ... | @@ -1660,7 +1649,8 @@ public: | ... | @@ -1660,7 +1649,8 @@ public: |
| 1660 | typedef value_type& reference; | 1649 | typedef value_type& reference; |
| 1661 | typedef const value_type& const_reference; | 1650 | typedef const value_type& const_reference; |
| 1662 | 1651 | ||
| 1663 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 1652 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 1653 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | ||
| 1664 | "Allocator::value_type must be same type as value_type"); | 1654 | "Allocator::value_type must be same type as value_type"); |
| 1665 | 1655 | ||
| 1666 | class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { | 1656 | class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { |
| ... | @@ -1685,10 +1675,6 @@ private: | ... | @@ -1685,10 +1675,6 @@ private: |
| 1685 | typedef typename __base::__node_traits __node_traits; | 1675 | typedef typename __base::__node_traits __node_traits; |
| 1686 | typedef allocator_traits<allocator_type> __alloc_traits; | 1676 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1687 | 1677 | ||
| 1688 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | ||
| 1689 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 1690 | "original allocator"); | ||
| 1691 | |||
| 1692 | __base __tree_; | 1678 | __base __tree_; |
| 1693 | 1679 | ||
| 1694 | public: | 1680 | public: |
| ... | @@ -1781,12 +1767,12 @@ public: | ... | @@ -1781,12 +1767,12 @@ public: |
| 1781 | 1767 | ||
| 1782 | #ifndef _LIBCPP_CXX03_LANG | 1768 | #ifndef _LIBCPP_CXX03_LANG |
| 1783 | 1769 | ||
| 1784 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) | 1770 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) |
| 1785 | : __tree_(std::move(__m.__tree_)) {} | 1771 | : __tree_(std::move(__m.__tree_)) {} |
| 1786 | 1772 | ||
| 1787 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a); | 1773 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a); |
| 1788 | 1774 | ||
| 1789 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { | 1775 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) { |
| 1790 | __tree_ = std::move(__m.__tree_); | 1776 | __tree_ = std::move(__m.__tree_); |
| 1791 | return *this; | 1777 | return *this; |
| 1792 | } | 1778 | } |
| ... | @@ -1838,7 +1824,7 @@ public: | ... | @@ -1838,7 +1824,7 @@ public: |
| 1838 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 1824 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1839 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1825 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1840 | 1826 | ||
| 1841 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 1827 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 1842 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 1828 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1843 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 1829 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1844 | 1830 | ||
| ... | @@ -1858,12 +1844,12 @@ public: | ... | @@ -1858,12 +1844,12 @@ public: |
| 1858 | return __tree_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...); | 1844 | return __tree_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...); |
| 1859 | } | 1845 | } |
| 1860 | 1846 | ||
| 1861 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value>> | 1847 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1862 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) { | 1848 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) { |
| 1863 | return __tree_.__insert_multi(std::forward<_Pp>(__p)); | 1849 | return __tree_.__insert_multi(std::forward<_Pp>(__p)); |
| 1864 | } | 1850 | } |
| 1865 | 1851 | ||
| 1866 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value>> | 1852 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1867 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { | 1853 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { |
| 1868 | return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p)); | 1854 | return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p)); |
| 1869 | } | 1855 | } |
| ... | @@ -1952,18 +1938,18 @@ public: | ... | @@ -1952,18 +1938,18 @@ public: |
| 1952 | 1938 | ||
| 1953 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } | 1939 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } |
| 1954 | 1940 | ||
| 1955 | _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) { | 1941 | _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { |
| 1956 | __tree_.swap(__m.__tree_); | 1942 | __tree_.swap(__m.__tree_); |
| 1957 | } | 1943 | } |
| 1958 | 1944 | ||
| 1959 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 1945 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1960 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 1946 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1961 | #if _LIBCPP_STD_VER >= 14 | 1947 | #if _LIBCPP_STD_VER >= 14 |
| 1962 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1948 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1963 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1949 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1964 | return __tree_.find(__k); | 1950 | return __tree_.find(__k); |
| 1965 | } | 1951 | } |
| 1966 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1952 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1967 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1953 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1968 | return __tree_.find(__k); | 1954 | return __tree_.find(__k); |
| 1969 | } | 1955 | } |
| ... | @@ -1971,7 +1957,7 @@ public: | ... | @@ -1971,7 +1957,7 @@ public: |
| 1971 | 1957 | ||
| 1972 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } | 1958 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } |
| 1973 | #if _LIBCPP_STD_VER >= 14 | 1959 | #if _LIBCPP_STD_VER >= 14 |
| 1974 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1960 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1975 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1961 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1976 | return __tree_.__count_multi(__k); | 1962 | return __tree_.__count_multi(__k); |
| 1977 | } | 1963 | } |
| ... | @@ -1979,7 +1965,7 @@ public: | ... | @@ -1979,7 +1965,7 @@ public: |
| 1979 | 1965 | ||
| 1980 | #if _LIBCPP_STD_VER >= 20 | 1966 | #if _LIBCPP_STD_VER >= 20 |
| 1981 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1967 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1982 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1968 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1983 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1969 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1984 | return find(__k) != end(); | 1970 | return find(__k) != end(); |
| 1985 | } | 1971 | } |
| ... | @@ -1988,12 +1974,12 @@ public: | ... | @@ -1988,12 +1974,12 @@ public: |
| 1988 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 1974 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 1989 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 1975 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 1990 | #if _LIBCPP_STD_VER >= 14 | 1976 | #if _LIBCPP_STD_VER >= 14 |
| 1991 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1977 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1992 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 1978 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1993 | return __tree_.lower_bound(__k); | 1979 | return __tree_.lower_bound(__k); |
| 1994 | } | 1980 | } |
| 1995 | 1981 | ||
| 1996 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1982 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1997 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 1983 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1998 | return __tree_.lower_bound(__k); | 1984 | return __tree_.lower_bound(__k); |
| 1999 | } | 1985 | } |
| ... | @@ -2002,11 +1988,11 @@ public: | ... | @@ -2002,11 +1988,11 @@ public: |
| 2002 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 1988 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 2003 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 1989 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 2004 | #if _LIBCPP_STD_VER >= 14 | 1990 | #if _LIBCPP_STD_VER >= 14 |
| 2005 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1991 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 2006 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 1992 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 2007 | return __tree_.upper_bound(__k); | 1993 | return __tree_.upper_bound(__k); |
| 2008 | } | 1994 | } |
| 2009 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1995 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 2010 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 1996 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 2011 | return __tree_.upper_bound(__k); | 1997 | return __tree_.upper_bound(__k); |
| 2012 | } | 1998 | } |
| ... | @@ -2019,11 +2005,11 @@ public: | ... | @@ -2019,11 +2005,11 @@ public: |
| 2019 | return __tree_.__equal_range_multi(__k); | 2005 | return __tree_.__equal_range_multi(__k); |
| 2020 | } | 2006 | } |
| 2021 | #if _LIBCPP_STD_VER >= 14 | 2007 | #if _LIBCPP_STD_VER >= 14 |
| 2022 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 2008 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 2023 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 2009 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 2024 | return __tree_.__equal_range_multi(__k); | 2010 | return __tree_.__equal_range_multi(__k); |
| 2025 | } | 2011 | } |
| 2026 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 2012 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 2027 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 2013 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 2028 | return __tree_.__equal_range_multi(__k); | 2014 | return __tree_.__equal_range_multi(__k); |
| 2029 | } | 2015 | } |
| ... | @@ -2064,8 +2050,9 @@ template <class _Key, | ... | @@ -2064,8 +2050,9 @@ template <class _Key, |
| 2064 | class _Allocator = allocator<pair<const _Key, _Tp>>, | 2050 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 2065 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 2051 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 2066 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2052 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 2067 | multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) | 2053 | multimap(initializer_list<pair<_Key, _Tp>>, |
| 2068 | -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; | 2054 | _Compare = _Compare(), |
| 2055 | _Allocator = _Allocator()) -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; | ||
| 2069 | 2056 | ||
| 2070 | template <class _InputIterator, | 2057 | template <class _InputIterator, |
| 2071 | class _Allocator, | 2058 | class _Allocator, |
| ... | @@ -2084,8 +2071,8 @@ multimap(from_range_t, _Range&&, _Allocator) | ... | @@ -2084,8 +2071,8 @@ multimap(from_range_t, _Range&&, _Allocator) |
| 2084 | # endif | 2071 | # endif |
| 2085 | 2072 | ||
| 2086 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2073 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 2087 | multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) | 2074 | multimap(initializer_list<pair<_Key, _Tp>>, |
| 2088 | -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; | 2075 | _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 2089 | #endif | 2076 | #endif |
| 2090 | 2077 | ||
| 2091 | #ifndef _LIBCPP_CXX03_LANG | 2078 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -2144,12 +2131,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> | ... | @@ -2144,12 +2131,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2144 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>> | 2131 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>> |
| 2145 | operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, | 2132 | operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2146 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { | 2133 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) { |
| 2147 | return std::lexicographical_compare_three_way( | 2134 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); |
| 2148 | __x.begin(), | ||
| 2149 | __x.end(), | ||
| 2150 | __y.begin(), | ||
| 2151 | __y.end(), | ||
| 2152 | std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>); | ||
| 2153 | } | 2135 | } |
| 2154 | 2136 | ||
| 2155 | #endif // #if _LIBCPP_STD_VER <= 17 | 2137 | #endif // #if _LIBCPP_STD_VER <= 17 |
lib/libcxx/include/math.h+4-4| ... | @@ -388,22 +388,22 @@ namespace __math { | ... | @@ -388,22 +388,22 @@ namespace __math { |
| 388 | 388 | ||
| 389 | // template on non-double overloads to make them weaker than same overloads from MSVC runtime | 389 | // template on non-double overloads to make them weaker than same overloads from MSVC runtime |
| 390 | template <class = int> | 390 | template <class = int> |
| 391 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { | 391 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { |
| 392 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); | 392 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | template <class = int> | 395 | template <class = int> |
| 396 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { | 396 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { |
| 397 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); | 397 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | template <class = int> | 400 | template <class = int> |
| 401 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { | 401 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { |
| 402 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); | 402 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> | 405 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> |
| 406 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { | 406 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { |
| 407 | return __x == 0 ? FP_ZERO : FP_NORMAL; | 407 | return __x == 0 ? FP_ZERO : FP_NORMAL; |
| 408 | } | 408 | } |
| 409 | 409 |
lib/libcxx/include/mdspan+29-8| ... | @@ -20,6 +20,10 @@ namespace std { | ... | @@ -20,6 +20,10 @@ namespace std { |
| 20 | template<class IndexType, size_t Rank> | 20 | template<class IndexType, size_t Rank> |
| 21 | using dextents = see below; | 21 | using dextents = see below; |
| 22 | 22 | ||
| 23 | // [mdspan.extents.dims], alias template dims | ||
| 24 | template<size_t Rank, class IndexType = size_t> | ||
| 25 | using dims = see below; // since C++26 | ||
| 26 | |||
| 23 | // [mdspan.layout], layout mapping | 27 | // [mdspan.layout], layout mapping |
| 24 | struct layout_left; | 28 | struct layout_left; |
| 25 | struct layout_right; | 29 | struct layout_right; |
| ... | @@ -370,7 +374,11 @@ namespace std { | ... | @@ -370,7 +374,11 @@ namespace std { |
| 370 | template<class ElementType, class... Integrals> | 374 | template<class ElementType, class... Integrals> |
| 371 | requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0) | 375 | requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0) |
| 372 | explicit mdspan(ElementType*, Integrals...) | 376 | explicit mdspan(ElementType*, Integrals...) |
| 373 | -> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>; | 377 | -> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>; // until C++26 |
| 378 | template<class ElementType, class... Integrals> | ||
| 379 | requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0) | ||
| 380 | explicit mdspan(ElementType*, Integrals...) | ||
| 381 | -> mdspan<ElementType, extents<size_t, maybe-static-ext<Integrals>...>>; // since C++26 | ||
| 374 | 382 | ||
| 375 | template<class ElementType, class OtherIndexType, size_t N> | 383 | template<class ElementType, class OtherIndexType, size_t N> |
| 376 | mdspan(ElementType*, span<OtherIndexType, N>) | 384 | mdspan(ElementType*, span<OtherIndexType, N>) |
| ... | @@ -401,17 +409,30 @@ namespace std { | ... | @@ -401,17 +409,30 @@ namespace std { |
| 401 | #define _LIBCPP_MDSPAN | 409 | #define _LIBCPP_MDSPAN |
| 402 | 410 | ||
| 403 | #include <__config> | 411 | #include <__config> |
| 404 | #include <__fwd/mdspan.h> | 412 | |
| 405 | #include <__mdspan/default_accessor.h> | 413 | #if _LIBCPP_STD_VER >= 23 |
| 406 | #include <__mdspan/extents.h> | 414 | # include <__fwd/mdspan.h> |
| 407 | #include <__mdspan/layout_left.h> | 415 | # include <__mdspan/default_accessor.h> |
| 408 | #include <__mdspan/layout_right.h> | 416 | # include <__mdspan/extents.h> |
| 409 | #include <__mdspan/layout_stride.h> | 417 | # include <__mdspan/layout_left.h> |
| 410 | #include <__mdspan/mdspan.h> | 418 | # include <__mdspan/layout_right.h> |
| 419 | # include <__mdspan/layout_stride.h> | ||
| 420 | # include <__mdspan/mdspan.h> | ||
| 421 | #endif | ||
| 422 | |||
| 411 | #include <version> | 423 | #include <version> |
| 412 | 424 | ||
| 413 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 425 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 414 | # pragma GCC system_header | 426 | # pragma GCC system_header |
| 415 | #endif | 427 | #endif |
| 416 | 428 | ||
| 429 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 430 | # include <array> | ||
| 431 | # include <cinttypes> | ||
| 432 | # include <concepts> | ||
| 433 | # include <cstddef> | ||
| 434 | # include <limits> | ||
| 435 | # include <span> | ||
| 436 | #endif | ||
| 437 | |||
| 417 | #endif // _LIBCPP_MDSPAN | 438 | #endif // _LIBCPP_MDSPAN |
lib/libcxx/include/memory+44-19| ... | @@ -88,6 +88,9 @@ struct allocator_traits | ... | @@ -88,6 +88,9 @@ struct allocator_traits |
| 88 | static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20 | 88 | static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20 |
| 89 | static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20 | 89 | static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20 |
| 90 | 90 | ||
| 91 | [[nodiscard]] static constexpr allocation_result<pointer, size_type> | ||
| 92 | allocate_at_least(Alloc& a, size_type n); // Since C++23 | ||
| 93 | |||
| 91 | static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20 | 94 | static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20 |
| 92 | 95 | ||
| 93 | template <class T, class... Args> | 96 | template <class T, class... Args> |
| ... | @@ -100,15 +103,11 @@ struct allocator_traits | ... | @@ -100,15 +103,11 @@ struct allocator_traits |
| 100 | static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20 | 103 | static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20 |
| 101 | }; | 104 | }; |
| 102 | 105 | ||
| 103 | template<class Pointer> | 106 | template<class Pointer, class SizeType = size_t> |
| 104 | struct allocation_result { | 107 | struct allocation_result { |
| 105 | Pointer ptr; | 108 | Pointer ptr; |
| 106 | size_t count; | 109 | SizeType count; |
| 107 | }; // since C++23 | 110 | }; // Since C++23 |
| 108 | |||
| 109 | template<class Allocator> | ||
| 110 | [[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer> | ||
| 111 | allocate_at_least(Allocator& a, size_t n); // since C++23 | ||
| 112 | 111 | ||
| 113 | template <> | 112 | template <> |
| 114 | class allocator<void> // removed in C++20 | 113 | class allocator<void> // removed in C++20 |
| ... | @@ -452,7 +451,8 @@ public: | ... | @@ -452,7 +451,8 @@ public: |
| 452 | constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23 | 451 | constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23 |
| 453 | 452 | ||
| 454 | // observers | 453 | // observers |
| 455 | typename constexpr add_lvalue_reference<T>::type operator*() const; // constexpr since C++23 | 454 | constexpr |
| 455 | add_lvalue_reference<T>::type operator*() const noexcept(see below); // constexpr since C++23 | ||
| 456 | constexpr pointer operator->() const noexcept; // constexpr since C++23 | 456 | constexpr pointer operator->() const noexcept; // constexpr since C++23 |
| 457 | constexpr pointer get() const noexcept; // constexpr since C++23 | 457 | constexpr pointer get() const noexcept; // constexpr since C++23 |
| 458 | constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23 | 458 | constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23 |
| ... | @@ -912,40 +912,65 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); | ... | @@ -912,40 +912,65 @@ 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 | // [out.ptr.t], class template out_ptr_t | ||
| 916 | template<class Smart, class Pointer, class... Args> | ||
| 917 | class out_ptr_t; // since c++23 | ||
| 918 | |||
| 919 | // [out.ptr], function template out_ptr | ||
| 920 | template<class Pointer = void, class Smart, class... Args> | ||
| 921 | auto out_ptr(Smart& s, Args&&... args); // since c++23 | ||
| 922 | |||
| 923 | // [inout.ptr.t], class template inout_ptr_t | ||
| 924 | template<class Smart, class Pointer, class... Args> | ||
| 925 | class inout_ptr_t; // since c++23 | ||
| 926 | |||
| 927 | // [inout.ptr], function template inout_ptr | ||
| 928 | template<class Pointer = void, class Smart, class... Args> | ||
| 929 | auto inout_ptr(Smart& s, Args&&... args); // since c++23 | ||
| 930 | |||
| 915 | } // std | 931 | } // std |
| 916 | 932 | ||
| 917 | */ | 933 | */ |
| 918 | 934 | ||
| 919 | // clang-format on | 935 | // clang-format on |
| 920 | 936 | ||
| 921 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 922 | #include <__config> | 937 | #include <__config> |
| 923 | #include <__memory/addressof.h> | 938 | #include <__memory/addressof.h> |
| 924 | #include <__memory/align.h> | 939 | #include <__memory/align.h> |
| 925 | #include <__memory/allocate_at_least.h> | ||
| 926 | #include <__memory/allocation_guard.h> | ||
| 927 | #include <__memory/allocator.h> | 940 | #include <__memory/allocator.h> |
| 928 | #include <__memory/allocator_arg_t.h> | 941 | #include <__memory/allocator_arg_t.h> |
| 929 | #include <__memory/allocator_traits.h> | 942 | #include <__memory/allocator_traits.h> |
| 930 | #include <__memory/assume_aligned.h> | ||
| 931 | #include <__memory/auto_ptr.h> | 943 | #include <__memory/auto_ptr.h> |
| 932 | #include <__memory/compressed_pair.h> | 944 | #include <__memory/inout_ptr.h> |
| 933 | #include <__memory/concepts.h> | 945 | #include <__memory/out_ptr.h> |
| 934 | #include <__memory/construct_at.h> | ||
| 935 | #include <__memory/pointer_traits.h> | 946 | #include <__memory/pointer_traits.h> |
| 936 | #include <__memory/ranges_construct_at.h> | ||
| 937 | #include <__memory/ranges_uninitialized_algorithms.h> | ||
| 938 | #include <__memory/raw_storage_iterator.h> | 947 | #include <__memory/raw_storage_iterator.h> |
| 939 | #include <__memory/shared_ptr.h> | 948 | #include <__memory/shared_ptr.h> |
| 940 | #include <__memory/temporary_buffer.h> | 949 | #include <__memory/temporary_buffer.h> |
| 941 | #include <__memory/uninitialized_algorithms.h> | 950 | #include <__memory/uninitialized_algorithms.h> |
| 942 | #include <__memory/unique_ptr.h> | 951 | #include <__memory/unique_ptr.h> |
| 943 | #include <__memory/uses_allocator.h> | 952 | #include <__memory/uses_allocator.h> |
| 944 | #include <__memory/uses_allocator_construction.h> | ||
| 945 | #include <version> | ||
| 946 | 953 | ||
| 947 | // standard-mandated includes | 954 | // standard-mandated includes |
| 948 | 955 | ||
| 956 | #if _LIBCPP_STD_VER >= 17 | ||
| 957 | # include <__memory/construct_at.h> | ||
| 958 | #endif | ||
| 959 | |||
| 960 | #if _LIBCPP_STD_VER >= 20 | ||
| 961 | # include <__memory/assume_aligned.h> | ||
| 962 | # include <__memory/concepts.h> | ||
| 963 | # include <__memory/ranges_construct_at.h> | ||
| 964 | # include <__memory/ranges_uninitialized_algorithms.h> | ||
| 965 | # include <__memory/uses_allocator_construction.h> | ||
| 966 | #endif | ||
| 967 | |||
| 968 | #if _LIBCPP_STD_VER >= 23 | ||
| 969 | # include <__memory/allocate_at_least.h> | ||
| 970 | #endif | ||
| 971 | |||
| 972 | #include <version> | ||
| 973 | |||
| 949 | // [memory.syn] | 974 | // [memory.syn] |
| 950 | #include <compare> | 975 | #include <compare> |
| 951 | 976 |
lib/libcxx/include/memory_resource+20-6| ... | @@ -50,18 +50,32 @@ namespace std::pmr { | ... | @@ -50,18 +50,32 @@ namespace std::pmr { |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | #include <__config> | 52 | #include <__config> |
| 53 | #include <__memory_resource/memory_resource.h> | 53 | |
| 54 | #include <__memory_resource/monotonic_buffer_resource.h> | 54 | #if _LIBCPP_STD_VER >= 17 |
| 55 | #include <__memory_resource/polymorphic_allocator.h> | 55 | # include <__memory_resource/memory_resource.h> |
| 56 | #include <__memory_resource/pool_options.h> | 56 | # include <__memory_resource/monotonic_buffer_resource.h> |
| 57 | #include <__memory_resource/synchronized_pool_resource.h> | 57 | # include <__memory_resource/polymorphic_allocator.h> |
| 58 | #include <__memory_resource/unsynchronized_pool_resource.h> | 58 | # include <__memory_resource/pool_options.h> |
| 59 | # include <__memory_resource/synchronized_pool_resource.h> | ||
| 60 | # include <__memory_resource/unsynchronized_pool_resource.h> | ||
| 61 | #endif | ||
| 62 | |||
| 59 | #include <version> | 63 | #include <version> |
| 60 | 64 | ||
| 61 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 65 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 62 | # pragma GCC system_header | 66 | # pragma GCC system_header |
| 63 | #endif | 67 | #endif |
| 64 | 68 | ||
| 69 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | ||
| 70 | # include <cstddef> | ||
| 71 | # include <cstdint> | ||
| 72 | # include <limits> | ||
| 73 | # include <mutex> | ||
| 74 | # include <new> | ||
| 75 | # include <stdexcept> | ||
| 76 | # include <tuple> | ||
| 77 | #endif | ||
| 78 | |||
| 65 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 79 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 66 | # include <stdexcept> | 80 | # include <stdexcept> |
| 67 | #endif | 81 | #endif |
lib/libcxx/include/mutex+12-27| ... | @@ -186,7 +186,6 @@ template<class Callable, class ...Args> | ... | @@ -186,7 +186,6 @@ template<class Callable, class ...Args> |
| 186 | 186 | ||
| 187 | */ | 187 | */ |
| 188 | 188 | ||
| 189 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 190 | #include <__chrono/steady_clock.h> | 189 | #include <__chrono/steady_clock.h> |
| 191 | #include <__chrono/time_point.h> | 190 | #include <__chrono/time_point.h> |
| 192 | #include <__condition_variable/condition_variable.h> | 191 | #include <__condition_variable/condition_variable.h> |
| ... | @@ -198,7 +197,7 @@ template<class Callable, class ...Args> | ... | @@ -198,7 +197,7 @@ template<class Callable, class ...Args> |
| 198 | #include <__mutex/tag_types.h> | 197 | #include <__mutex/tag_types.h> |
| 199 | #include <__mutex/unique_lock.h> | 198 | #include <__mutex/unique_lock.h> |
| 200 | #include <__thread/id.h> | 199 | #include <__thread/id.h> |
| 201 | #include <__threading_support> | 200 | #include <__thread/support.h> |
| 202 | #include <__utility/forward.h> | 201 | #include <__utility/forward.h> |
| 203 | #include <cstddef> | 202 | #include <cstddef> |
| 204 | #include <limits> | 203 | #include <limits> |
| ... | @@ -419,24 +418,6 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... | ... | @@ -419,24 +418,6 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... |
| 419 | std::__lock_first(0, __l0, __l1, __l2, __l3...); | 418 | std::__lock_first(0, __l0, __l1, __l2, __l3...); |
| 420 | } | 419 | } |
| 421 | 420 | ||
| 422 | template <class _L0> | ||
| 423 | inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0) { | ||
| 424 | __l0.unlock(); | ||
| 425 | } | ||
| 426 | |||
| 427 | template <class _L0, class _L1> | ||
| 428 | inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0, _L1& __l1) { | ||
| 429 | __l0.unlock(); | ||
| 430 | __l1.unlock(); | ||
| 431 | } | ||
| 432 | |||
| 433 | template <class _L0, class _L1, class _L2, class... _L3> | ||
| 434 | inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { | ||
| 435 | __l0.unlock(); | ||
| 436 | __l1.unlock(); | ||
| 437 | std::__unlock(__l2, __l3...); | ||
| 438 | } | ||
| 439 | |||
| 440 | # endif // _LIBCPP_CXX03_LANG | 421 | # endif // _LIBCPP_CXX03_LANG |
| 441 | 422 | ||
| 442 | # if _LIBCPP_STD_VER >= 17 | 423 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -446,10 +427,10 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock; | ... | @@ -446,10 +427,10 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock; |
| 446 | template <> | 427 | template <> |
| 447 | class _LIBCPP_TEMPLATE_VIS scoped_lock<> { | 428 | class _LIBCPP_TEMPLATE_VIS scoped_lock<> { |
| 448 | public: | 429 | public: |
| 449 | explicit scoped_lock() {} | 430 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {} |
| 450 | ~scoped_lock() = default; | 431 | ~scoped_lock() = default; |
| 451 | 432 | ||
| 452 | _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t) {} | 433 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t) {} |
| 453 | 434 | ||
| 454 | scoped_lock(scoped_lock const&) = delete; | 435 | scoped_lock(scoped_lock const&) = delete; |
| 455 | scoped_lock& operator=(scoped_lock const&) = delete; | 436 | scoped_lock& operator=(scoped_lock const&) = delete; |
| ... | @@ -464,13 +445,15 @@ private: | ... | @@ -464,13 +445,15 @@ private: |
| 464 | mutex_type& __m_; | 445 | mutex_type& __m_; |
| 465 | 446 | ||
| 466 | public: | 447 | public: |
| 467 | explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) : __m_(__m) { | 448 | [[nodiscard]] |
| 449 | _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) | ||
| 450 | : __m_(__m) { | ||
| 468 | __m_.lock(); | 451 | __m_.lock(); |
| 469 | } | 452 | } |
| 470 | 453 | ||
| 471 | ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } | 454 | ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } |
| 472 | 455 | ||
| 473 | _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m) | 456 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m) |
| 474 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) | 457 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) |
| 475 | : __m_(__m) {} | 458 | : __m_(__m) {} |
| 476 | 459 | ||
| ... | @@ -484,9 +467,11 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock { | ... | @@ -484,9 +467,11 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock { |
| 484 | typedef tuple<_MArgs&...> _MutexTuple; | 467 | typedef tuple<_MArgs&...> _MutexTuple; |
| 485 | 468 | ||
| 486 | public: | 469 | public: |
| 487 | _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) : __t_(__margs...) { std::lock(__margs...); } | 470 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) : __t_(__margs...) { |
| 471 | std::lock(__margs...); | ||
| 472 | } | ||
| 488 | 473 | ||
| 489 | _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {} | 474 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {} |
| 490 | 475 | ||
| 491 | _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { | 476 | _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { |
| 492 | typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices; | 477 | typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices; |
| ... | @@ -499,7 +484,7 @@ public: | ... | @@ -499,7 +484,7 @@ public: |
| 499 | private: | 484 | private: |
| 500 | template <size_t... _Indx> | 485 | template <size_t... _Indx> |
| 501 | _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) { | 486 | _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) { |
| 502 | std::__unlock(std::get<_Indx>(__mt)...); | 487 | (std::get<_Indx>(__mt).unlock(), ...); |
| 503 | } | 488 | } |
| 504 | 489 | ||
| 505 | _MutexTuple __t_; | 490 | _MutexTuple __t_; |
lib/libcxx/include/new+15-21| ... | @@ -86,13 +86,12 @@ void operator delete[](void* ptr, void*) noexcept; | ... | @@ -86,13 +86,12 @@ void operator delete[](void* ptr, void*) noexcept; |
| 86 | 86 | ||
| 87 | */ | 87 | */ |
| 88 | 88 | ||
| 89 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 90 | #include <__availability> | ||
| 91 | #include <__config> | 89 | #include <__config> |
| 92 | #include <__exception/exception.h> | 90 | #include <__exception/exception.h> |
| 93 | #include <__type_traits/is_function.h> | 91 | #include <__type_traits/is_function.h> |
| 94 | #include <__type_traits/is_same.h> | 92 | #include <__type_traits/is_same.h> |
| 95 | #include <__type_traits/remove_cv.h> | 93 | #include <__type_traits/remove_cv.h> |
| 94 | #include <__verbose_abort> | ||
| 96 | #include <cstddef> | 95 | #include <cstddef> |
| 97 | #include <version> | 96 | #include <version> |
| 98 | 97 | ||
| ... | @@ -204,18 +203,18 @@ inline constexpr destroying_delete_t destroying_delete{}; | ... | @@ -204,18 +203,18 @@ inline constexpr destroying_delete_t destroying_delete{}; |
| 204 | 203 | ||
| 205 | #if !defined(_LIBCPP_ABI_VCRUNTIME) | 204 | #if !defined(_LIBCPP_ABI_VCRUNTIME) |
| 206 | 205 | ||
| 207 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; | 206 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; |
| 208 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* | 207 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT |
| 209 | operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | 208 | _LIBCPP_NOALIAS; |
| 210 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; | 209 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; |
| 211 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; | 210 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; |
| 212 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | 211 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION |
| 213 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; | 212 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; |
| 214 | # endif | 213 | # endif |
| 215 | 214 | ||
| 216 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; | 215 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; |
| 217 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* | 216 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT |
| 218 | operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | 217 | _LIBCPP_NOALIAS; |
| 219 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; | 218 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; |
| 220 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; | 219 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; |
| 221 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | 220 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION |
| ... | @@ -223,9 +222,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) | ... | @@ -223,9 +222,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) |
| 223 | # endif | 222 | # endif |
| 224 | 223 | ||
| 225 | # ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | 224 | # ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
| 226 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* | 225 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; |
| 227 | operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | 226 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* |
| 228 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* | ||
| 229 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | 227 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; |
| 230 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; | 228 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; |
| 231 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | 229 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; |
| ... | @@ -233,9 +231,9 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, c | ... | @@ -233,9 +231,9 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, c |
| 233 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | 231 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; |
| 234 | # endif | 232 | # endif |
| 235 | 233 | ||
| 236 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* | 234 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* |
| 237 | operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | 235 | operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; |
| 238 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* | 236 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* |
| 239 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | 237 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; |
| 240 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; | 238 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; |
| 241 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | 239 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; |
| ... | @@ -244,12 +242,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, | ... | @@ -244,12 +242,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, |
| 244 | # endif | 242 | # endif |
| 245 | # endif | 243 | # endif |
| 246 | 244 | ||
| 247 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { | 245 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { return __p; } |
| 248 | return __p; | 246 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT { return __p; } |
| 249 | } | ||
| 250 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT { | ||
| 251 | return __p; | ||
| 252 | } | ||
| 253 | inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {} | 247 | inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {} |
| 254 | inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {} | 248 | inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {} |
| 255 | 249 | ||
| ... | @@ -334,7 +328,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_ | ... | @@ -334,7 +328,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_ |
| 334 | } | 328 | } |
| 335 | 329 | ||
| 336 | template <class _Tp> | 330 | template <class _Tp> |
| 337 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { | 331 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { |
| 338 | static_assert(!(is_function<_Tp>::value), "can't launder functions"); | 332 | static_assert(!(is_function<_Tp>::value), "can't launder functions"); |
| 339 | static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void"); | 333 | static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void"); |
| 340 | return __builtin_launder(__p); | 334 | return __builtin_launder(__p); |
| ... | @@ -342,7 +336,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp | ... | @@ -342,7 +336,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp |
| 342 | 336 | ||
| 343 | #if _LIBCPP_STD_VER >= 17 | 337 | #if _LIBCPP_STD_VER >= 17 |
| 344 | template <class _Tp> | 338 | template <class _Tp> |
| 345 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { | 339 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { |
| 346 | return std::__launder(__p); | 340 | return std::__launder(__p); |
| 347 | } | 341 | } |
| 348 | #endif | 342 | #endif |
lib/libcxx/include/numbers-1| ... | @@ -58,7 +58,6 @@ namespace std::numbers { | ... | @@ -58,7 +58,6 @@ namespace std::numbers { |
| 58 | } | 58 | } |
| 59 | */ | 59 | */ |
| 60 | 60 | ||
| 61 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 62 | #include <__concepts/arithmetic.h> | 61 | #include <__concepts/arithmetic.h> |
| 63 | #include <__config> | 62 | #include <__config> |
| 64 | #include <version> | 63 | #include <version> |
lib/libcxx/include/numeric+28-13| ... | @@ -156,36 +156,51 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin | ... | @@ -156,36 +156,51 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin |
| 156 | 156 | ||
| 157 | */ | 157 | */ |
| 158 | 158 | ||
| 159 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 160 | #include <__config> | 159 | #include <__config> |
| 161 | #include <version> | ||
| 162 | 160 | ||
| 163 | #include <__numeric/accumulate.h> | 161 | #include <__numeric/accumulate.h> |
| 164 | #include <__numeric/adjacent_difference.h> | 162 | #include <__numeric/adjacent_difference.h> |
| 165 | #include <__numeric/exclusive_scan.h> | ||
| 166 | #include <__numeric/gcd_lcm.h> | ||
| 167 | #include <__numeric/inclusive_scan.h> | ||
| 168 | #include <__numeric/inner_product.h> | 163 | #include <__numeric/inner_product.h> |
| 169 | #include <__numeric/iota.h> | 164 | #include <__numeric/iota.h> |
| 170 | #include <__numeric/midpoint.h> | ||
| 171 | #include <__numeric/partial_sum.h> | 165 | #include <__numeric/partial_sum.h> |
| 172 | #include <__numeric/pstl_reduce.h> | 166 | |
| 173 | #include <__numeric/pstl_transform_reduce.h> | 167 | #if _LIBCPP_STD_VER >= 17 |
| 174 | #include <__numeric/reduce.h> | 168 | # include <__numeric/exclusive_scan.h> |
| 175 | #include <__numeric/saturation_arithmetic.h> | 169 | # include <__numeric/gcd_lcm.h> |
| 176 | #include <__numeric/transform_exclusive_scan.h> | 170 | # include <__numeric/inclusive_scan.h> |
| 177 | #include <__numeric/transform_inclusive_scan.h> | 171 | # include <__numeric/pstl.h> |
| 178 | #include <__numeric/transform_reduce.h> | 172 | # include <__numeric/reduce.h> |
| 173 | # include <__numeric/transform_exclusive_scan.h> | ||
| 174 | # include <__numeric/transform_inclusive_scan.h> | ||
| 175 | # include <__numeric/transform_reduce.h> | ||
| 176 | #endif | ||
| 177 | |||
| 178 | #if _LIBCPP_STD_VER >= 20 | ||
| 179 | # include <__numeric/midpoint.h> | ||
| 180 | # include <__numeric/saturation_arithmetic.h> | ||
| 181 | #endif | ||
| 182 | |||
| 183 | #include <version> | ||
| 179 | 184 | ||
| 180 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 185 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 181 | # pragma GCC system_header | 186 | # pragma GCC system_header |
| 182 | #endif | 187 | #endif |
| 183 | 188 | ||
| 189 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | ||
| 190 | # include <initializer_list> | ||
| 191 | # include <limits> | ||
| 192 | #endif | ||
| 193 | |||
| 184 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 194 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 195 | # include <climits> | ||
| 185 | # include <cmath> | 196 | # include <cmath> |
| 186 | # include <concepts> | 197 | # include <concepts> |
| 198 | # include <cstdint> | ||
| 199 | # include <execution> | ||
| 187 | # include <functional> | 200 | # include <functional> |
| 188 | # include <iterator> | 201 | # include <iterator> |
| 202 | # include <new> | ||
| 203 | # include <optional> | ||
| 189 | # include <type_traits> | 204 | # include <type_traits> |
| 190 | #endif | 205 | #endif |
| 191 | 206 |
lib/libcxx/include/optional+30-30| ... | @@ -136,12 +136,12 @@ namespace std { | ... | @@ -136,12 +136,12 @@ namespace std { |
| 136 | void swap(optional &) noexcept(see below ); // constexpr in C++20 | 136 | void swap(optional &) noexcept(see below ); // constexpr in C++20 |
| 137 | 137 | ||
| 138 | // [optional.observe], observers | 138 | // [optional.observe], observers |
| 139 | constexpr T const *operator->() const; | 139 | constexpr T const *operator->() const noexcept; |
| 140 | constexpr T *operator->(); | 140 | constexpr T *operator->() noexcept; |
| 141 | constexpr T const &operator*() const &; | 141 | constexpr T const &operator*() const & noexcept; |
| 142 | constexpr T &operator*() &; | 142 | constexpr T &operator*() & noexcept; |
| 143 | constexpr T &&operator*() &&; | 143 | constexpr T &&operator*() && noexcept; |
| 144 | constexpr const T &&operator*() const &&; | 144 | constexpr const T &&operator*() const && noexcept; |
| 145 | constexpr explicit operator bool() const noexcept; | 145 | constexpr explicit operator bool() const noexcept; |
| 146 | constexpr bool has_value() const noexcept; | 146 | constexpr bool has_value() const noexcept; |
| 147 | constexpr T const &value() const &; | 147 | constexpr T const &value() const &; |
| ... | @@ -177,8 +177,7 @@ namespace std { | ... | @@ -177,8 +177,7 @@ namespace std { |
| 177 | 177 | ||
| 178 | */ | 178 | */ |
| 179 | 179 | ||
| 180 | #include <__assert> // all public C++ headers provide the assertion handler | 180 | #include <__assert> |
| 181 | #include <__availability> | ||
| 182 | #include <__compare/compare_three_way_result.h> | 181 | #include <__compare/compare_three_way_result.h> |
| 183 | #include <__compare/three_way_comparable.h> | 182 | #include <__compare/three_way_comparable.h> |
| 184 | #include <__concepts/invocable.h> | 183 | #include <__concepts/invocable.h> |
| ... | @@ -186,8 +185,8 @@ namespace std { | ... | @@ -186,8 +185,8 @@ namespace std { |
| 186 | #include <__exception/exception.h> | 185 | #include <__exception/exception.h> |
| 187 | #include <__functional/hash.h> | 186 | #include <__functional/hash.h> |
| 188 | #include <__functional/invoke.h> | 187 | #include <__functional/invoke.h> |
| 189 | #include <__functional/reference_wrapper.h> | ||
| 190 | #include <__functional/unary_function.h> | 188 | #include <__functional/unary_function.h> |
| 189 | #include <__fwd/functional.h> | ||
| 191 | #include <__memory/addressof.h> | 190 | #include <__memory/addressof.h> |
| 192 | #include <__memory/construct_at.h> | 191 | #include <__memory/construct_at.h> |
| 193 | #include <__tuple/sfinae_helpers.h> | 192 | #include <__tuple/sfinae_helpers.h> |
| ... | @@ -200,22 +199,17 @@ namespace std { | ... | @@ -200,22 +199,17 @@ namespace std { |
| 200 | #include <__type_traits/is_assignable.h> | 199 | #include <__type_traits/is_assignable.h> |
| 201 | #include <__type_traits/is_constructible.h> | 200 | #include <__type_traits/is_constructible.h> |
| 202 | #include <__type_traits/is_convertible.h> | 201 | #include <__type_traits/is_convertible.h> |
| 203 | #include <__type_traits/is_copy_assignable.h> | ||
| 204 | #include <__type_traits/is_copy_constructible.h> | ||
| 205 | #include <__type_traits/is_destructible.h> | 202 | #include <__type_traits/is_destructible.h> |
| 206 | #include <__type_traits/is_move_assignable.h> | 203 | #include <__type_traits/is_nothrow_assignable.h> |
| 207 | #include <__type_traits/is_move_constructible.h> | 204 | #include <__type_traits/is_nothrow_constructible.h> |
| 208 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 209 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 210 | #include <__type_traits/is_object.h> | 205 | #include <__type_traits/is_object.h> |
| 211 | #include <__type_traits/is_reference.h> | 206 | #include <__type_traits/is_reference.h> |
| 212 | #include <__type_traits/is_scalar.h> | 207 | #include <__type_traits/is_scalar.h> |
| 213 | #include <__type_traits/is_swappable.h> | 208 | #include <__type_traits/is_swappable.h> |
| 214 | #include <__type_traits/is_trivially_copy_assignable.h> | 209 | #include <__type_traits/is_trivially_assignable.h> |
| 215 | #include <__type_traits/is_trivially_copy_constructible.h> | 210 | #include <__type_traits/is_trivially_constructible.h> |
| 216 | #include <__type_traits/is_trivially_destructible.h> | 211 | #include <__type_traits/is_trivially_destructible.h> |
| 217 | #include <__type_traits/is_trivially_move_assignable.h> | 212 | #include <__type_traits/is_trivially_relocatable.h> |
| 218 | #include <__type_traits/is_trivially_move_constructible.h> | ||
| 219 | #include <__type_traits/negation.h> | 213 | #include <__type_traits/negation.h> |
| 220 | #include <__type_traits/remove_const.h> | 214 | #include <__type_traits/remove_const.h> |
| 221 | #include <__type_traits/remove_cvref.h> | 215 | #include <__type_traits/remove_cvref.h> |
| ... | @@ -307,7 +301,7 @@ struct __optional_destruct_base<_Tp, false> { | ... | @@ -307,7 +301,7 @@ struct __optional_destruct_base<_Tp, false> { |
| 307 | 301 | ||
| 308 | # if _LIBCPP_STD_VER >= 23 | 302 | # if _LIBCPP_STD_VER >= 23 |
| 309 | template <class _Fp, class... _Args> | 303 | template <class _Fp, class... _Args> |
| 310 | _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base( | 304 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base( |
| 311 | __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) | 305 | __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) |
| 312 | : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} | 306 | : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} |
| 313 | # endif | 307 | # endif |
| ... | @@ -587,6 +581,8 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES optional | ... | @@ -587,6 +581,8 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES optional |
| 587 | public: | 581 | public: |
| 588 | using value_type = _Tp; | 582 | using value_type = _Tp; |
| 589 | 583 | ||
| 584 | using __trivially_relocatable = conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; | ||
| 585 | |||
| 590 | private: | 586 | private: |
| 591 | // Disable the reference extension using this static assert. | 587 | // Disable the reference extension using this static assert. |
| 592 | static_assert(!is_same_v<__remove_cvref_t<value_type>, in_place_t>, | 588 | static_assert(!is_same_v<__remove_cvref_t<value_type>, in_place_t>, |
| ... | @@ -711,8 +707,11 @@ public: | ... | @@ -711,8 +707,11 @@ public: |
| 711 | } | 707 | } |
| 712 | 708 | ||
| 713 | # if _LIBCPP_STD_VER >= 23 | 709 | # if _LIBCPP_STD_VER >= 23 |
| 714 | template <class _Fp, class... _Args> | 710 | template <class _Tag, |
| 715 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) | 711 | class _Fp, |
| 712 | class... _Args, | ||
| 713 | __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0> | ||
| 714 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args) | ||
| 716 | : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} | 715 | : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} |
| 717 | # endif | 716 | # endif |
| 718 | 717 | ||
| ... | @@ -728,9 +727,9 @@ public: | ... | @@ -728,9 +727,9 @@ public: |
| 728 | template < | 727 | template < |
| 729 | class _Up = value_type, | 728 | class _Up = value_type, |
| 730 | class = enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Up>, optional>, | 729 | class = enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Up>, optional>, |
| 731 | _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >, | 730 | _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >, |
| 732 | is_constructible<value_type, _Up>, | 731 | is_constructible<value_type, _Up>, |
| 733 | is_assignable<value_type&, _Up> >::value> > | 732 | is_assignable<value_type&, _Up> >::value> > |
| 734 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) { | 733 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) { |
| 735 | if (this->has_value()) | 734 | if (this->has_value()) |
| 736 | this->__get() = std::forward<_Up>(__v); | 735 | this->__get() = std::forward<_Up>(__v); |
| ... | @@ -787,12 +786,12 @@ public: | ... | @@ -787,12 +786,12 @@ public: |
| 787 | } | 786 | } |
| 788 | } | 787 | } |
| 789 | 788 | ||
| 790 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const { | 789 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const noexcept { |
| 791 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); | 790 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); |
| 792 | return std::addressof(this->__get()); | 791 | return std::addressof(this->__get()); |
| 793 | } | 792 | } |
| 794 | 793 | ||
| 795 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() { | 794 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() noexcept { |
| 796 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); | 795 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); |
| 797 | return std::addressof(this->__get()); | 796 | return std::addressof(this->__get()); |
| 798 | } | 797 | } |
| ... | @@ -1246,9 +1245,9 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { | ... | @@ -1246,9 +1245,9 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { |
| 1246 | # endif // _LIBCPP_STD_VER >= 20 | 1245 | # endif // _LIBCPP_STD_VER >= 20 |
| 1247 | 1246 | ||
| 1248 | template <class _Tp> | 1247 | template <class _Tp> |
| 1249 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1248 | inline _LIBCPP_HIDE_FROM_ABI |
| 1250 | enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void > | 1249 | _LIBCPP_CONSTEXPR_SINCE_CXX20 enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void > |
| 1251 | swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { | 1250 | swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { |
| 1252 | __x.swap(__y); | 1251 | __x.swap(__y); |
| 1253 | } | 1252 | } |
| 1254 | 1253 | ||
| ... | @@ -1291,6 +1290,7 @@ _LIBCPP_POP_MACROS | ... | @@ -1291,6 +1290,7 @@ _LIBCPP_POP_MACROS |
| 1291 | # include <concepts> | 1290 | # include <concepts> |
| 1292 | # include <ctime> | 1291 | # include <ctime> |
| 1293 | # include <iterator> | 1292 | # include <iterator> |
| 1293 | # include <limits> | ||
| 1294 | # include <memory> | 1294 | # include <memory> |
| 1295 | # include <ratio> | 1295 | # include <ratio> |
| 1296 | # include <stdexcept> | 1296 | # include <stdexcept> |
lib/libcxx/include/ostream+9-994| ... | @@ -164,6 +164,7 @@ template<class... Args> | ... | @@ -164,6 +164,7 @@ template<class... Args> |
| 164 | void print(ostream& os, format_string<Args...> fmt, Args&&... args); | 164 | void print(ostream& os, format_string<Args...> fmt, Args&&... args); |
| 165 | template<class... Args> // since C++23 | 165 | template<class... Args> // since C++23 |
| 166 | void println(ostream& os, format_string<Args...> fmt, Args&&... args); | 166 | void println(ostream& os, format_string<Args...> fmt, Args&&... args); |
| 167 | void println(ostream& os); // since C++26 | ||
| 167 | 168 | ||
| 168 | void vprint_unicode(ostream& os, string_view fmt, format_args args); // since C++23 | 169 | void vprint_unicode(ostream& os, string_view fmt, format_args args); // since C++23 |
| 169 | void vprint_nonunicode(ostream& os, string_view fmt, format_args args); // since C++23 | 170 | void vprint_nonunicode(ostream& os, string_view fmt, format_args args); // since C++23 |
| ... | @@ -171,1015 +172,29 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); | ... | @@ -171,1015 +172,29 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); |
| 171 | 172 | ||
| 172 | */ | 173 | */ |
| 173 | 174 | ||
| 174 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 175 | #include <__availability> | ||
| 176 | #include <__config> | 175 | #include <__config> |
| 177 | #include <__exception/operations.h> | ||
| 178 | #include <__fwd/ostream.h> | ||
| 179 | #include <__memory/shared_ptr.h> | ||
| 180 | #include <__memory/unique_ptr.h> | ||
| 181 | #include <__system_error/error_code.h> | ||
| 182 | #include <__type_traits/conjunction.h> | ||
| 183 | #include <__type_traits/enable_if.h> | ||
| 184 | #include <__type_traits/is_base_of.h> | ||
| 185 | #include <__type_traits/void_t.h> | ||
| 186 | #include <__utility/declval.h> | ||
| 187 | #include <bitset> | ||
| 188 | #include <cstdio> | ||
| 189 | #include <format> | ||
| 190 | #include <ios> | ||
| 191 | #include <locale> | ||
| 192 | #include <new> | ||
| 193 | #include <print> | ||
| 194 | #include <streambuf> | ||
| 195 | #include <string_view> | ||
| 196 | #include <version> | ||
| 197 | |||
| 198 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 199 | # pragma GCC system_header | ||
| 200 | #endif | ||
| 201 | |||
| 202 | _LIBCPP_PUSH_MACROS | ||
| 203 | #include <__undef_macros> | ||
| 204 | |||
| 205 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 206 | |||
| 207 | template <class _CharT, class _Traits> | ||
| 208 | class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> { | ||
| 209 | public: | ||
| 210 | // types (inherited from basic_ios (27.5.4)): | ||
| 211 | typedef _CharT char_type; | ||
| 212 | typedef _Traits traits_type; | ||
| 213 | typedef typename traits_type::int_type int_type; | ||
| 214 | typedef typename traits_type::pos_type pos_type; | ||
| 215 | typedef typename traits_type::off_type off_type; | ||
| 216 | |||
| 217 | // 27.7.2.2 Constructor/destructor: | ||
| 218 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) { | ||
| 219 | this->init(__sb); | ||
| 220 | } | ||
| 221 | ~basic_ostream() override; | ||
| 222 | |||
| 223 | protected: | ||
| 224 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs); | ||
| 225 | |||
| 226 | // 27.7.2.3 Assign/swap | ||
| 227 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs); | ||
| 228 | |||
| 229 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_ostream& __rhs) { | ||
| 230 | basic_ios<char_type, traits_type>::swap(__rhs); | ||
| 231 | } | ||
| 232 | |||
| 233 | basic_ostream(const basic_ostream& __rhs) = delete; | ||
| 234 | basic_ostream& operator=(const basic_ostream& __rhs) = delete; | ||
| 235 | 176 | ||
| 236 | public: | 177 | #include <__ostream/basic_ostream.h> |
| 237 | // 27.7.2.4 Prefix/suffix: | ||
| 238 | class _LIBCPP_TEMPLATE_VIS sentry; | ||
| 239 | |||
| 240 | // 27.7.2.6 Formatted output: | ||
| 241 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) { | ||
| 242 | return __pf(*this); | ||
| 243 | } | ||
| 244 | |||
| 245 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& | ||
| 246 | operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) { | ||
| 247 | __pf(*this); | ||
| 248 | return *this; | ||
| 249 | } | ||
| 250 | |||
| 251 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) { | ||
| 252 | __pf(*this); | ||
| 253 | return *this; | ||
| 254 | } | ||
| 255 | |||
| 256 | basic_ostream& operator<<(bool __n); | ||
| 257 | basic_ostream& operator<<(short __n); | ||
| 258 | basic_ostream& operator<<(unsigned short __n); | ||
| 259 | basic_ostream& operator<<(int __n); | ||
| 260 | basic_ostream& operator<<(unsigned int __n); | ||
| 261 | basic_ostream& operator<<(long __n); | ||
| 262 | basic_ostream& operator<<(unsigned long __n); | ||
| 263 | basic_ostream& operator<<(long long __n); | ||
| 264 | basic_ostream& operator<<(unsigned long long __n); | ||
| 265 | basic_ostream& operator<<(float __f); | ||
| 266 | basic_ostream& operator<<(double __f); | ||
| 267 | basic_ostream& operator<<(long double __f); | ||
| 268 | basic_ostream& operator<<(const void* __p); | ||
| 269 | 178 | ||
| 270 | #if _LIBCPP_STD_VER >= 23 | 179 | #if _LIBCPP_STD_VER >= 23 |
| 271 | _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) { | 180 | # include <__ostream/print.h> |
| 272 | return operator<<(const_cast<const void*>(__p)); | ||
| 273 | } | ||
| 274 | #endif | ||
| 275 | |||
| 276 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); | ||
| 277 | |||
| 278 | #if _LIBCPP_STD_VER >= 17 | ||
| 279 | // LWG 2221 - nullptr. This is not backported to older standards modes. | ||
| 280 | // See https://reviews.llvm.org/D127033 for more info on the rationale. | ||
| 281 | _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; } | ||
| 282 | #endif | 181 | #endif |
| 283 | 182 | ||
| 284 | // 27.7.2.7 Unformatted output: | 183 | #include <version> |
| 285 | basic_ostream& put(char_type __c); | ||
| 286 | basic_ostream& write(const char_type* __s, streamsize __n); | ||
| 287 | basic_ostream& flush(); | ||
| 288 | |||
| 289 | // 27.7.2.5 seeks: | ||
| 290 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type tellp(); | ||
| 291 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(pos_type __pos); | ||
| 292 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir); | ||
| 293 | |||
| 294 | protected: | ||
| 295 | _LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize | ||
| 296 | }; | ||
| 297 | |||
| 298 | template <class _CharT, class _Traits> | ||
| 299 | class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry { | ||
| 300 | bool __ok_; | ||
| 301 | basic_ostream<_CharT, _Traits>& __os_; | ||
| 302 | |||
| 303 | public: | ||
| 304 | explicit sentry(basic_ostream<_CharT, _Traits>& __os); | ||
| 305 | ~sentry(); | ||
| 306 | sentry(const sentry&) = delete; | ||
| 307 | sentry& operator=(const sentry&) = delete; | ||
| 308 | |||
| 309 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; } | ||
| 310 | }; | ||
| 311 | |||
| 312 | template <class _CharT, class _Traits> | ||
| 313 | basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) { | ||
| 314 | if (__os.good()) { | ||
| 315 | if (__os.tie()) | ||
| 316 | __os.tie()->flush(); | ||
| 317 | __ok_ = true; | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | template <class _CharT, class _Traits> | ||
| 322 | basic_ostream<_CharT, _Traits>::sentry::~sentry() { | ||
| 323 | if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && !uncaught_exception()) { | ||
| 324 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 325 | try { | ||
| 326 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 327 | if (__os_.rdbuf()->pubsync() == -1) | ||
| 328 | __os_.setstate(ios_base::badbit); | ||
| 329 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 330 | } catch (...) { | ||
| 331 | } | ||
| 332 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 333 | } | ||
| 334 | } | ||
| 335 | |||
| 336 | template <class _CharT, class _Traits> | ||
| 337 | basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) { | ||
| 338 | this->move(__rhs); | ||
| 339 | } | ||
| 340 | |||
| 341 | template <class _CharT, class _Traits> | ||
| 342 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) { | ||
| 343 | swap(__rhs); | ||
| 344 | return *this; | ||
| 345 | } | ||
| 346 | |||
| 347 | template <class _CharT, class _Traits> | ||
| 348 | basic_ostream<_CharT, _Traits>::~basic_ostream() {} | ||
| 349 | |||
| 350 | template <class _CharT, class _Traits> | ||
| 351 | basic_ostream<_CharT, _Traits>& | ||
| 352 | basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) { | ||
| 353 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 354 | try { | ||
| 355 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 356 | sentry __s(*this); | ||
| 357 | if (__s) { | ||
| 358 | if (__sb) { | ||
| 359 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 360 | try { | ||
| 361 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 362 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 363 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; | ||
| 364 | _Ip __i(__sb); | ||
| 365 | _Ip __eof; | ||
| 366 | _Op __o(*this); | ||
| 367 | size_t __c = 0; | ||
| 368 | for (; __i != __eof; ++__i, ++__o, ++__c) { | ||
| 369 | *__o = *__i; | ||
| 370 | if (__o.failed()) | ||
| 371 | break; | ||
| 372 | } | ||
| 373 | if (__c == 0) | ||
| 374 | this->setstate(ios_base::failbit); | ||
| 375 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 376 | } catch (...) { | ||
| 377 | this->__set_failbit_and_consider_rethrow(); | ||
| 378 | } | ||
| 379 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 380 | } else | ||
| 381 | this->setstate(ios_base::badbit); | ||
| 382 | } | ||
| 383 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 384 | } catch (...) { | ||
| 385 | this->__set_badbit_and_consider_rethrow(); | ||
| 386 | } | ||
| 387 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 388 | return *this; | ||
| 389 | } | ||
| 390 | |||
| 391 | template <class _CharT, class _Traits> | ||
| 392 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) { | ||
| 393 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 394 | try { | ||
| 395 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 396 | sentry __s(*this); | ||
| 397 | if (__s) { | ||
| 398 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 399 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 400 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 401 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 402 | } | ||
| 403 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 404 | } catch (...) { | ||
| 405 | this->__set_badbit_and_consider_rethrow(); | ||
| 406 | } | ||
| 407 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 408 | return *this; | ||
| 409 | } | ||
| 410 | |||
| 411 | template <class _CharT, class _Traits> | ||
| 412 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) { | ||
| 413 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 414 | try { | ||
| 415 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 416 | sentry __s(*this); | ||
| 417 | if (__s) { | ||
| 418 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; | ||
| 419 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 420 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 421 | if (__f.put(*this, | ||
| 422 | *this, | ||
| 423 | this->fill(), | ||
| 424 | __flags == ios_base::oct || __flags == ios_base::hex | ||
| 425 | ? static_cast<long>(static_cast<unsigned short>(__n)) | ||
| 426 | : static_cast<long>(__n)) | ||
| 427 | .failed()) | ||
| 428 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 429 | } | ||
| 430 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 431 | } catch (...) { | ||
| 432 | this->__set_badbit_and_consider_rethrow(); | ||
| 433 | } | ||
| 434 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 435 | return *this; | ||
| 436 | } | ||
| 437 | |||
| 438 | template <class _CharT, class _Traits> | ||
| 439 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) { | ||
| 440 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 441 | try { | ||
| 442 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 443 | sentry __s(*this); | ||
| 444 | if (__s) { | ||
| 445 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 446 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 447 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) | ||
| 448 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 449 | } | ||
| 450 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 451 | } catch (...) { | ||
| 452 | this->__set_badbit_and_consider_rethrow(); | ||
| 453 | } | ||
| 454 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 455 | return *this; | ||
| 456 | } | ||
| 457 | |||
| 458 | template <class _CharT, class _Traits> | ||
| 459 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) { | ||
| 460 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 461 | try { | ||
| 462 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 463 | sentry __s(*this); | ||
| 464 | if (__s) { | ||
| 465 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; | ||
| 466 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 467 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 468 | if (__f.put(*this, | ||
| 469 | *this, | ||
| 470 | this->fill(), | ||
| 471 | __flags == ios_base::oct || __flags == ios_base::hex | ||
| 472 | ? static_cast<long>(static_cast<unsigned int>(__n)) | ||
| 473 | : static_cast<long>(__n)) | ||
| 474 | .failed()) | ||
| 475 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 476 | } | ||
| 477 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 478 | } catch (...) { | ||
| 479 | this->__set_badbit_and_consider_rethrow(); | ||
| 480 | } | ||
| 481 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 482 | return *this; | ||
| 483 | } | ||
| 484 | |||
| 485 | template <class _CharT, class _Traits> | ||
| 486 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) { | ||
| 487 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 488 | try { | ||
| 489 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 490 | sentry __s(*this); | ||
| 491 | if (__s) { | ||
| 492 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 493 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 494 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) | ||
| 495 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 496 | } | ||
| 497 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 498 | } catch (...) { | ||
| 499 | this->__set_badbit_and_consider_rethrow(); | ||
| 500 | } | ||
| 501 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 502 | return *this; | ||
| 503 | } | ||
| 504 | |||
| 505 | template <class _CharT, class _Traits> | ||
| 506 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) { | ||
| 507 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 508 | try { | ||
| 509 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 510 | sentry __s(*this); | ||
| 511 | if (__s) { | ||
| 512 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 513 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 514 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 515 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 516 | } | ||
| 517 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 518 | } catch (...) { | ||
| 519 | this->__set_badbit_and_consider_rethrow(); | ||
| 520 | } | ||
| 521 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 522 | return *this; | ||
| 523 | } | ||
| 524 | |||
| 525 | template <class _CharT, class _Traits> | ||
| 526 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) { | ||
| 527 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 528 | try { | ||
| 529 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 530 | sentry __s(*this); | ||
| 531 | if (__s) { | ||
| 532 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 533 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 534 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 535 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 536 | } | ||
| 537 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 538 | } catch (...) { | ||
| 539 | this->__set_badbit_and_consider_rethrow(); | ||
| 540 | } | ||
| 541 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 542 | return *this; | ||
| 543 | } | ||
| 544 | |||
| 545 | template <class _CharT, class _Traits> | ||
| 546 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) { | ||
| 547 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 548 | try { | ||
| 549 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 550 | sentry __s(*this); | ||
| 551 | if (__s) { | ||
| 552 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 553 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 554 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 555 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 556 | } | ||
| 557 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 558 | } catch (...) { | ||
| 559 | this->__set_badbit_and_consider_rethrow(); | ||
| 560 | } | ||
| 561 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 562 | return *this; | ||
| 563 | } | ||
| 564 | |||
| 565 | template <class _CharT, class _Traits> | ||
| 566 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) { | ||
| 567 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 568 | try { | ||
| 569 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 570 | sentry __s(*this); | ||
| 571 | if (__s) { | ||
| 572 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 573 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 574 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 575 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 576 | } | ||
| 577 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 578 | } catch (...) { | ||
| 579 | this->__set_badbit_and_consider_rethrow(); | ||
| 580 | } | ||
| 581 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 582 | return *this; | ||
| 583 | } | ||
| 584 | |||
| 585 | template <class _CharT, class _Traits> | ||
| 586 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) { | ||
| 587 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 588 | try { | ||
| 589 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 590 | sentry __s(*this); | ||
| 591 | if (__s) { | ||
| 592 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 593 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 594 | if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed()) | ||
| 595 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 596 | } | ||
| 597 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 598 | } catch (...) { | ||
| 599 | this->__set_badbit_and_consider_rethrow(); | ||
| 600 | } | ||
| 601 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 602 | return *this; | ||
| 603 | } | ||
| 604 | |||
| 605 | template <class _CharT, class _Traits> | ||
| 606 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) { | ||
| 607 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 608 | try { | ||
| 609 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 610 | sentry __s(*this); | ||
| 611 | if (__s) { | ||
| 612 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 613 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 614 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 615 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 616 | } | ||
| 617 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 618 | } catch (...) { | ||
| 619 | this->__set_badbit_and_consider_rethrow(); | ||
| 620 | } | ||
| 621 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 622 | return *this; | ||
| 623 | } | ||
| 624 | |||
| 625 | template <class _CharT, class _Traits> | ||
| 626 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) { | ||
| 627 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 628 | try { | ||
| 629 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 630 | sentry __s(*this); | ||
| 631 | if (__s) { | ||
| 632 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 633 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 634 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 635 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 636 | } | ||
| 637 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 638 | } catch (...) { | ||
| 639 | this->__set_badbit_and_consider_rethrow(); | ||
| 640 | } | ||
| 641 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 642 | return *this; | ||
| 643 | } | ||
| 644 | |||
| 645 | template <class _CharT, class _Traits> | ||
| 646 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) { | ||
| 647 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 648 | try { | ||
| 649 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 650 | sentry __s(*this); | ||
| 651 | if (__s) { | ||
| 652 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; | ||
| 653 | const _Fp& __f = std::use_facet<_Fp>(this->getloc()); | ||
| 654 | if (__f.put(*this, *this, this->fill(), __n).failed()) | ||
| 655 | this->setstate(ios_base::badbit | ios_base::failbit); | ||
| 656 | } | ||
| 657 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 658 | } catch (...) { | ||
| 659 | this->__set_badbit_and_consider_rethrow(); | ||
| 660 | } | ||
| 661 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 662 | return *this; | ||
| 663 | } | ||
| 664 | |||
| 665 | template <class _CharT, class _Traits> | ||
| 666 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 667 | __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) { | ||
| 668 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 669 | try { | ||
| 670 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 671 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | ||
| 672 | if (__s) { | ||
| 673 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 674 | if (std::__pad_and_output( | ||
| 675 | _Ip(__os), | ||
| 676 | __str, | ||
| 677 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str, | ||
| 678 | __str + __len, | ||
| 679 | __os, | ||
| 680 | __os.fill()) | ||
| 681 | .failed()) | ||
| 682 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 683 | } | ||
| 684 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 685 | } catch (...) { | ||
| 686 | __os.__set_badbit_and_consider_rethrow(); | ||
| 687 | } | ||
| 688 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 689 | return __os; | ||
| 690 | } | ||
| 691 | |||
| 692 | template <class _CharT, class _Traits> | ||
| 693 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) { | ||
| 694 | return std::__put_character_sequence(__os, &__c, 1); | ||
| 695 | } | ||
| 696 | |||
| 697 | template <class _CharT, class _Traits> | ||
| 698 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) { | ||
| 699 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 700 | try { | ||
| 701 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 702 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | ||
| 703 | if (__s) { | ||
| 704 | _CharT __c = __os.widen(__cn); | ||
| 705 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 706 | if (std::__pad_and_output( | ||
| 707 | _Ip(__os), | ||
| 708 | &__c, | ||
| 709 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c, | ||
| 710 | &__c + 1, | ||
| 711 | __os, | ||
| 712 | __os.fill()) | ||
| 713 | .failed()) | ||
| 714 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 715 | } | ||
| 716 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 717 | } catch (...) { | ||
| 718 | __os.__set_badbit_and_consider_rethrow(); | ||
| 719 | } | ||
| 720 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 721 | return __os; | ||
| 722 | } | ||
| 723 | |||
| 724 | template <class _Traits> | ||
| 725 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, char __c) { | ||
| 726 | return std::__put_character_sequence(__os, &__c, 1); | ||
| 727 | } | ||
| 728 | |||
| 729 | template <class _Traits> | ||
| 730 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, signed char __c) { | ||
| 731 | return std::__put_character_sequence(__os, (char*)&__c, 1); | ||
| 732 | } | ||
| 733 | |||
| 734 | template <class _Traits> | ||
| 735 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) { | ||
| 736 | return std::__put_character_sequence(__os, (char*)&__c, 1); | ||
| 737 | } | ||
| 738 | |||
| 739 | template <class _CharT, class _Traits> | ||
| 740 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 741 | operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) { | ||
| 742 | return std::__put_character_sequence(__os, __str, _Traits::length(__str)); | ||
| 743 | } | ||
| 744 | |||
| 745 | template <class _CharT, class _Traits> | ||
| 746 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 747 | operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { | ||
| 748 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 749 | try { | ||
| 750 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 751 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | ||
| 752 | if (__s) { | ||
| 753 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | ||
| 754 | size_t __len = char_traits<char>::length(__strn); | ||
| 755 | const int __bs = 100; | ||
| 756 | _CharT __wbb[__bs]; | ||
| 757 | _CharT* __wb = __wbb; | ||
| 758 | unique_ptr<_CharT, void (*)(void*)> __h(0, free); | ||
| 759 | if (__len > __bs) { | ||
| 760 | __wb = (_CharT*)malloc(__len * sizeof(_CharT)); | ||
| 761 | if (__wb == 0) | ||
| 762 | __throw_bad_alloc(); | ||
| 763 | __h.reset(__wb); | ||
| 764 | } | ||
| 765 | for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p) | ||
| 766 | *__p = __os.widen(*__strn); | ||
| 767 | if (std::__pad_and_output( | ||
| 768 | _Ip(__os), | ||
| 769 | __wb, | ||
| 770 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __wb + __len : __wb, | ||
| 771 | __wb + __len, | ||
| 772 | __os, | ||
| 773 | __os.fill()) | ||
| 774 | .failed()) | ||
| 775 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 776 | } | ||
| 777 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 778 | } catch (...) { | ||
| 779 | __os.__set_badbit_and_consider_rethrow(); | ||
| 780 | } | ||
| 781 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 782 | return __os; | ||
| 783 | } | ||
| 784 | |||
| 785 | template <class _Traits> | ||
| 786 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, const char* __str) { | ||
| 787 | return std::__put_character_sequence(__os, __str, _Traits::length(__str)); | ||
| 788 | } | ||
| 789 | |||
| 790 | template <class _Traits> | ||
| 791 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& | ||
| 792 | operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) { | ||
| 793 | const char* __s = (const char*)__str; | ||
| 794 | return std::__put_character_sequence(__os, __s, _Traits::length(__s)); | ||
| 795 | } | ||
| 796 | |||
| 797 | template <class _Traits> | ||
| 798 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& | ||
| 799 | operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) { | ||
| 800 | const char* __s = (const char*)__str; | ||
| 801 | return std::__put_character_sequence(__os, __s, _Traits::length(__s)); | ||
| 802 | } | ||
| 803 | |||
| 804 | template <class _CharT, class _Traits> | ||
| 805 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) { | ||
| 806 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 807 | try { | ||
| 808 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 809 | sentry __s(*this); | ||
| 810 | if (__s) { | ||
| 811 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; | ||
| 812 | _Op __o(*this); | ||
| 813 | *__o = __c; | ||
| 814 | if (__o.failed()) | ||
| 815 | this->setstate(ios_base::badbit); | ||
| 816 | } | ||
| 817 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 818 | } catch (...) { | ||
| 819 | this->__set_badbit_and_consider_rethrow(); | ||
| 820 | } | ||
| 821 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 822 | return *this; | ||
| 823 | } | ||
| 824 | |||
| 825 | template <class _CharT, class _Traits> | ||
| 826 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) { | ||
| 827 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 828 | try { | ||
| 829 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 830 | sentry __sen(*this); | ||
| 831 | if (__sen && __n) { | ||
| 832 | if (this->rdbuf()->sputn(__s, __n) != __n) | ||
| 833 | this->setstate(ios_base::badbit); | ||
| 834 | } | ||
| 835 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 836 | } catch (...) { | ||
| 837 | this->__set_badbit_and_consider_rethrow(); | ||
| 838 | } | ||
| 839 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 840 | return *this; | ||
| 841 | } | ||
| 842 | |||
| 843 | template <class _CharT, class _Traits> | ||
| 844 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { | ||
| 845 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 846 | try { | ||
| 847 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 848 | if (this->rdbuf()) { | ||
| 849 | sentry __s(*this); | ||
| 850 | if (__s) { | ||
| 851 | if (this->rdbuf()->pubsync() == -1) | ||
| 852 | this->setstate(ios_base::badbit); | ||
| 853 | } | ||
| 854 | } | ||
| 855 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 856 | } catch (...) { | ||
| 857 | this->__set_badbit_and_consider_rethrow(); | ||
| 858 | } | ||
| 859 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 860 | return *this; | ||
| 861 | } | ||
| 862 | |||
| 863 | template <class _CharT, class _Traits> | ||
| 864 | typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() { | ||
| 865 | if (this->fail()) | ||
| 866 | return pos_type(-1); | ||
| 867 | return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); | ||
| 868 | } | ||
| 869 | |||
| 870 | template <class _CharT, class _Traits> | ||
| 871 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { | ||
| 872 | sentry __s(*this); | ||
| 873 | if (!this->fail()) { | ||
| 874 | if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) | ||
| 875 | this->setstate(ios_base::failbit); | ||
| 876 | } | ||
| 877 | return *this; | ||
| 878 | } | ||
| 879 | |||
| 880 | template <class _CharT, class _Traits> | ||
| 881 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { | ||
| 882 | sentry __s(*this); | ||
| 883 | if (!this->fail()) { | ||
| 884 | if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) | ||
| 885 | this->setstate(ios_base::failbit); | ||
| 886 | } | ||
| 887 | return *this; | ||
| 888 | } | ||
| 889 | |||
| 890 | template <class _CharT, class _Traits> | ||
| 891 | _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) { | ||
| 892 | __os.put(__os.widen('\n')); | ||
| 893 | __os.flush(); | ||
| 894 | return __os; | ||
| 895 | } | ||
| 896 | |||
| 897 | template <class _CharT, class _Traits> | ||
| 898 | _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) { | ||
| 899 | __os.put(_CharT()); | ||
| 900 | return __os; | ||
| 901 | } | ||
| 902 | |||
| 903 | template <class _CharT, class _Traits> | ||
| 904 | _LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) { | ||
| 905 | __os.flush(); | ||
| 906 | return __os; | ||
| 907 | } | ||
| 908 | |||
| 909 | template <class _Stream, class _Tp, class = void> | ||
| 910 | struct __is_ostreamable : false_type {}; | ||
| 911 | |||
| 912 | template <class _Stream, class _Tp> | ||
| 913 | struct __is_ostreamable<_Stream, _Tp, decltype(std::declval<_Stream>() << std::declval<_Tp>(), void())> : true_type {}; | ||
| 914 | |||
| 915 | template <class _Stream, | ||
| 916 | class _Tp, | ||
| 917 | __enable_if_t<_And<is_base_of<ios_base, _Stream>, __is_ostreamable<_Stream&, const _Tp&> >::value, int> = 0> | ||
| 918 | _LIBCPP_HIDE_FROM_ABI _Stream&& operator<<(_Stream&& __os, const _Tp& __x) { | ||
| 919 | __os << __x; | ||
| 920 | return std::move(__os); | ||
| 921 | } | ||
| 922 | |||
| 923 | template <class _CharT, class _Traits, class _Allocator> | ||
| 924 | basic_ostream<_CharT, _Traits>& | ||
| 925 | operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str) { | ||
| 926 | return std::__put_character_sequence(__os, __str.data(), __str.size()); | ||
| 927 | } | ||
| 928 | |||
| 929 | template <class _CharT, class _Traits> | ||
| 930 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 931 | operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) { | ||
| 932 | return std::__put_character_sequence(__os, __sv.data(), __sv.size()); | ||
| 933 | } | ||
| 934 | |||
| 935 | template <class _CharT, class _Traits> | ||
| 936 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 937 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) { | ||
| 938 | return __os << __ec.category().name() << ':' << __ec.value(); | ||
| 939 | } | ||
| 940 | |||
| 941 | template <class _CharT, class _Traits, class _Yp> | ||
| 942 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 943 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) { | ||
| 944 | return __os << __p.get(); | ||
| 945 | } | ||
| 946 | |||
| 947 | template < | ||
| 948 | class _CharT, | ||
| 949 | class _Traits, | ||
| 950 | class _Yp, | ||
| 951 | class _Dp, | ||
| 952 | __enable_if_t<is_same<void, | ||
| 953 | __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() | ||
| 954 | << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value, | ||
| 955 | int> = 0> | ||
| 956 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 957 | operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) { | ||
| 958 | return __os << __p.get(); | ||
| 959 | } | ||
| 960 | |||
| 961 | template <class _CharT, class _Traits, size_t _Size> | ||
| 962 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 963 | operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) { | ||
| 964 | return __os << __x.template to_string<_CharT, _Traits>(std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'), | ||
| 965 | std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); | ||
| 966 | } | ||
| 967 | |||
| 968 | #if _LIBCPP_STD_VER >= 20 | ||
| 969 | |||
| 970 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 971 | template <class _Traits> | ||
| 972 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; | ||
| 973 | |||
| 974 | template <class _Traits> | ||
| 975 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete; | ||
| 976 | |||
| 977 | template <class _Traits> | ||
| 978 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete; | ||
| 979 | |||
| 980 | template <class _Traits> | ||
| 981 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete; | ||
| 982 | |||
| 983 | template <class _Traits> | ||
| 984 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete; | ||
| 985 | |||
| 986 | template <class _Traits> | ||
| 987 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; | ||
| 988 | |||
| 989 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | ||
| 990 | |||
| 991 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | ||
| 992 | template <class _Traits> | ||
| 993 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; | ||
| 994 | |||
| 995 | template <class _Traits> | ||
| 996 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete; | ||
| 997 | |||
| 998 | template <class _Traits> | ||
| 999 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete; | ||
| 1000 | |||
| 1001 | template <class _Traits> | ||
| 1002 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; | ||
| 1003 | # endif | ||
| 1004 | |||
| 1005 | template <class _Traits> | ||
| 1006 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; | ||
| 1007 | |||
| 1008 | template <class _Traits> | ||
| 1009 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete; | ||
| 1010 | |||
| 1011 | template <class _Traits> | ||
| 1012 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete; | ||
| 1013 | |||
| 1014 | template <class _Traits> | ||
| 1015 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; | ||
| 1016 | |||
| 1017 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 1018 | 184 | ||
| 1019 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>; | 185 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 1020 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 186 | # pragma GCC system_header |
| 1021 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>; | ||
| 1022 | #endif | 187 | #endif |
| 1023 | 188 | ||
| 1024 | #if _LIBCPP_STD_VER >= 23 | ||
| 1025 | |||
| 1026 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 1027 | _LIBCPP_HIDE_FROM_ABI inline void | ||
| 1028 | __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) { | ||
| 1029 | // [ostream.formatted.print]/3 | ||
| 1030 | // Effects: Behaves as a formatted output function | ||
| 1031 | // ([ostream.formatted.reqmts]) of os, except that: | ||
| 1032 | // - failure to generate output is reported as specified below, and | ||
| 1033 | // - any exception thrown by the call to vformat is propagated without regard | ||
| 1034 | // to the value of os.exceptions() and without turning on ios_base::badbit | ||
| 1035 | // in the error state of os. | ||
| 1036 | // After constructing a sentry object, the function initializes an automatic | ||
| 1037 | // variable via | ||
| 1038 | // string out = vformat(os.getloc(), fmt, args); | ||
| 1039 | |||
| 1040 | ostream::sentry __s(__os); | ||
| 1041 | if (__s) { | ||
| 1042 | string __o = std::vformat(__os.getloc(), __fmt, __args); | ||
| 1043 | if (__write_nl) | ||
| 1044 | __o += '\n'; | ||
| 1045 | |||
| 1046 | const char* __str = __o.data(); | ||
| 1047 | size_t __len = __o.size(); | ||
| 1048 | |||
| 1049 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1050 | try { | ||
| 1051 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1052 | typedef ostreambuf_iterator<char> _Ip; | ||
| 1053 | if (std::__pad_and_output( | ||
| 1054 | _Ip(__os), | ||
| 1055 | __str, | ||
| 1056 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str, | ||
| 1057 | __str + __len, | ||
| 1058 | __os, | ||
| 1059 | __os.fill()) | ||
| 1060 | .failed()) | ||
| 1061 | __os.setstate(ios_base::badbit | ios_base::failbit); | ||
| 1062 | |||
| 1063 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1064 | } catch (...) { | ||
| 1065 | __os.__set_badbit_and_consider_rethrow(); | ||
| 1066 | } | ||
| 1067 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1068 | } | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 1072 | _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args) { | ||
| 1073 | std::__vprint_nonunicode(__os, __fmt, __args, false); | ||
| 1074 | } | ||
| 1075 | |||
| 1076 | // Returns the FILE* associated with the __os. | ||
| 1077 | // Returns a nullptr when no FILE* is associated with __os. | ||
| 1078 | // This function is in the dylib since the type of the buffer associated | ||
| 1079 | // with std::cout, std::cerr, and std::clog is only known in the dylib. | ||
| 1080 | // | ||
| 1081 | // This function implements part of the implementation-defined behavior | ||
| 1082 | // of [ostream.formatted.print]/3 | ||
| 1083 | // If the function is vprint_unicode and os is a stream that refers to | ||
| 1084 | // a terminal capable of displaying Unicode which is determined in an | ||
| 1085 | // implementation-defined manner, writes out to the terminal using the | ||
| 1086 | // native Unicode API; | ||
| 1087 | // Whether the returned FILE* is "a terminal capable of displaying Unicode" | ||
| 1088 | // is determined in the same way as the print(FILE*, ...) overloads. | ||
| 1089 | _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os); | ||
| 1090 | |||
| 1091 | # ifndef _LIBCPP_HAS_NO_UNICODE | ||
| 1092 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 1093 | _LIBCPP_HIDE_FROM_ABI void | ||
| 1094 | __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) { | ||
| 1095 | #if _LIBCPP_AVAILABILITY_HAS_PRINT == 0 | ||
| 1096 | return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); | ||
| 1097 | #else | ||
| 1098 | FILE* __file = std::__get_ostream_file(__os); | ||
| 1099 | if (!__file || !__print::__is_terminal(__file)) | ||
| 1100 | return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); | ||
| 1101 | |||
| 1102 | // [ostream.formatted.print]/3 | ||
| 1103 | // If the function is vprint_unicode and os is a stream that refers to a | ||
| 1104 | // terminal capable of displaying Unicode which is determined in an | ||
| 1105 | // implementation-defined manner, writes out to the terminal using the | ||
| 1106 | // native Unicode API; if out contains invalid code units, the behavior is | ||
| 1107 | // undefined and implementations are encouraged to diagnose it. If the | ||
| 1108 | // native Unicode API is used, the function flushes os before writing out. | ||
| 1109 | // | ||
| 1110 | // This is the path for the native API, start with flushing. | ||
| 1111 | __os.flush(); | ||
| 1112 | |||
| 1113 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1114 | try { | ||
| 1115 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1116 | ostream::sentry __s(__os); | ||
| 1117 | if (__s) { | ||
| 1118 | # ifndef _LIBCPP_WIN32API | ||
| 1119 | __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true); | ||
| 1120 | # elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | ||
| 1121 | __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true); | ||
| 1122 | # else | ||
| 1123 | # error "Windows builds with wchar_t disabled are not supported." | ||
| 1124 | # endif | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1128 | } catch (...) { | ||
| 1129 | __os.__set_badbit_and_consider_rethrow(); | ||
| 1130 | } | ||
| 1131 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 1132 | #endif // _LIBCPP_AVAILABILITY_HAS_PRINT | ||
| 1133 | } | ||
| 1134 | |||
| 1135 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 1136 | _LIBCPP_HIDE_FROM_ABI inline void | ||
| 1137 | vprint_unicode(ostream& __os, string_view __fmt, format_args __args) { | ||
| 1138 | std::__vprint_unicode(__os, __fmt, __args, false); | ||
| 1139 | } | ||
| 1140 | # endif // _LIBCPP_HAS_NO_UNICODE | ||
| 1141 | |||
| 1142 | template <class... _Args> | ||
| 1143 | _LIBCPP_HIDE_FROM_ABI void | ||
| 1144 | print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { | ||
| 1145 | # ifndef _LIBCPP_HAS_NO_UNICODE | ||
| 1146 | if constexpr (__print::__use_unicode_execution_charset) | ||
| 1147 | std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false); | ||
| 1148 | else | ||
| 1149 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); | ||
| 1150 | # else // _LIBCPP_HAS_NO_UNICODE | ||
| 1151 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); | ||
| 1152 | # endif // _LIBCPP_HAS_NO_UNICODE | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | template <class... _Args> | ||
| 1156 | _LIBCPP_HIDE_FROM_ABI void | ||
| 1157 | println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { | ||
| 1158 | # ifndef _LIBCPP_HAS_NO_UNICODE | ||
| 1159 | // Note the wording in the Standard is inefficient. The output of | ||
| 1160 | // std::format is a std::string which is then copied. This solution | ||
| 1161 | // just appends a newline at the end of the output. | ||
| 1162 | if constexpr (__print::__use_unicode_execution_charset) | ||
| 1163 | std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true); | ||
| 1164 | else | ||
| 1165 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); | ||
| 1166 | # else // _LIBCPP_HAS_NO_UNICODE | ||
| 1167 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); | ||
| 1168 | # endif // _LIBCPP_HAS_NO_UNICODE | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 1172 | |||
| 1173 | _LIBCPP_END_NAMESPACE_STD | ||
| 1174 | |||
| 1175 | _LIBCPP_POP_MACROS | ||
| 1176 | |||
| 1177 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 189 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 1178 | # include <atomic> | 190 | # include <atomic> |
| 1179 | # include <concepts> | 191 | # include <concepts> |
| 192 | # include <cstdio> | ||
| 1180 | # include <cstdlib> | 193 | # include <cstdlib> |
| 194 | # include <format> | ||
| 1181 | # include <iosfwd> | 195 | # include <iosfwd> |
| 1182 | # include <iterator> | 196 | # include <iterator> |
| 197 | # include <print> | ||
| 1183 | # include <stdexcept> | 198 | # include <stdexcept> |
| 1184 | # include <type_traits> | 199 | # include <type_traits> |
| 1185 | #endif | 200 | #endif |
lib/libcxx/include/print+13-2| ... | @@ -15,8 +15,10 @@ namespace std { | ... | @@ -15,8 +15,10 @@ namespace std { |
| 15 | // [print.fun], print functions | 15 | // [print.fun], print functions |
| 16 | template<class... Args> | 16 | template<class... Args> |
| 17 | void print(format_string<Args...> fmt, Args&&... args); | 17 | void print(format_string<Args...> fmt, Args&&... args); |
| 18 | void println(); // Since C++26 | ||
| 18 | template<class... Args> | 19 | template<class... Args> |
| 19 | void print(FILE* stream, format_string<Args...> fmt, Args&&... args); | 20 | void print(FILE* stream, format_string<Args...> fmt, Args&&... args); |
| 21 | void println(FILE* stream); // Since C++26 | ||
| 20 | 22 | ||
| 21 | template<class... Args> | 23 | template<class... Args> |
| 22 | void println(format_string<Args...> fmt, Args&&... args); | 24 | void println(format_string<Args...> fmt, Args&&... args); |
| ... | @@ -31,8 +33,7 @@ namespace std { | ... | @@ -31,8 +33,7 @@ namespace std { |
| 31 | } | 33 | } |
| 32 | */ | 34 | */ |
| 33 | 35 | ||
| 34 | #include <__assert> // all public C++ headers provide the assertion handler | 36 | #include <__assert> |
| 35 | #include <__availability> | ||
| 36 | #include <__concepts/same_as.h> | 37 | #include <__concepts/same_as.h> |
| 37 | #include <__config> | 38 | #include <__config> |
| 38 | #include <__system_error/system_error.h> | 39 | #include <__system_error/system_error.h> |
| ... | @@ -356,6 +357,16 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt | ... | @@ -356,6 +357,16 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt |
| 356 | # endif // _LIBCPP_HAS_NO_UNICODE | 357 | # endif // _LIBCPP_HAS_NO_UNICODE |
| 357 | } | 358 | } |
| 358 | 359 | ||
| 360 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 361 | _LIBCPP_HIDE_FROM_ABI inline void println(FILE* __stream) { | ||
| 362 | std::print(__stream, "\n"); | ||
| 363 | } | ||
| 364 | |||
| 365 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
| 366 | _LIBCPP_HIDE_FROM_ABI inline void println() { | ||
| 367 | println(stdout); | ||
| 368 | } | ||
| 369 | |||
| 359 | template <class... _Args> | 370 | template <class... _Args> |
| 360 | _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __args) { | 371 | _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __args) { |
| 361 | std::println(stdout, __fmt, std::forward<_Args>(__args)...); | 372 | std::println(stdout, __fmt, std::forward<_Args>(__args)...); |
lib/libcxx/include/queue+135-165| ... | @@ -258,9 +258,10 @@ template <class T, class Container, class Compare> | ... | @@ -258,9 +258,10 @@ template <class T, class Container, class Compare> |
| 258 | #include <__algorithm/pop_heap.h> | 258 | #include <__algorithm/pop_heap.h> |
| 259 | #include <__algorithm/push_heap.h> | 259 | #include <__algorithm/push_heap.h> |
| 260 | #include <__algorithm/ranges_copy.h> | 260 | #include <__algorithm/ranges_copy.h> |
| 261 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 262 | #include <__config> | 261 | #include <__config> |
| 263 | #include <__functional/operations.h> | 262 | #include <__functional/operations.h> |
| 263 | #include <__fwd/deque.h> | ||
| 264 | #include <__fwd/queue.h> | ||
| 264 | #include <__iterator/back_insert_iterator.h> | 265 | #include <__iterator/back_insert_iterator.h> |
| 265 | #include <__iterator/iterator_traits.h> | 266 | #include <__iterator/iterator_traits.h> |
| 266 | #include <__memory/uses_allocator.h> | 267 | #include <__memory/uses_allocator.h> |
| ... | @@ -288,9 +289,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -288,9 +289,6 @@ _LIBCPP_PUSH_MACROS |
| 288 | 289 | ||
| 289 | _LIBCPP_BEGIN_NAMESPACE_STD | 290 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 290 | 291 | ||
| 291 | template <class _Tp, class _Container = deque<_Tp> > | ||
| 292 | class _LIBCPP_TEMPLATE_VIS queue; | ||
| 293 | |||
| 294 | template <class _Tp, class _Container> | 292 | template <class _Tp, class _Container> |
| 295 | _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); | 293 | _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); |
| 296 | 294 | ||
| ... | @@ -305,7 +303,7 @@ public: | ... | @@ -305,7 +303,7 @@ public: |
| 305 | typedef typename container_type::reference reference; | 303 | typedef typename container_type::reference reference; |
| 306 | typedef typename container_type::const_reference const_reference; | 304 | typedef typename container_type::const_reference const_reference; |
| 307 | typedef typename container_type::size_type size_type; | 305 | typedef typename container_type::size_type size_type; |
| 308 | static_assert((is_same<_Tp, value_type>::value), ""); | 306 | static_assert(is_same<_Tp, value_type>::value, ""); |
| 309 | 307 | ||
| 310 | protected: | 308 | protected: |
| 311 | container_type c; | 309 | container_type c; |
| ... | @@ -316,7 +314,7 @@ public: | ... | @@ -316,7 +314,7 @@ public: |
| 316 | _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} | 314 | _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} |
| 317 | 315 | ||
| 318 | #if _LIBCPP_STD_VER >= 23 | 316 | #if _LIBCPP_STD_VER >= 23 |
| 319 | template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> | 317 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 320 | _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} | 318 | _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} |
| 321 | 319 | ||
| 322 | template <_ContainerCompatibleRange<_Tp> _Range> | 320 | template <_ContainerCompatibleRange<_Tp> _Range> |
| ... | @@ -324,14 +322,14 @@ public: | ... | @@ -324,14 +322,14 @@ public: |
| 324 | 322 | ||
| 325 | template <class _InputIterator, | 323 | template <class _InputIterator, |
| 326 | class _Alloc, | 324 | class _Alloc, |
| 327 | class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 325 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 328 | class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> | 326 | __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 329 | _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) | 327 | _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) |
| 330 | : c(__first, __second, __alloc) {} | 328 | : c(__first, __second, __alloc) {} |
| 331 | 329 | ||
| 332 | template <_ContainerCompatibleRange<_Tp> _Range, | 330 | template <_ContainerCompatibleRange<_Tp> _Range, |
| 333 | class _Alloc, | 331 | class _Alloc, |
| 334 | class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> | 332 | __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 335 | _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc) | 333 | _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc) |
| 336 | : c(from_range, std::forward<_Range>(__range), __alloc) {} | 334 | : c(from_range, std::forward<_Range>(__range), __alloc) {} |
| 337 | 335 | ||
| ... | @@ -343,10 +341,10 @@ public: | ... | @@ -343,10 +341,10 @@ public: |
| 343 | } | 341 | } |
| 344 | 342 | ||
| 345 | #ifndef _LIBCPP_CXX03_LANG | 343 | #ifndef _LIBCPP_CXX03_LANG |
| 346 | _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) | 344 | _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible<container_type>::value) |
| 347 | : c(std::move(__q.c)) {} | 345 | : c(std::move(__q.c)) {} |
| 348 | 346 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) { | 347 | _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) noexcept(is_nothrow_move_assignable<container_type>::value) { |
| 350 | c = std::move(__q.c); | 348 | c = std::move(__q.c); |
| 351 | return *this; | 349 | return *this; |
| 352 | } | 350 | } |
| ... | @@ -356,31 +354,25 @@ public: | ... | @@ -356,31 +354,25 @@ public: |
| 356 | #ifndef _LIBCPP_CXX03_LANG | 354 | #ifndef _LIBCPP_CXX03_LANG |
| 357 | _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {} | 355 | _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {} |
| 358 | #endif // _LIBCPP_CXX03_LANG | 356 | #endif // _LIBCPP_CXX03_LANG |
| 359 | template <class _Alloc> | 357 | |
| 360 | _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a, | 358 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 361 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | 359 | _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {} |
| 362 | : c(__a) {} | 360 | |
| 363 | template <class _Alloc> | 361 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 364 | _LIBCPP_HIDE_FROM_ABI | 362 | _LIBCPP_HIDE_FROM_ABI queue(const queue& __q, const _Alloc& __a) : c(__q.c, __a) {} |
| 365 | queue(const queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | 363 | |
| 366 | : c(__q.c, __a) {} | 364 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 367 | template <class _Alloc> | 365 | _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {} |
| 368 | _LIBCPP_HIDE_FROM_ABI | 366 | |
| 369 | queue(const container_type& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | ||
| 370 | : c(__c, __a) {} | ||
| 371 | #ifndef _LIBCPP_CXX03_LANG | 367 | #ifndef _LIBCPP_CXX03_LANG |
| 372 | template <class _Alloc> | 368 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 373 | _LIBCPP_HIDE_FROM_ABI | 369 | _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {} |
| 374 | queue(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | ||
| 375 | : c(std::move(__c), __a) {} | ||
| 376 | template <class _Alloc> | ||
| 377 | _LIBCPP_HIDE_FROM_ABI | ||
| 378 | queue(queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | ||
| 379 | : c(std::move(__q.c), __a) {} | ||
| 380 | 370 | ||
| 371 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | ||
| 372 | _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {} | ||
| 381 | #endif // _LIBCPP_CXX03_LANG | 373 | #endif // _LIBCPP_CXX03_LANG |
| 382 | 374 | ||
| 383 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 375 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 384 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 376 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 385 | 377 | ||
| 386 | _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } | 378 | _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } |
| ... | @@ -406,20 +398,20 @@ public: | ... | @@ -406,20 +398,20 @@ public: |
| 406 | template <class... _Args> | 398 | template <class... _Args> |
| 407 | _LIBCPP_HIDE_FROM_ABI | 399 | _LIBCPP_HIDE_FROM_ABI |
| 408 | # if _LIBCPP_STD_VER >= 17 | 400 | # if _LIBCPP_STD_VER >= 17 |
| 409 | decltype(auto) | 401 | decltype(auto) |
| 410 | emplace(_Args&&... __args) { | 402 | emplace(_Args&&... __args) { |
| 411 | return c.emplace_back(std::forward<_Args>(__args)...); | 403 | return c.emplace_back(std::forward<_Args>(__args)...); |
| 412 | } | 404 | } |
| 413 | # else | 405 | # else |
| 414 | void | 406 | void |
| 415 | emplace(_Args&&... __args) { | 407 | emplace(_Args&&... __args) { |
| 416 | c.emplace_back(std::forward<_Args>(__args)...); | 408 | c.emplace_back(std::forward<_Args>(__args)...); |
| 417 | } | 409 | } |
| 418 | # endif | 410 | # endif |
| 419 | #endif // _LIBCPP_CXX03_LANG | 411 | #endif // _LIBCPP_CXX03_LANG |
| 420 | _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } | 412 | _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } |
| 421 | 413 | ||
| 422 | _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) { | 414 | _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) { |
| 423 | using std::swap; | 415 | using std::swap; |
| 424 | swap(c, __q.c); | 416 | swap(c, __q.c); |
| 425 | } | 417 | } |
| ... | @@ -447,7 +439,7 @@ queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; | ... | @@ -447,7 +439,7 @@ queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; |
| 447 | #endif | 439 | #endif |
| 448 | 440 | ||
| 449 | #if _LIBCPP_STD_VER >= 23 | 441 | #if _LIBCPP_STD_VER >= 23 |
| 450 | template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> | 442 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 451 | queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; | 443 | queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; |
| 452 | 444 | ||
| 453 | template <ranges::input_range _Range> | 445 | template <ranges::input_range _Range> |
| ... | @@ -455,14 +447,16 @@ queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; | ... | @@ -455,14 +447,16 @@ queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; |
| 455 | 447 | ||
| 456 | template <class _InputIterator, | 448 | template <class _InputIterator, |
| 457 | class _Alloc, | 449 | class _Alloc, |
| 458 | class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 450 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 459 | class = __enable_if_t<__is_allocator<_Alloc>::value>> | 451 | __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 460 | queue(_InputIterator, _InputIterator, _Alloc) | 452 | queue(_InputIterator, |
| 461 | -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | 453 | _InputIterator, |
| 462 | 454 | _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | |
| 463 | template <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>> | 455 | |
| 464 | queue(from_range_t, _Range&&, _Alloc) | 456 | template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 465 | -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | 457 | queue(from_range_t, |
| 458 | _Range&&, | ||
| 459 | _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | ||
| 466 | #endif | 460 | #endif |
| 467 | 461 | ||
| 468 | template <class _Tp, class _Container> | 462 | template <class _Tp, class _Container> |
| ... | @@ -506,7 +500,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y | ... | @@ -506,7 +500,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y |
| 506 | 500 | ||
| 507 | #endif | 501 | #endif |
| 508 | 502 | ||
| 509 | template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> | 503 | template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0> |
| 510 | inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) | 504 | inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) |
| 511 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 505 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 512 | __x.swap(__y); | 506 | __x.swap(__y); |
| ... | @@ -516,7 +510,7 @@ template <class _Tp, class _Container, class _Alloc> | ... | @@ -516,7 +510,7 @@ template <class _Tp, class _Container, class _Alloc> |
| 516 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { | 510 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { |
| 517 | }; | 511 | }; |
| 518 | 512 | ||
| 519 | template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > | 513 | template <class _Tp, class _Container, class _Compare> |
| 520 | class _LIBCPP_TEMPLATE_VIS priority_queue { | 514 | class _LIBCPP_TEMPLATE_VIS priority_queue { |
| 521 | public: | 515 | public: |
| 522 | typedef _Container container_type; | 516 | typedef _Container container_type; |
| ... | @@ -525,7 +519,7 @@ public: | ... | @@ -525,7 +519,7 @@ public: |
| 525 | typedef typename container_type::reference reference; | 519 | typedef typename container_type::reference reference; |
| 526 | typedef typename container_type::const_reference const_reference; | 520 | typedef typename container_type::const_reference const_reference; |
| 527 | typedef typename container_type::size_type size_type; | 521 | typedef typename container_type::size_type size_type; |
| 528 | static_assert((is_same<_Tp, value_type>::value), ""); | 522 | static_assert(is_same<_Tp, value_type>::value, ""); |
| 529 | 523 | ||
| 530 | protected: | 524 | protected: |
| 531 | container_type c; | 525 | container_type c; |
| ... | @@ -545,12 +539,12 @@ public: | ... | @@ -545,12 +539,12 @@ public: |
| 545 | } | 539 | } |
| 546 | 540 | ||
| 547 | #ifndef _LIBCPP_CXX03_LANG | 541 | #ifndef _LIBCPP_CXX03_LANG |
| 548 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) _NOEXCEPT_( | 542 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept( |
| 549 | is_nothrow_move_constructible<container_type>::value&& is_nothrow_move_constructible<value_compare>::value) | 543 | is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value) |
| 550 | : c(std::move(__q.c)), comp(std::move(__q.comp)) {} | 544 | : c(std::move(__q.c)), comp(std::move(__q.comp)) {} |
| 551 | 545 | ||
| 552 | _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) | 546 | _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept( |
| 553 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value&& is_nothrow_move_assignable<value_compare>::value) { | 547 | is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) { |
| 554 | c = std::move(__q.c); | 548 | c = std::move(__q.c); |
| 555 | comp = std::move(__q.comp); | 549 | comp = std::move(__q.comp); |
| 556 | return *this; | 550 | return *this; |
| ... | @@ -562,13 +556,15 @@ public: | ... | @@ -562,13 +556,15 @@ public: |
| 562 | #ifndef _LIBCPP_CXX03_LANG | 556 | #ifndef _LIBCPP_CXX03_LANG |
| 563 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); | 557 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); |
| 564 | #endif | 558 | #endif |
| 565 | template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 559 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 566 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); | 560 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); |
| 567 | template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 561 | |
| 562 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | ||
| 568 | _LIBCPP_HIDE_FROM_ABI | 563 | _LIBCPP_HIDE_FROM_ABI |
| 569 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); | 564 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); |
| 565 | |||
| 570 | #ifndef _LIBCPP_CXX03_LANG | 566 | #ifndef _LIBCPP_CXX03_LANG |
| 571 | template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 567 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 572 | _LIBCPP_HIDE_FROM_ABI | 568 | _LIBCPP_HIDE_FROM_ABI |
| 573 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); | 569 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); |
| 574 | #endif // _LIBCPP_CXX03_LANG | 570 | #endif // _LIBCPP_CXX03_LANG |
| ... | @@ -581,68 +577,56 @@ public: | ... | @@ -581,68 +577,56 @@ public: |
| 581 | } | 577 | } |
| 582 | #endif | 578 | #endif |
| 583 | 579 | ||
| 584 | template <class _Alloc> | 580 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 585 | _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a, | 581 | _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a); |
| 586 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 587 | template <class _Alloc> | ||
| 588 | _LIBCPP_HIDE_FROM_ABI | ||
| 589 | priority_queue(const value_compare& __comp, | ||
| 590 | const _Alloc& __a, | ||
| 591 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 592 | template <class _Alloc> | ||
| 593 | _LIBCPP_HIDE_FROM_ABI | ||
| 594 | priority_queue(const value_compare& __comp, | ||
| 595 | const container_type& __c, | ||
| 596 | const _Alloc& __a, | ||
| 597 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 598 | template <class _Alloc> | ||
| 599 | _LIBCPP_HIDE_FROM_ABI priority_queue( | ||
| 600 | const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 601 | #ifndef _LIBCPP_CXX03_LANG | ||
| 602 | template <class _Alloc> | ||
| 603 | _LIBCPP_HIDE_FROM_ABI | ||
| 604 | priority_queue(const value_compare& __comp, | ||
| 605 | container_type&& __c, | ||
| 606 | const _Alloc& __a, | ||
| 607 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 608 | template <class _Alloc> | ||
| 609 | _LIBCPP_HIDE_FROM_ABI priority_queue( | ||
| 610 | priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 611 | #endif // _LIBCPP_CXX03_LANG | ||
| 612 | 582 | ||
| 613 | template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 583 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 614 | _LIBCPP_HIDE_FROM_ABI | 584 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a); |
| 615 | priority_queue(_InputIter __f, | ||
| 616 | _InputIter __l, | ||
| 617 | const _Alloc& __a, | ||
| 618 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 619 | 585 | ||
| 620 | template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 586 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 621 | _LIBCPP_HIDE_FROM_ABI priority_queue( | 587 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a); |
| 622 | _InputIter __f, | ||
| 623 | _InputIter __l, | ||
| 624 | const value_compare& __comp, | ||
| 625 | const _Alloc& __a, | ||
| 626 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 627 | 588 | ||
| 628 | template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 589 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 629 | _LIBCPP_HIDE_FROM_ABI priority_queue( | 590 | _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a); |
| 630 | _InputIter __f, | ||
| 631 | _InputIter __l, | ||
| 632 | const value_compare& __comp, | ||
| 633 | const container_type& __c, | ||
| 634 | const _Alloc& __a, | ||
| 635 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | ||
| 636 | 591 | ||
| 637 | #ifndef _LIBCPP_CXX03_LANG | 592 | #ifndef _LIBCPP_CXX03_LANG |
| 638 | template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > | 593 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 594 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a); | ||
| 595 | |||
| 596 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | ||
| 597 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a); | ||
| 598 | #endif // _LIBCPP_CXX03_LANG | ||
| 599 | |||
| 600 | template < | ||
| 601 | class _InputIter, | ||
| 602 | class _Alloc, | ||
| 603 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | ||
| 604 | int> = 0> | ||
| 605 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a); | ||
| 606 | |||
| 607 | template < | ||
| 608 | class _InputIter, | ||
| 609 | class _Alloc, | ||
| 610 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | ||
| 611 | int> = 0> | ||
| 612 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a); | ||
| 613 | |||
| 614 | template < | ||
| 615 | class _InputIter, | ||
| 616 | class _Alloc, | ||
| 617 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | ||
| 618 | int> = 0> | ||
| 639 | _LIBCPP_HIDE_FROM_ABI priority_queue( | 619 | _LIBCPP_HIDE_FROM_ABI priority_queue( |
| 640 | _InputIter __f, | 620 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a); |
| 641 | _InputIter __l, | 621 | |
| 642 | const value_compare& __comp, | 622 | #ifndef _LIBCPP_CXX03_LANG |
| 643 | container_type&& __c, | 623 | template < |
| 644 | const _Alloc& __a, | 624 | class _InputIter, |
| 645 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | 625 | class _Alloc, |
| 626 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | ||
| 627 | int> = 0> | ||
| 628 | _LIBCPP_HIDE_FROM_ABI | ||
| 629 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a); | ||
| 646 | #endif // _LIBCPP_CXX03_LANG | 630 | #endif // _LIBCPP_CXX03_LANG |
| 647 | 631 | ||
| 648 | #if _LIBCPP_STD_VER >= 23 | 632 | #if _LIBCPP_STD_VER >= 23 |
| ... | @@ -665,7 +649,7 @@ public: | ... | @@ -665,7 +649,7 @@ public: |
| 665 | 649 | ||
| 666 | #endif | 650 | #endif |
| 667 | 651 | ||
| 668 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 652 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 669 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 653 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 670 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } | 654 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } |
| 671 | 655 | ||
| ... | @@ -692,7 +676,7 @@ public: | ... | @@ -692,7 +676,7 @@ public: |
| 692 | _LIBCPP_HIDE_FROM_ABI void pop(); | 676 | _LIBCPP_HIDE_FROM_ABI void pop(); |
| 693 | 677 | ||
| 694 | _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) | 678 | _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) |
| 695 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value); | 679 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>); |
| 696 | 680 | ||
| 697 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | 681 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } |
| 698 | }; | 682 | }; |
| ... | @@ -792,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com | ... | @@ -792,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com |
| 792 | #endif // _LIBCPP_CXX03_LANG | 776 | #endif // _LIBCPP_CXX03_LANG |
| 793 | 777 | ||
| 794 | template <class _Tp, class _Container, class _Compare> | 778 | template <class _Tp, class _Container, class _Compare> |
| 795 | template <class _InputIter, class> | 779 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 796 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 780 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 797 | _InputIter __f, _InputIter __l, const value_compare& __comp) | 781 | _InputIter __f, _InputIter __l, const value_compare& __comp) |
| 798 | : c(__f, __l), comp(__comp) { | 782 | : c(__f, __l), comp(__comp) { |
| ... | @@ -800,7 +784,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -800,7 +784,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 800 | } | 784 | } |
| 801 | 785 | ||
| 802 | template <class _Tp, class _Container, class _Compare> | 786 | template <class _Tp, class _Container, class _Compare> |
| 803 | template <class _InputIter, class> | 787 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 804 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 788 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 805 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) | 789 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) |
| 806 | : c(__c), comp(__comp) { | 790 | : c(__c), comp(__comp) { |
| ... | @@ -811,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -811,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 811 | #ifndef _LIBCPP_CXX03_LANG | 795 | #ifndef _LIBCPP_CXX03_LANG |
| 812 | 796 | ||
| 813 | template <class _Tp, class _Container, class _Compare> | 797 | template <class _Tp, class _Container, class _Compare> |
| 814 | template <class _InputIter, class> | 798 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 815 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 799 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 816 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c) | 800 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c) |
| 817 | : c(std::move(__c)), comp(__comp) { | 801 | : c(std::move(__c)), comp(__comp) { |
| ... | @@ -822,84 +806,72 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -822,84 +806,72 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 822 | #endif // _LIBCPP_CXX03_LANG | 806 | #endif // _LIBCPP_CXX03_LANG |
| 823 | 807 | ||
| 824 | template <class _Tp, class _Container, class _Compare> | 808 | template <class _Tp, class _Container, class _Compare> |
| 825 | template <class _Alloc> | 809 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 826 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 810 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {} |
| 827 | const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 828 | : c(__a) {} | ||
| 829 | 811 | ||
| 830 | template <class _Tp, class _Container, class _Compare> | 812 | template <class _Tp, class _Container, class _Compare> |
| 831 | template <class _Alloc> | 813 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 832 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 814 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a) |
| 833 | const value_compare& __comp, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 834 | : c(__a), comp(__comp) {} | 815 | : c(__a), comp(__comp) {} |
| 835 | 816 | ||
| 836 | template <class _Tp, class _Container, class _Compare> | 817 | template <class _Tp, class _Container, class _Compare> |
| 837 | template <class _Alloc> | 818 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 838 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 819 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 839 | const value_compare& __comp, | 820 | const value_compare& __comp, const container_type& __c, const _Alloc& __a) |
| 840 | const container_type& __c, | ||
| 841 | const _Alloc& __a, | ||
| 842 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 843 | : c(__c, __a), comp(__comp) { | 821 | : c(__c, __a), comp(__comp) { |
| 844 | std::make_heap(c.begin(), c.end(), comp); | 822 | std::make_heap(c.begin(), c.end(), comp); |
| 845 | } | 823 | } |
| 846 | 824 | ||
| 847 | template <class _Tp, class _Container, class _Compare> | 825 | template <class _Tp, class _Container, class _Compare> |
| 848 | template <class _Alloc> | 826 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 849 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 827 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a) |
| 850 | const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 851 | : c(__q.c, __a), comp(__q.comp) {} | 828 | : c(__q.c, __a), comp(__q.comp) {} |
| 852 | 829 | ||
| 853 | #ifndef _LIBCPP_CXX03_LANG | 830 | #ifndef _LIBCPP_CXX03_LANG |
| 854 | 831 | ||
| 855 | template <class _Tp, class _Container, class _Compare> | 832 | template <class _Tp, class _Container, class _Compare> |
| 856 | template <class _Alloc> | 833 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 857 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 834 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 858 | const value_compare& __comp, | 835 | const value_compare& __comp, container_type&& __c, const _Alloc& __a) |
| 859 | container_type&& __c, | ||
| 860 | const _Alloc& __a, | ||
| 861 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 862 | : c(std::move(__c), __a), comp(__comp) { | 836 | : c(std::move(__c), __a), comp(__comp) { |
| 863 | std::make_heap(c.begin(), c.end(), comp); | 837 | std::make_heap(c.begin(), c.end(), comp); |
| 864 | } | 838 | } |
| 865 | 839 | ||
| 866 | template <class _Tp, class _Container, class _Compare> | 840 | template <class _Tp, class _Container, class _Compare> |
| 867 | template <class _Alloc> | 841 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 868 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 842 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a) |
| 869 | priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 870 | : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} | 843 | : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} |
| 871 | 844 | ||
| 872 | #endif // _LIBCPP_CXX03_LANG | 845 | #endif // _LIBCPP_CXX03_LANG |
| 873 | 846 | ||
| 874 | template <class _Tp, class _Container, class _Compare> | 847 | template <class _Tp, class _Container, class _Compare> |
| 875 | template <class _InputIter, class _Alloc, class> | 848 | template < |
| 876 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 849 | class _InputIter, |
| 877 | _InputIter __f, _InputIter __l, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | 850 | class _Alloc, |
| 851 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | ||
| 852 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a) | ||
| 878 | : c(__f, __l, __a), comp() { | 853 | : c(__f, __l, __a), comp() { |
| 879 | std::make_heap(c.begin(), c.end(), comp); | 854 | std::make_heap(c.begin(), c.end(), comp); |
| 880 | } | 855 | } |
| 881 | 856 | ||
| 882 | template <class _Tp, class _Container, class _Compare> | 857 | template <class _Tp, class _Container, class _Compare> |
| 883 | template <class _InputIter, class _Alloc, class> | 858 | template < |
| 859 | class _InputIter, | ||
| 860 | class _Alloc, | ||
| 861 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | ||
| 884 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 862 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 885 | _InputIter __f, | 863 | _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a) |
| 886 | _InputIter __l, | ||
| 887 | const value_compare& __comp, | ||
| 888 | const _Alloc& __a, | ||
| 889 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 890 | : c(__f, __l, __a), comp(__comp) { | 864 | : c(__f, __l, __a), comp(__comp) { |
| 891 | std::make_heap(c.begin(), c.end(), comp); | 865 | std::make_heap(c.begin(), c.end(), comp); |
| 892 | } | 866 | } |
| 893 | 867 | ||
| 894 | template <class _Tp, class _Container, class _Compare> | 868 | template <class _Tp, class _Container, class _Compare> |
| 895 | template <class _InputIter, class _Alloc, class> | 869 | template < |
| 870 | class _InputIter, | ||
| 871 | class _Alloc, | ||
| 872 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | ||
| 896 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 873 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 897 | _InputIter __f, | 874 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a) |
| 898 | _InputIter __l, | ||
| 899 | const value_compare& __comp, | ||
| 900 | const container_type& __c, | ||
| 901 | const _Alloc& __a, | ||
| 902 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 903 | : c(__c, __a), comp(__comp) { | 875 | : c(__c, __a), comp(__comp) { |
| 904 | c.insert(c.end(), __f, __l); | 876 | c.insert(c.end(), __f, __l); |
| 905 | std::make_heap(c.begin(), c.end(), comp); | 877 | std::make_heap(c.begin(), c.end(), comp); |
| ... | @@ -907,14 +879,12 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -907,14 +879,12 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 907 | 879 | ||
| 908 | #ifndef _LIBCPP_CXX03_LANG | 880 | #ifndef _LIBCPP_CXX03_LANG |
| 909 | template <class _Tp, class _Container, class _Compare> | 881 | template <class _Tp, class _Container, class _Compare> |
| 910 | template <class _InputIter, class _Alloc, class> | 882 | template < |
| 883 | class _InputIter, | ||
| 884 | class _Alloc, | ||
| 885 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | ||
| 911 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 886 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 912 | _InputIter __f, | 887 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a) |
| 913 | _InputIter __l, | ||
| 914 | const value_compare& __comp, | ||
| 915 | container_type&& __c, | ||
| 916 | const _Alloc& __a, | ||
| 917 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | ||
| 918 | : c(std::move(__c), __a), comp(__comp) { | 888 | : c(std::move(__c), __a), comp(__comp) { |
| 919 | c.insert(c.end(), __f, __l); | 889 | c.insert(c.end(), __f, __l); |
| 920 | std::make_heap(c.begin(), c.end(), comp); | 890 | std::make_heap(c.begin(), c.end(), comp); |
| ... | @@ -952,7 +922,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::pop() { | ... | @@ -952,7 +922,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::pop() { |
| 952 | 922 | ||
| 953 | template <class _Tp, class _Container, class _Compare> | 923 | template <class _Tp, class _Container, class _Compare> |
| 954 | inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) | 924 | inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) |
| 955 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value) { | 925 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) { |
| 956 | using std::swap; | 926 | using std::swap; |
| 957 | swap(c, __q.c); | 927 | swap(c, __q.c); |
| 958 | swap(comp, __q.comp); | 928 | swap(comp, __q.comp); |
| ... | @@ -961,7 +931,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) | ... | @@ -961,7 +931,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) |
| 961 | template <class _Tp, | 931 | template <class _Tp, |
| 962 | class _Container, | 932 | class _Container, |
| 963 | class _Compare, | 933 | class _Compare, |
| 964 | __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0> | 934 | __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0> |
| 965 | inline _LIBCPP_HIDE_FROM_ABI void | 935 | inline _LIBCPP_HIDE_FROM_ABI void |
| 966 | swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) | 936 | swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) |
| 967 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 937 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
lib/libcxx/include/random-4| ... | @@ -1677,13 +1677,11 @@ class piecewise_linear_distribution | ... | @@ -1677,13 +1677,11 @@ class piecewise_linear_distribution |
| 1677 | } // std | 1677 | } // std |
| 1678 | */ | 1678 | */ |
| 1679 | 1679 | ||
| 1680 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 1681 | #include <__config> | 1680 | #include <__config> |
| 1682 | #include <__random/bernoulli_distribution.h> | 1681 | #include <__random/bernoulli_distribution.h> |
| 1683 | #include <__random/binomial_distribution.h> | 1682 | #include <__random/binomial_distribution.h> |
| 1684 | #include <__random/cauchy_distribution.h> | 1683 | #include <__random/cauchy_distribution.h> |
| 1685 | #include <__random/chi_squared_distribution.h> | 1684 | #include <__random/chi_squared_distribution.h> |
| 1686 | #include <__random/clamp_to_integral.h> | ||
| 1687 | #include <__random/default_random_engine.h> | 1685 | #include <__random/default_random_engine.h> |
| 1688 | #include <__random/discard_block_engine.h> | 1686 | #include <__random/discard_block_engine.h> |
| 1689 | #include <__random/discrete_distribution.h> | 1687 | #include <__random/discrete_distribution.h> |
| ... | @@ -1695,10 +1693,8 @@ class piecewise_linear_distribution | ... | @@ -1695,10 +1693,8 @@ class piecewise_linear_distribution |
| 1695 | #include <__random/geometric_distribution.h> | 1693 | #include <__random/geometric_distribution.h> |
| 1696 | #include <__random/independent_bits_engine.h> | 1694 | #include <__random/independent_bits_engine.h> |
| 1697 | #include <__random/is_seed_sequence.h> | 1695 | #include <__random/is_seed_sequence.h> |
| 1698 | #include <__random/is_valid.h> | ||
| 1699 | #include <__random/knuth_b.h> | 1696 | #include <__random/knuth_b.h> |
| 1700 | #include <__random/linear_congruential_engine.h> | 1697 | #include <__random/linear_congruential_engine.h> |
| 1701 | #include <__random/log2.h> | ||
| 1702 | #include <__random/lognormal_distribution.h> | 1698 | #include <__random/lognormal_distribution.h> |
| 1703 | #include <__random/mersenne_twister_engine.h> | 1699 | #include <__random/mersenne_twister_engine.h> |
| 1704 | #include <__random/negative_binomial_distribution.h> | 1700 | #include <__random/negative_binomial_distribution.h> |
lib/libcxx/include/ranges+60-41| ... | @@ -93,6 +93,11 @@ namespace std::ranges { | ... | @@ -93,6 +93,11 @@ namespace std::ranges { |
| 93 | template<class T> | 93 | template<class T> |
| 94 | concept viewable_range = see below; | 94 | concept viewable_range = see below; |
| 95 | 95 | ||
| 96 | // [range.adaptor.object], range adaptor objects | ||
| 97 | template<class D> | ||
| 98 | requires is_class_v<D> && same_as<D, remove_cv_t<D>> | ||
| 99 | class range_adaptor_closure { }; // Since c++23 | ||
| 100 | |||
| 96 | // [view.interface], class template view_interface | 101 | // [view.interface], class template view_interface |
| 97 | template<class D> | 102 | template<class D> |
| 98 | requires is_class_v<D> && same_as<D, remove_cv_t<D>> | 103 | requires is_class_v<D> && same_as<D, remove_cv_t<D>> |
| ... | @@ -375,51 +380,57 @@ namespace std { | ... | @@ -375,51 +380,57 @@ namespace std { |
| 375 | } | 380 | } |
| 376 | */ | 381 | */ |
| 377 | 382 | ||
| 378 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 379 | #include <__config> | 383 | #include <__config> |
| 380 | #include <__ranges/access.h> | ||
| 381 | #include <__ranges/all.h> | ||
| 382 | #include <__ranges/as_rvalue_view.h> | ||
| 383 | #include <__ranges/chunk_by_view.h> | ||
| 384 | #include <__ranges/common_view.h> | ||
| 385 | #include <__ranges/concepts.h> | ||
| 386 | #include <__ranges/counted.h> | ||
| 387 | #include <__ranges/dangling.h> | ||
| 388 | #include <__ranges/data.h> | ||
| 389 | #include <__ranges/drop_view.h> | ||
| 390 | #include <__ranges/drop_while_view.h> | ||
| 391 | #include <__ranges/elements_view.h> | ||
| 392 | #include <__ranges/empty.h> | ||
| 393 | #include <__ranges/empty_view.h> | ||
| 394 | #include <__ranges/enable_borrowed_range.h> | ||
| 395 | #include <__ranges/enable_view.h> | ||
| 396 | #include <__ranges/filter_view.h> | ||
| 397 | #include <__ranges/from_range.h> | ||
| 398 | #include <__ranges/iota_view.h> | ||
| 399 | #include <__ranges/join_view.h> | ||
| 400 | #include <__ranges/lazy_split_view.h> | ||
| 401 | #include <__ranges/rbegin.h> | ||
| 402 | #include <__ranges/ref_view.h> | ||
| 403 | #include <__ranges/rend.h> | ||
| 404 | #include <__ranges/repeat_view.h> | ||
| 405 | #include <__ranges/reverse_view.h> | ||
| 406 | #include <__ranges/single_view.h> | ||
| 407 | #include <__ranges/size.h> | ||
| 408 | #include <__ranges/split_view.h> | ||
| 409 | #include <__ranges/subrange.h> | ||
| 410 | #include <__ranges/take_view.h> | ||
| 411 | #include <__ranges/take_while_view.h> | ||
| 412 | #include <__ranges/to.h> | ||
| 413 | #include <__ranges/transform_view.h> | ||
| 414 | #include <__ranges/view_interface.h> | ||
| 415 | #include <__ranges/views.h> | ||
| 416 | #include <__ranges/zip_view.h> | ||
| 417 | #include <version> | ||
| 418 | 384 | ||
| 419 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | 385 | #if _LIBCPP_STD_VER >= 20 |
| 420 | # include <__ranges/istream_view.h> | 386 | # include <__ranges/access.h> |
| 387 | # include <__ranges/all.h> | ||
| 388 | # include <__ranges/common_view.h> | ||
| 389 | # include <__ranges/concepts.h> | ||
| 390 | # include <__ranges/counted.h> | ||
| 391 | # include <__ranges/dangling.h> | ||
| 392 | # include <__ranges/data.h> | ||
| 393 | # include <__ranges/drop_view.h> | ||
| 394 | # include <__ranges/drop_while_view.h> | ||
| 395 | # include <__ranges/elements_view.h> | ||
| 396 | # include <__ranges/empty.h> | ||
| 397 | # include <__ranges/empty_view.h> | ||
| 398 | # include <__ranges/enable_borrowed_range.h> | ||
| 399 | # include <__ranges/enable_view.h> | ||
| 400 | # include <__ranges/filter_view.h> | ||
| 401 | # include <__ranges/iota_view.h> | ||
| 402 | # include <__ranges/join_view.h> | ||
| 403 | # include <__ranges/lazy_split_view.h> | ||
| 404 | # include <__ranges/rbegin.h> | ||
| 405 | # include <__ranges/ref_view.h> | ||
| 406 | # include <__ranges/rend.h> | ||
| 407 | # include <__ranges/reverse_view.h> | ||
| 408 | # include <__ranges/single_view.h> | ||
| 409 | # include <__ranges/size.h> | ||
| 410 | # include <__ranges/split_view.h> | ||
| 411 | # include <__ranges/subrange.h> | ||
| 412 | # include <__ranges/take_view.h> | ||
| 413 | # include <__ranges/take_while_view.h> | ||
| 414 | # include <__ranges/transform_view.h> | ||
| 415 | # include <__ranges/view_interface.h> | ||
| 416 | # include <__ranges/views.h> | ||
| 417 | |||
| 418 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 419 | # include <__ranges/istream_view.h> | ||
| 420 | # endif | ||
| 421 | #endif | ||
| 422 | |||
| 423 | #if _LIBCPP_STD_VER >= 23 | ||
| 424 | # include <__ranges/as_rvalue_view.h> | ||
| 425 | # include <__ranges/chunk_by_view.h> | ||
| 426 | # include <__ranges/from_range.h> | ||
| 427 | # include <__ranges/repeat_view.h> | ||
| 428 | # include <__ranges/to.h> | ||
| 429 | # include <__ranges/zip_view.h> | ||
| 421 | #endif | 430 | #endif |
| 422 | 431 | ||
| 432 | #include <version> | ||
| 433 | |||
| 423 | // standard-mandated includes | 434 | // standard-mandated includes |
| 424 | 435 | ||
| 425 | // [ranges.syn] | 436 | // [ranges.syn] |
| ... | @@ -435,6 +446,14 @@ namespace std { | ... | @@ -435,6 +446,14 @@ namespace std { |
| 435 | # pragma GCC system_header | 446 | # pragma GCC system_header |
| 436 | #endif | 447 | #endif |
| 437 | 448 | ||
| 449 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | ||
| 450 | # include <cstddef> | ||
| 451 | # include <limits> | ||
| 452 | # include <optional> | ||
| 453 | # include <span> | ||
| 454 | # include <tuple> | ||
| 455 | #endif | ||
| 456 | |||
| 438 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 457 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 439 | # include <cstdlib> | 458 | # include <cstdlib> |
| 440 | # include <iosfwd> | 459 | # include <iosfwd> |
lib/libcxx/include/ratio+36-7| ... | @@ -81,7 +81,6 @@ using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C+ | ... | @@ -81,7 +81,6 @@ using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C+ |
| 81 | } | 81 | } |
| 82 | */ | 82 | */ |
| 83 | 83 | ||
| 84 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 85 | #include <__config> | 84 | #include <__config> |
| 86 | #include <__type_traits/integral_constant.h> | 85 | #include <__type_traits/integral_constant.h> |
| 87 | #include <climits> | 86 | #include <climits> |
| ... | @@ -289,6 +288,9 @@ private: | ... | @@ -289,6 +288,9 @@ private: |
| 289 | static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value; | 288 | static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value; |
| 290 | static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value; | 289 | static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value; |
| 291 | 290 | ||
| 291 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 292 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 293 | |||
| 292 | public: | 294 | public: |
| 293 | typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value, | 295 | typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value, |
| 294 | __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type; | 296 | __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type; |
| ... | @@ -312,6 +314,9 @@ private: | ... | @@ -312,6 +314,9 @@ private: |
| 312 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | 314 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; |
| 313 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | 315 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; |
| 314 | 316 | ||
| 317 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 318 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 319 | |||
| 315 | public: | 320 | public: |
| 316 | typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value, | 321 | typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value, |
| 317 | __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type; | 322 | __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type; |
| ... | @@ -335,6 +340,9 @@ private: | ... | @@ -335,6 +340,9 @@ private: |
| 335 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | 340 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; |
| 336 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | 341 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; |
| 337 | 342 | ||
| 343 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 344 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 345 | |||
| 338 | public: | 346 | public: |
| 339 | typedef typename ratio_multiply< | 347 | typedef typename ratio_multiply< |
| 340 | ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>, | 348 | ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>, |
| ... | @@ -361,6 +369,9 @@ private: | ... | @@ -361,6 +369,9 @@ private: |
| 361 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | 369 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; |
| 362 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | 370 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; |
| 363 | 371 | ||
| 372 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 373 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 374 | |||
| 364 | public: | 375 | public: |
| 365 | typedef typename ratio_multiply< | 376 | typedef typename ratio_multiply< |
| 366 | ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>, | 377 | ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>, |
| ... | @@ -384,10 +395,16 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>:: | ... | @@ -384,10 +395,16 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>:: |
| 384 | // ratio_equal | 395 | // ratio_equal |
| 385 | 396 | ||
| 386 | template <class _R1, class _R2> | 397 | template <class _R1, class _R2> |
| 387 | struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {}; | 398 | struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> { |
| 399 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 400 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 401 | }; | ||
| 388 | 402 | ||
| 389 | template <class _R1, class _R2> | 403 | template <class _R1, class _R2> |
| 390 | struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {}; | 404 | struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> { |
| 405 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 406 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 407 | }; | ||
| 391 | 408 | ||
| 392 | // ratio_less | 409 | // ratio_less |
| 393 | 410 | ||
| ... | @@ -441,16 +458,28 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> { | ... | @@ -441,16 +458,28 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> { |
| 441 | }; | 458 | }; |
| 442 | 459 | ||
| 443 | template <class _R1, class _R2> | 460 | template <class _R1, class _R2> |
| 444 | struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {}; | 461 | struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> { |
| 462 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 463 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 464 | }; | ||
| 445 | 465 | ||
| 446 | template <class _R1, class _R2> | 466 | template <class _R1, class _R2> |
| 447 | struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {}; | 467 | struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> { |
| 468 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 469 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 470 | }; | ||
| 448 | 471 | ||
| 449 | template <class _R1, class _R2> | 472 | template <class _R1, class _R2> |
| 450 | struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {}; | 473 | struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> { |
| 474 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 475 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 476 | }; | ||
| 451 | 477 | ||
| 452 | template <class _R1, class _R2> | 478 | template <class _R1, class _R2> |
| 453 | struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {}; | 479 | struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> { |
| 480 | static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | ||
| 481 | static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | ||
| 482 | }; | ||
| 454 | 483 | ||
| 455 | template <class _R1, class _R2> | 484 | template <class _R1, class _R2> |
| 456 | struct __ratio_gcd { | 485 | struct __ratio_gcd { |
lib/libcxx/include/regex+39-28| ... | @@ -791,8 +791,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | ... | @@ -791,8 +791,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 791 | 791 | ||
| 792 | #include <__algorithm/find.h> | 792 | #include <__algorithm/find.h> |
| 793 | #include <__algorithm/search.h> | 793 | #include <__algorithm/search.h> |
| 794 | #include <__assert> // all public C++ headers provide the assertion handler | 794 | #include <__assert> |
| 795 | #include <__availability> | ||
| 796 | #include <__config> | 795 | #include <__config> |
| 797 | #include <__iterator/back_insert_iterator.h> | 796 | #include <__iterator/back_insert_iterator.h> |
| 798 | #include <__iterator/default_sentinel.h> | 797 | #include <__iterator/default_sentinel.h> |
| ... | @@ -1346,13 +1345,12 @@ struct __state { | ... | @@ -1346,13 +1345,12 @@ struct __state { |
| 1346 | 1345 | ||
| 1347 | template <class _CharT> | 1346 | template <class _CharT> |
| 1348 | class __node { | 1347 | class __node { |
| 1349 | __node(const __node&); | ||
| 1350 | __node& operator=(const __node&); | ||
| 1351 | |||
| 1352 | public: | 1348 | public: |
| 1353 | typedef std::__state<_CharT> __state; | 1349 | typedef std::__state<_CharT> __state; |
| 1354 | 1350 | ||
| 1355 | _LIBCPP_HIDE_FROM_ABI __node() {} | 1351 | _LIBCPP_HIDE_FROM_ABI __node() {} |
| 1352 | __node(const __node&) = delete; | ||
| 1353 | __node& operator=(const __node&) = delete; | ||
| 1356 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL | 1354 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL |
| 1357 | virtual ~__node() {} | 1355 | virtual ~__node() {} |
| 1358 | 1356 | ||
| ... | @@ -1953,14 +1951,14 @@ class __match_char : public __owns_one_state<_CharT> { | ... | @@ -1953,14 +1951,14 @@ class __match_char : public __owns_one_state<_CharT> { |
| 1953 | 1951 | ||
| 1954 | _CharT __c_; | 1952 | _CharT __c_; |
| 1955 | 1953 | ||
| 1956 | __match_char(const __match_char&); | ||
| 1957 | __match_char& operator=(const __match_char&); | ||
| 1958 | |||
| 1959 | public: | 1954 | public: |
| 1960 | typedef std::__state<_CharT> __state; | 1955 | typedef std::__state<_CharT> __state; |
| 1961 | 1956 | ||
| 1962 | _LIBCPP_HIDE_FROM_ABI __match_char(_CharT __c, __node<_CharT>* __s) : base(__s), __c_(__c) {} | 1957 | _LIBCPP_HIDE_FROM_ABI __match_char(_CharT __c, __node<_CharT>* __s) : base(__s), __c_(__c) {} |
| 1963 | 1958 | ||
| 1959 | __match_char(const __match_char&) = delete; | ||
| 1960 | __match_char& operator=(const __match_char&) = delete; | ||
| 1961 | |||
| 1964 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; | 1962 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; |
| 1965 | }; | 1963 | }; |
| 1966 | 1964 | ||
| ... | @@ -1985,15 +1983,15 @@ class __match_char_icase : public __owns_one_state<_CharT> { | ... | @@ -1985,15 +1983,15 @@ class __match_char_icase : public __owns_one_state<_CharT> { |
| 1985 | _Traits __traits_; | 1983 | _Traits __traits_; |
| 1986 | _CharT __c_; | 1984 | _CharT __c_; |
| 1987 | 1985 | ||
| 1988 | __match_char_icase(const __match_char_icase&); | ||
| 1989 | __match_char_icase& operator=(const __match_char_icase&); | ||
| 1990 | |||
| 1991 | public: | 1986 | public: |
| 1992 | typedef std::__state<_CharT> __state; | 1987 | typedef std::__state<_CharT> __state; |
| 1993 | 1988 | ||
| 1994 | _LIBCPP_HIDE_FROM_ABI __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) | 1989 | _LIBCPP_HIDE_FROM_ABI __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) |
| 1995 | : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {} | 1990 | : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {} |
| 1996 | 1991 | ||
| 1992 | __match_char_icase(const __match_char_icase&) = delete; | ||
| 1993 | __match_char_icase& operator=(const __match_char_icase&) = delete; | ||
| 1994 | |||
| 1997 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; | 1995 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; |
| 1998 | }; | 1996 | }; |
| 1999 | 1997 | ||
| ... | @@ -2018,15 +2016,15 @@ class __match_char_collate : public __owns_one_state<_CharT> { | ... | @@ -2018,15 +2016,15 @@ class __match_char_collate : public __owns_one_state<_CharT> { |
| 2018 | _Traits __traits_; | 2016 | _Traits __traits_; |
| 2019 | _CharT __c_; | 2017 | _CharT __c_; |
| 2020 | 2018 | ||
| 2021 | __match_char_collate(const __match_char_collate&); | ||
| 2022 | __match_char_collate& operator=(const __match_char_collate&); | ||
| 2023 | |||
| 2024 | public: | 2019 | public: |
| 2025 | typedef std::__state<_CharT> __state; | 2020 | typedef std::__state<_CharT> __state; |
| 2026 | 2021 | ||
| 2027 | _LIBCPP_HIDE_FROM_ABI __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) | 2022 | _LIBCPP_HIDE_FROM_ABI __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) |
| 2028 | : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {} | 2023 | : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {} |
| 2029 | 2024 | ||
| 2025 | __match_char_collate(const __match_char_collate&) = delete; | ||
| 2026 | __match_char_collate& operator=(const __match_char_collate&) = delete; | ||
| 2027 | |||
| 2030 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; | 2028 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; |
| 2031 | }; | 2029 | }; |
| 2032 | 2030 | ||
| ... | @@ -2062,9 +2060,6 @@ class __bracket_expression : public __owns_one_state<_CharT> { | ... | @@ -2062,9 +2060,6 @@ class __bracket_expression : public __owns_one_state<_CharT> { |
| 2062 | bool __collate_; | 2060 | bool __collate_; |
| 2063 | bool __might_have_digraph_; | 2061 | bool __might_have_digraph_; |
| 2064 | 2062 | ||
| 2065 | __bracket_expression(const __bracket_expression&); | ||
| 2066 | __bracket_expression& operator=(const __bracket_expression&); | ||
| 2067 | |||
| 2068 | public: | 2063 | public: |
| 2069 | typedef std::__state<_CharT> __state; | 2064 | typedef std::__state<_CharT> __state; |
| 2070 | 2065 | ||
| ... | @@ -2079,6 +2074,9 @@ public: | ... | @@ -2079,6 +2074,9 @@ public: |
| 2079 | __collate_(__collate), | 2074 | __collate_(__collate), |
| 2080 | __might_have_digraph_(__traits_.getloc().name() != "C") {} | 2075 | __might_have_digraph_(__traits_.getloc().name() != "C") {} |
| 2081 | 2076 | ||
| 2077 | __bracket_expression(const __bracket_expression&) = delete; | ||
| 2078 | __bracket_expression& operator=(const __bracket_expression&) = delete; | ||
| 2079 | |||
| 2082 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; | 2080 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; |
| 2083 | 2081 | ||
| 2084 | _LIBCPP_HIDE_FROM_ABI bool __negated() const { return __negate_; } | 2082 | _LIBCPP_HIDE_FROM_ABI bool __negated() const { return __negate_; } |
| ... | @@ -2700,9 +2698,6 @@ class __lookahead : public __owns_one_state<_CharT> { | ... | @@ -2700,9 +2698,6 @@ class __lookahead : public __owns_one_state<_CharT> { |
| 2700 | unsigned __mexp_; | 2698 | unsigned __mexp_; |
| 2701 | bool __invert_; | 2699 | bool __invert_; |
| 2702 | 2700 | ||
| 2703 | __lookahead(const __lookahead&); | ||
| 2704 | __lookahead& operator=(const __lookahead&); | ||
| 2705 | |||
| 2706 | public: | 2701 | public: |
| 2707 | typedef std::__state<_CharT> __state; | 2702 | typedef std::__state<_CharT> __state; |
| 2708 | 2703 | ||
| ... | @@ -2710,6 +2705,9 @@ public: | ... | @@ -2710,6 +2705,9 @@ public: |
| 2710 | __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) | 2705 | __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) |
| 2711 | : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {} | 2706 | : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {} |
| 2712 | 2707 | ||
| 2708 | __lookahead(const __lookahead&) = delete; | ||
| 2709 | __lookahead& operator=(const __lookahead&) = delete; | ||
| 2710 | |||
| 2713 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; | 2711 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const; |
| 2714 | }; | 2712 | }; |
| 2715 | 2713 | ||
| ... | @@ -4215,11 +4213,7 @@ public: | ... | @@ -4215,11 +4213,7 @@ public: |
| 4215 | _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return str().compare(__s); } | 4213 | _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return str().compare(__s); } |
| 4216 | _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return str().compare(__s); } | 4214 | _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return str().compare(__s); } |
| 4217 | 4215 | ||
| 4218 | _LIBCPP_HIDE_FROM_ABI void swap(sub_match& __s) | 4216 | _LIBCPP_HIDE_FROM_ABI void swap(sub_match& __s) _NOEXCEPT_(__is_nothrow_swappable_v<_BidirectionalIterator>) { |
| 4219 | #ifndef _LIBCPP_CXX03_LANG | ||
| 4220 | _NOEXCEPT(__is_nothrow_swappable<_BidirectionalIterator>::value) | ||
| 4221 | #endif // _LIBCPP_CXX03_LANG | ||
| 4222 | { | ||
| 4223 | this->pair<_BidirectionalIterator, _BidirectionalIterator>::swap(__s); | 4217 | this->pair<_BidirectionalIterator, _BidirectionalIterator>::swap(__s); |
| 4224 | std::swap(matched, __s.matched); | 4218 | std::swap(matched, __s.matched); |
| 4225 | } | 4219 | } |
| ... | @@ -4583,7 +4577,7 @@ public: | ... | @@ -4583,7 +4577,7 @@ public: |
| 4583 | // size: | 4577 | // size: |
| 4584 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); } | 4578 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); } |
| 4585 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); } | 4579 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); } |
| 4586 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | 4580 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } |
| 4587 | 4581 | ||
| 4588 | // element access: | 4582 | // element access: |
| 4589 | _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const { | 4583 | _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const { |
| ... | @@ -4701,6 +4695,9 @@ private: | ... | @@ -4701,6 +4695,9 @@ private: |
| 4701 | 4695 | ||
| 4702 | template <class, class> | 4696 | template <class, class> |
| 4703 | friend class __lookahead; | 4697 | friend class __lookahead; |
| 4698 | |||
| 4699 | template <class, class, class> | ||
| 4700 | friend class regex_iterator; | ||
| 4704 | }; | 4701 | }; |
| 4705 | 4702 | ||
| 4706 | template <class _BidirectionalIterator, class _Allocator> | 4703 | template <class _BidirectionalIterator, class _Allocator> |
| ... | @@ -5411,7 +5408,9 @@ template <class _BidirectionalIterator, class _CharT, class _Traits> | ... | @@ -5411,7 +5408,9 @@ template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5411 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>& | 5408 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>& |
| 5412 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { | 5409 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { |
| 5413 | __flags_ |= regex_constants::__no_update_pos; | 5410 | __flags_ |= regex_constants::__no_update_pos; |
| 5414 | _BidirectionalIterator __start = __match_[0].second; | 5411 | _BidirectionalIterator __start = __match_[0].second; |
| 5412 | _BidirectionalIterator __prefix_start = __start; | ||
| 5413 | |||
| 5415 | if (__match_[0].first == __match_[0].second) { | 5414 | if (__match_[0].first == __match_[0].second) { |
| 5416 | if (__start == __end_) { | 5415 | if (__start == __end_) { |
| 5417 | __match_ = value_type(); | 5416 | __match_ = value_type(); |
| ... | @@ -5425,9 +5424,21 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { | ... | @@ -5425,9 +5424,21 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { |
| 5425 | else | 5424 | else |
| 5426 | ++__start; | 5425 | ++__start; |
| 5427 | } | 5426 | } |
| 5427 | |||
| 5428 | __flags_ |= regex_constants::match_prev_avail; | 5428 | __flags_ |= regex_constants::match_prev_avail; |
| 5429 | if (!std::regex_search(__start, __end_, __match_, *__pregex_, __flags_)) | 5429 | if (!std::regex_search(__start, __end_, __match_, *__pregex_, __flags_)) { |
| 5430 | __match_ = value_type(); | 5430 | __match_ = value_type(); |
| 5431 | |||
| 5432 | } else { | ||
| 5433 | // The Standard mandates that if `regex_search` returns true ([re.regiter.incr]), "`match.prefix().first` shall be | ||
| 5434 | // equal to the previous value of `match[0].second`... It is unspecified how the implementation makes these | ||
| 5435 | // adjustments." The adjustment is necessary if we incremented `__start` above (the branch that deals with | ||
| 5436 | // zero-length matches). | ||
| 5437 | auto& __prefix = __match_.__prefix_; | ||
| 5438 | __prefix.first = __prefix_start; | ||
| 5439 | __prefix.matched = __prefix.first != __prefix.second; | ||
| 5440 | } | ||
| 5441 | |||
| 5431 | return *this; | 5442 | return *this; |
| 5432 | } | 5443 | } |
| 5433 | 5444 |
lib/libcxx/include/scoped_allocator+15-17| ... | @@ -109,7 +109,6 @@ template <class OuterA1, class OuterA2, class... InnerAllocs> | ... | @@ -109,7 +109,6 @@ template <class OuterA1, class OuterA2, class... InnerAllocs> |
| 109 | 109 | ||
| 110 | */ | 110 | */ |
| 111 | 111 | ||
| 112 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 113 | #include <__config> | 112 | #include <__config> |
| 114 | #include <__memory/allocator_traits.h> | 113 | #include <__memory/allocator_traits.h> |
| 115 | #include <__memory/uses_allocator_construction.h> | 114 | #include <__memory/uses_allocator_construction.h> |
| ... | @@ -314,7 +313,7 @@ false_type __has_outer_allocator_test(const volatile _Alloc& __a); | ... | @@ -314,7 +313,7 @@ false_type __has_outer_allocator_test(const volatile _Alloc& __a); |
| 314 | 313 | ||
| 315 | template <class _Alloc> | 314 | template <class _Alloc> |
| 316 | struct __has_outer_allocator | 315 | struct __has_outer_allocator |
| 317 | : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>())) >::type {}; | 316 | : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))>::type {}; |
| 318 | 317 | ||
| 319 | template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value> | 318 | template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value> |
| 320 | struct __outermost { | 319 | struct __outermost { |
| ... | @@ -334,12 +333,12 @@ struct __outermost<_Alloc, true> { | ... | @@ -334,12 +333,12 @@ struct __outermost<_Alloc, true> { |
| 334 | template <class _OuterAlloc, class... _InnerAllocs> | 333 | template <class _OuterAlloc, class... _InnerAllocs> |
| 335 | class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> | 334 | class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> |
| 336 | : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> { | 335 | : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> { |
| 337 | typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base; | 336 | typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base; |
| 338 | typedef allocator_traits<_OuterAlloc> _OuterTraits; | 337 | typedef allocator_traits<_OuterAlloc> _OuterTraits; |
| 339 | 338 | ||
| 340 | public: | 339 | public: |
| 341 | typedef _OuterAlloc outer_allocator_type; | 340 | typedef _OuterAlloc outer_allocator_type; |
| 342 | typedef typename base::inner_allocator_type inner_allocator_type; | 341 | typedef typename _Base::inner_allocator_type inner_allocator_type; |
| 343 | typedef typename _OuterTraits::size_type size_type; | 342 | typedef typename _OuterTraits::size_type size_type; |
| 344 | typedef typename _OuterTraits::difference_type difference_type; | 343 | typedef typename _OuterTraits::difference_type difference_type; |
| 345 | typedef typename _OuterTraits::pointer pointer; | 344 | typedef typename _OuterTraits::pointer pointer; |
| ... | @@ -365,35 +364,35 @@ public: | ... | @@ -365,35 +364,35 @@ public: |
| 365 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> | 364 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> |
| 366 | _LIBCPP_HIDE_FROM_ABI | 365 | _LIBCPP_HIDE_FROM_ABI |
| 367 | scoped_allocator_adaptor(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT | 366 | scoped_allocator_adaptor(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT |
| 368 | : base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {} | 367 | : _Base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {} |
| 369 | // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default; | 368 | // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default; |
| 370 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0> | 369 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0> |
| 371 | _LIBCPP_HIDE_FROM_ABI | 370 | _LIBCPP_HIDE_FROM_ABI |
| 372 | scoped_allocator_adaptor(const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT | 371 | scoped_allocator_adaptor(const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT |
| 373 | : base(__other) {} | 372 | : _Base(__other) {} |
| 374 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> | 373 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> |
| 375 | _LIBCPP_HIDE_FROM_ABI | 374 | _LIBCPP_HIDE_FROM_ABI |
| 376 | scoped_allocator_adaptor(scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT | 375 | scoped_allocator_adaptor(scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT |
| 377 | : base(std::move(__other)) {} | 376 | : _Base(std::move(__other)) {} |
| 378 | 377 | ||
| 379 | // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; | 378 | // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; |
| 380 | // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; | 379 | // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; |
| 381 | // ~scoped_allocator_adaptor() = default; | 380 | // ~scoped_allocator_adaptor() = default; |
| 382 | 381 | ||
| 383 | _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return base::inner_allocator(); } | 382 | _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return _Base::inner_allocator(); } |
| 384 | _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT { | 383 | _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT { |
| 385 | return base::inner_allocator(); | 384 | return _Base::inner_allocator(); |
| 386 | } | 385 | } |
| 387 | 386 | ||
| 388 | _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return base::outer_allocator(); } | 387 | _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return _Base::outer_allocator(); } |
| 389 | _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT { | 388 | _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT { |
| 390 | return base::outer_allocator(); | 389 | return _Base::outer_allocator(); |
| 391 | } | 390 | } |
| 392 | 391 | ||
| 393 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) { | 392 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) { |
| 394 | return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n); | 393 | return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n); |
| 395 | } | 394 | } |
| 396 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) { | 395 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) { |
| 397 | return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint); | 396 | return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint); |
| 398 | } | 397 | } |
| 399 | 398 | ||
| ... | @@ -472,13 +471,12 @@ public: | ... | @@ -472,13 +471,12 @@ public: |
| 472 | } | 471 | } |
| 473 | 472 | ||
| 474 | _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT { | 473 | _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT { |
| 475 | return base::select_on_container_copy_construction(); | 474 | return _Base::select_on_container_copy_construction(); |
| 476 | } | 475 | } |
| 477 | 476 | ||
| 478 | private: | 477 | private: |
| 479 | template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> | 478 | _LIBCPP_HIDE_FROM_ABI explicit scoped_allocator_adaptor( |
| 480 | _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor(_OuterA2&& __o, const inner_allocator_type& __i) _NOEXCEPT | 479 | outer_allocator_type&& __o, inner_allocator_type&& __i) _NOEXCEPT : _Base(std::move(__o), std::move(__i)) {} |
| 481 | : base(std::forward<_OuterA2>(__o), __i) {} | ||
| 482 | 480 | ||
| 483 | template <class _Tp, class... _Args> | 481 | template <class _Tp, class... _Args> |
| 484 | _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 0>, _Tp* __p, _Args&&... __args) { | 482 | _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 0>, _Tp* __p, _Args&&... __args) { |
lib/libcxx/include/semaphore+40-41| ... | @@ -47,31 +47,28 @@ using binary_semaphore = counting_semaphore<1>; | ... | @@ -47,31 +47,28 @@ using binary_semaphore = counting_semaphore<1>; |
| 47 | 47 | ||
| 48 | #include <__config> | 48 | #include <__config> |
| 49 | 49 | ||
| 50 | #ifdef _LIBCPP_HAS_NO_THREADS | 50 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 51 | # error "<semaphore> is not supported since libc++ has been configured without support for threads." | 51 | |
| 52 | #endif | 52 | # include <__assert> |
| 53 | 53 | # include <__atomic/atomic_base.h> | |
| 54 | #include <__assert> // all public C++ headers provide the assertion handler | 54 | # include <__atomic/atomic_sync.h> |
| 55 | #include <__atomic/atomic_base.h> | 55 | # include <__atomic/memory_order.h> |
| 56 | #include <__atomic/atomic_sync.h> | 56 | # include <__chrono/time_point.h> |
| 57 | #include <__atomic/memory_order.h> | 57 | # include <__thread/poll_with_backoff.h> |
| 58 | #include <__availability> | 58 | # include <__thread/support.h> |
| 59 | #include <__chrono/time_point.h> | 59 | # include <__thread/timed_backoff_policy.h> |
| 60 | #include <__thread/poll_with_backoff.h> | 60 | # include <cstddef> |
| 61 | #include <__thread/timed_backoff_policy.h> | 61 | # include <limits> |
| 62 | #include <__threading_support> | 62 | # include <version> |
| 63 | #include <cstddef> | 63 | |
| 64 | #include <limits> | 64 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 65 | #include <version> | 65 | # pragma GCC system_header |
| 66 | 66 | # endif | |
| 67 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 68 | # pragma GCC system_header | ||
| 69 | #endif | ||
| 70 | 67 | ||
| 71 | _LIBCPP_PUSH_MACROS | 68 | _LIBCPP_PUSH_MACROS |
| 72 | #include <__undef_macros> | 69 | # include <__undef_macros> |
| 73 | 70 | ||
| 74 | #if _LIBCPP_STD_VER >= 14 | 71 | # if _LIBCPP_STD_VER >= 14 |
| 75 | 72 | ||
| 76 | _LIBCPP_BEGIN_NAMESPACE_STD | 73 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 77 | 74 | ||
| ... | @@ -83,7 +80,7 @@ functions. It avoids contention against users' own use of those facilities. | ... | @@ -83,7 +80,7 @@ functions. It avoids contention against users' own use of those facilities. |
| 83 | 80 | ||
| 84 | */ | 81 | */ |
| 85 | 82 | ||
| 86 | # define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) | 83 | # define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) |
| 87 | 84 | ||
| 88 | class __atomic_semaphore_base { | 85 | class __atomic_semaphore_base { |
| 89 | __atomic_base<ptrdiff_t> __a_; | 86 | __atomic_base<ptrdiff_t> __a_; |
| ... | @@ -94,42 +91,40 @@ public: | ... | @@ -94,42 +91,40 @@ public: |
| 94 | auto __old = __a_.fetch_add(__update, memory_order_release); | 91 | auto __old = __a_.fetch_add(__update, memory_order_release); |
| 95 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 92 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 96 | __update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value"); | 93 | __update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value"); |
| 97 | 94 | if (__old == 0) { | |
| 98 | if (__old > 0) { | ||
| 99 | // Nothing to do | ||
| 100 | } else if (__update > 1) | ||
| 101 | __a_.notify_all(); | 95 | __a_.notify_all(); |
| 102 | else | 96 | } |
| 103 | __a_.notify_one(); | ||
| 104 | } | 97 | } |
| 105 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() { | 98 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() { |
| 106 | auto const __test_fn = [this]() -> bool { | 99 | std::__atomic_wait_unless( |
| 107 | auto __old = __a_.load(memory_order_relaxed); | 100 | __a_, [this](ptrdiff_t& __old) { return __try_acquire_impl(__old); }, memory_order_relaxed); |
| 108 | return (__old != 0) && __a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed); | ||
| 109 | }; | ||
| 110 | __cxx_atomic_wait(&__a_.__a_, __test_fn); | ||
| 111 | } | 101 | } |
| 112 | template <class _Rep, class _Period> | 102 | template <class _Rep, class _Period> |
| 113 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool | 103 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool |
| 114 | try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { | 104 | try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { |
| 115 | if (__rel_time == chrono::duration<_Rep, _Period>::zero()) | 105 | if (__rel_time == chrono::duration<_Rep, _Period>::zero()) |
| 116 | return try_acquire(); | 106 | return try_acquire(); |
| 117 | auto const __test_fn = [this]() { return try_acquire(); }; | 107 | auto const __poll_fn = [this]() { return try_acquire(); }; |
| 118 | return std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time); | 108 | return std::__libcpp_thread_poll_with_backoff(__poll_fn, __libcpp_timed_backoff_policy(), __rel_time); |
| 119 | } | 109 | } |
| 120 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool try_acquire() { | 110 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool try_acquire() { |
| 121 | auto __old = __a_.load(memory_order_acquire); | 111 | auto __old = __a_.load(memory_order_relaxed); |
| 112 | return __try_acquire_impl(__old); | ||
| 113 | } | ||
| 114 | |||
| 115 | private: | ||
| 116 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __try_acquire_impl(ptrdiff_t& __old) { | ||
| 122 | while (true) { | 117 | while (true) { |
| 123 | if (__old == 0) | 118 | if (__old == 0) |
| 124 | return false; | 119 | return false; |
| 125 | if (__a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) | 120 | if (__a_.compare_exchange_weak(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) |
| 126 | return true; | 121 | return true; |
| 127 | } | 122 | } |
| 128 | } | 123 | } |
| 129 | }; | 124 | }; |
| 130 | 125 | ||
| 131 | template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> | 126 | template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> |
| 132 | class counting_semaphore { | 127 | class _LIBCPP_DEPRECATED_ATOMIC_SYNC counting_semaphore { |
| 133 | __atomic_semaphore_base __semaphore_; | 128 | __atomic_semaphore_base __semaphore_; |
| 134 | 129 | ||
| 135 | public: | 130 | public: |
| ... | @@ -174,14 +169,18 @@ public: | ... | @@ -174,14 +169,18 @@ public: |
| 174 | } | 169 | } |
| 175 | }; | 170 | }; |
| 176 | 171 | ||
| 177 | using binary_semaphore = counting_semaphore<1>; | 172 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 173 | using binary_semaphore _LIBCPP_DEPRECATED_ATOMIC_SYNC = counting_semaphore<1>; | ||
| 174 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 178 | 175 | ||
| 179 | _LIBCPP_END_NAMESPACE_STD | 176 | _LIBCPP_END_NAMESPACE_STD |
| 180 | 177 | ||
| 181 | #endif // _LIBCPP_STD_VER >= 14 | 178 | # endif // _LIBCPP_STD_VER >= 14 |
| 182 | 179 | ||
| 183 | _LIBCPP_POP_MACROS | 180 | _LIBCPP_POP_MACROS |
| 184 | 181 | ||
| 182 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 183 | |||
| 185 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 184 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 186 | # include <atomic> | 185 | # include <atomic> |
| 187 | #endif | 186 | #endif |
lib/libcxx/include/set+46-50| ... | @@ -515,8 +515,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -515,8 +515,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 515 | #include <__algorithm/equal.h> | 515 | #include <__algorithm/equal.h> |
| 516 | #include <__algorithm/lexicographical_compare.h> | 516 | #include <__algorithm/lexicographical_compare.h> |
| 517 | #include <__algorithm/lexicographical_compare_three_way.h> | 517 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 518 | #include <__assert> // all public C++ headers provide the assertion handler | 518 | #include <__assert> |
| 519 | #include <__availability> | ||
| 520 | #include <__config> | 519 | #include <__config> |
| 521 | #include <__functional/is_transparent.h> | 520 | #include <__functional/is_transparent.h> |
| 522 | #include <__functional/operations.h> | 521 | #include <__functional/operations.h> |
| ... | @@ -572,16 +571,14 @@ public: | ... | @@ -572,16 +571,14 @@ public: |
| 572 | typedef value_type& reference; | 571 | typedef value_type& reference; |
| 573 | typedef const value_type& const_reference; | 572 | typedef const value_type& const_reference; |
| 574 | 573 | ||
| 575 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 574 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| 576 | "Allocator::value_type must be same type as value_type"); | 575 | "Allocator::value_type must be same type as value_type"); |
| 577 | 576 | ||
| 578 | private: | 577 | private: |
| 579 | typedef __tree<value_type, value_compare, allocator_type> __base; | 578 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 580 | typedef allocator_traits<allocator_type> __alloc_traits; | 579 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 581 | 580 | ||
| 582 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | 581 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 583 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 584 | "original allocator"); | ||
| 585 | 582 | ||
| 586 | __base __tree_; | 583 | __base __tree_; |
| 587 | 584 | ||
| ... | @@ -660,7 +657,7 @@ public: | ... | @@ -660,7 +657,7 @@ public: |
| 660 | } | 657 | } |
| 661 | 658 | ||
| 662 | #ifndef _LIBCPP_CXX03_LANG | 659 | #ifndef _LIBCPP_CXX03_LANG |
| 663 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) | 660 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) |
| 664 | : __tree_(std::move(__s.__tree_)) {} | 661 | : __tree_(std::move(__s.__tree_)) {} |
| 665 | #endif // _LIBCPP_CXX03_LANG | 662 | #endif // _LIBCPP_CXX03_LANG |
| 666 | 663 | ||
| ... | @@ -693,7 +690,7 @@ public: | ... | @@ -693,7 +690,7 @@ public: |
| 693 | return *this; | 690 | return *this; |
| 694 | } | 691 | } |
| 695 | 692 | ||
| 696 | _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { | 693 | _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) noexcept(is_nothrow_move_assignable<__base>::value) { |
| 697 | __tree_ = std::move(__s.__tree_); | 694 | __tree_ = std::move(__s.__tree_); |
| 698 | return *this; | 695 | return *this; |
| 699 | } | 696 | } |
| ... | @@ -716,7 +713,7 @@ public: | ... | @@ -716,7 +713,7 @@ public: |
| 716 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 713 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 717 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 714 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 718 | 715 | ||
| 719 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 716 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 720 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 717 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 721 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 718 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 722 | 719 | ||
| ... | @@ -813,9 +810,7 @@ public: | ... | @@ -813,9 +810,7 @@ public: |
| 813 | } | 810 | } |
| 814 | #endif | 811 | #endif |
| 815 | 812 | ||
| 816 | _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) { | 813 | _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); } |
| 817 | __tree_.swap(__s.__tree_); | ||
| 818 | } | ||
| 819 | 814 | ||
| 820 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); } | 815 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); } |
| 821 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); } | 816 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); } |
| ... | @@ -825,11 +820,11 @@ public: | ... | @@ -825,11 +820,11 @@ public: |
| 825 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 820 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 826 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 821 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 827 | #if _LIBCPP_STD_VER >= 14 | 822 | #if _LIBCPP_STD_VER >= 14 |
| 828 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 823 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 829 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 824 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 830 | return __tree_.find(__k); | 825 | return __tree_.find(__k); |
| 831 | } | 826 | } |
| 832 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 827 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 833 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 828 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 834 | return __tree_.find(__k); | 829 | return __tree_.find(__k); |
| 835 | } | 830 | } |
| ... | @@ -837,7 +832,7 @@ public: | ... | @@ -837,7 +832,7 @@ public: |
| 837 | 832 | ||
| 838 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } | 833 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } |
| 839 | #if _LIBCPP_STD_VER >= 14 | 834 | #if _LIBCPP_STD_VER >= 14 |
| 840 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 835 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 841 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 836 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 842 | return __tree_.__count_multi(__k); | 837 | return __tree_.__count_multi(__k); |
| 843 | } | 838 | } |
| ... | @@ -845,7 +840,7 @@ public: | ... | @@ -845,7 +840,7 @@ public: |
| 845 | 840 | ||
| 846 | #if _LIBCPP_STD_VER >= 20 | 841 | #if _LIBCPP_STD_VER >= 20 |
| 847 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 842 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 848 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 843 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 849 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 844 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 850 | return find(__k) != end(); | 845 | return find(__k) != end(); |
| 851 | } | 846 | } |
| ... | @@ -854,12 +849,12 @@ public: | ... | @@ -854,12 +849,12 @@ public: |
| 854 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 849 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 855 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 850 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 856 | #if _LIBCPP_STD_VER >= 14 | 851 | #if _LIBCPP_STD_VER >= 14 |
| 857 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 852 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 858 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 853 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 859 | return __tree_.lower_bound(__k); | 854 | return __tree_.lower_bound(__k); |
| 860 | } | 855 | } |
| 861 | 856 | ||
| 862 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 857 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 863 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 858 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 864 | return __tree_.lower_bound(__k); | 859 | return __tree_.lower_bound(__k); |
| 865 | } | 860 | } |
| ... | @@ -868,11 +863,11 @@ public: | ... | @@ -868,11 +863,11 @@ public: |
| 868 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 863 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 869 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 864 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 870 | #if _LIBCPP_STD_VER >= 14 | 865 | #if _LIBCPP_STD_VER >= 14 |
| 871 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 866 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 872 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 867 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 873 | return __tree_.upper_bound(__k); | 868 | return __tree_.upper_bound(__k); |
| 874 | } | 869 | } |
| 875 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 870 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 876 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 871 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 877 | return __tree_.upper_bound(__k); | 872 | return __tree_.upper_bound(__k); |
| 878 | } | 873 | } |
| ... | @@ -885,11 +880,11 @@ public: | ... | @@ -885,11 +880,11 @@ public: |
| 885 | return __tree_.__equal_range_unique(__k); | 880 | return __tree_.__equal_range_unique(__k); |
| 886 | } | 881 | } |
| 887 | #if _LIBCPP_STD_VER >= 14 | 882 | #if _LIBCPP_STD_VER >= 14 |
| 888 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 883 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 889 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 884 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 890 | return __tree_.__equal_range_multi(__k); | 885 | return __tree_.__equal_range_multi(__k); |
| 891 | } | 886 | } |
| 892 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 887 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 893 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 888 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 894 | return __tree_.__equal_range_multi(__k); | 889 | return __tree_.__equal_range_multi(__k); |
| 895 | } | 890 | } |
| ... | @@ -927,13 +922,15 @@ template <class _InputIterator, | ... | @@ -927,13 +922,15 @@ template <class _InputIterator, |
| 927 | class _Allocator, | 922 | class _Allocator, |
| 928 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 923 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 929 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 924 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 930 | set(_InputIterator, _InputIterator, _Allocator) | 925 | set(_InputIterator, |
| 931 | -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; | 926 | _InputIterator, |
| 927 | _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; | ||
| 932 | 928 | ||
| 933 | # if _LIBCPP_STD_VER >= 23 | 929 | # if _LIBCPP_STD_VER >= 23 |
| 934 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 930 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 935 | set(from_range_t, _Range&&, _Allocator) | 931 | set(from_range_t, |
| 936 | -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; | 932 | _Range&&, |
| 933 | _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; | ||
| 937 | # endif | 934 | # endif |
| 938 | 935 | ||
| 939 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 936 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| ... | @@ -996,8 +993,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, | ... | @@ -996,8 +993,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, |
| 996 | template <class _Key, class _Allocator> | 993 | template <class _Key, class _Allocator> |
| 997 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> | 994 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> |
| 998 | operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) { | 995 | operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) { |
| 999 | return std::lexicographical_compare_three_way( | 996 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1000 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>); | ||
| 1001 | } | 997 | } |
| 1002 | 998 | ||
| 1003 | #endif // _LIBCPP_STD_VER <= 17 | 999 | #endif // _LIBCPP_STD_VER <= 17 |
| ... | @@ -1029,16 +1025,14 @@ public: | ... | @@ -1029,16 +1025,14 @@ public: |
| 1029 | typedef value_type& reference; | 1025 | typedef value_type& reference; |
| 1030 | typedef const value_type& const_reference; | 1026 | typedef const value_type& const_reference; |
| 1031 | 1027 | ||
| 1032 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 1028 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| 1033 | "Allocator::value_type must be same type as value_type"); | 1029 | "Allocator::value_type must be same type as value_type"); |
| 1034 | 1030 | ||
| 1035 | private: | 1031 | private: |
| 1036 | typedef __tree<value_type, value_compare, allocator_type> __base; | 1032 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 1037 | typedef allocator_traits<allocator_type> __alloc_traits; | 1033 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1038 | 1034 | ||
| 1039 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | 1035 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 1040 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 1041 | "original allocator"); | ||
| 1042 | 1036 | ||
| 1043 | __base __tree_; | 1037 | __base __tree_; |
| 1044 | 1038 | ||
| ... | @@ -1120,7 +1114,7 @@ public: | ... | @@ -1120,7 +1114,7 @@ public: |
| 1120 | } | 1114 | } |
| 1121 | 1115 | ||
| 1122 | #ifndef _LIBCPP_CXX03_LANG | 1116 | #ifndef _LIBCPP_CXX03_LANG |
| 1123 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) | 1117 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) |
| 1124 | : __tree_(std::move(__s.__tree_)) {} | 1118 | : __tree_(std::move(__s.__tree_)) {} |
| 1125 | 1119 | ||
| 1126 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); | 1120 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); |
| ... | @@ -1176,7 +1170,7 @@ public: | ... | @@ -1176,7 +1170,7 @@ public: |
| 1176 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 1170 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1177 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1171 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1178 | 1172 | ||
| 1179 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 1173 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 1180 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 1174 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1181 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 1175 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1182 | 1176 | ||
| ... | @@ -1271,7 +1265,7 @@ public: | ... | @@ -1271,7 +1265,7 @@ public: |
| 1271 | } | 1265 | } |
| 1272 | #endif | 1266 | #endif |
| 1273 | 1267 | ||
| 1274 | _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) { | 1268 | _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { |
| 1275 | __tree_.swap(__s.__tree_); | 1269 | __tree_.swap(__s.__tree_); |
| 1276 | } | 1270 | } |
| 1277 | 1271 | ||
| ... | @@ -1283,11 +1277,11 @@ public: | ... | @@ -1283,11 +1277,11 @@ public: |
| 1283 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 1277 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1284 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 1278 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1285 | #if _LIBCPP_STD_VER >= 14 | 1279 | #if _LIBCPP_STD_VER >= 14 |
| 1286 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1280 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1287 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1281 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1288 | return __tree_.find(__k); | 1282 | return __tree_.find(__k); |
| 1289 | } | 1283 | } |
| 1290 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1284 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1291 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1285 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1292 | return __tree_.find(__k); | 1286 | return __tree_.find(__k); |
| 1293 | } | 1287 | } |
| ... | @@ -1295,7 +1289,7 @@ public: | ... | @@ -1295,7 +1289,7 @@ public: |
| 1295 | 1289 | ||
| 1296 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } | 1290 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } |
| 1297 | #if _LIBCPP_STD_VER >= 14 | 1291 | #if _LIBCPP_STD_VER >= 14 |
| 1298 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1292 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1299 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1293 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1300 | return __tree_.__count_multi(__k); | 1294 | return __tree_.__count_multi(__k); |
| 1301 | } | 1295 | } |
| ... | @@ -1303,7 +1297,7 @@ public: | ... | @@ -1303,7 +1297,7 @@ public: |
| 1303 | 1297 | ||
| 1304 | #if _LIBCPP_STD_VER >= 20 | 1298 | #if _LIBCPP_STD_VER >= 20 |
| 1305 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1299 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1306 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1300 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1307 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1301 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1308 | return find(__k) != end(); | 1302 | return find(__k) != end(); |
| 1309 | } | 1303 | } |
| ... | @@ -1312,12 +1306,12 @@ public: | ... | @@ -1312,12 +1306,12 @@ public: |
| 1312 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 1306 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 1313 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 1307 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 1314 | #if _LIBCPP_STD_VER >= 14 | 1308 | #if _LIBCPP_STD_VER >= 14 |
| 1315 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1309 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1316 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 1310 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1317 | return __tree_.lower_bound(__k); | 1311 | return __tree_.lower_bound(__k); |
| 1318 | } | 1312 | } |
| 1319 | 1313 | ||
| 1320 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1314 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1321 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 1315 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1322 | return __tree_.lower_bound(__k); | 1316 | return __tree_.lower_bound(__k); |
| 1323 | } | 1317 | } |
| ... | @@ -1326,11 +1320,11 @@ public: | ... | @@ -1326,11 +1320,11 @@ public: |
| 1326 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 1320 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 1327 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 1321 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 1328 | #if _LIBCPP_STD_VER >= 14 | 1322 | #if _LIBCPP_STD_VER >= 14 |
| 1329 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1323 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1330 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 1324 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1331 | return __tree_.upper_bound(__k); | 1325 | return __tree_.upper_bound(__k); |
| 1332 | } | 1326 | } |
| 1333 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1327 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1334 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 1328 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1335 | return __tree_.upper_bound(__k); | 1329 | return __tree_.upper_bound(__k); |
| 1336 | } | 1330 | } |
| ... | @@ -1343,11 +1337,11 @@ public: | ... | @@ -1343,11 +1337,11 @@ public: |
| 1343 | return __tree_.__equal_range_multi(__k); | 1337 | return __tree_.__equal_range_multi(__k); |
| 1344 | } | 1338 | } |
| 1345 | #if _LIBCPP_STD_VER >= 14 | 1339 | #if _LIBCPP_STD_VER >= 14 |
| 1346 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1340 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1347 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1341 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1348 | return __tree_.__equal_range_multi(__k); | 1342 | return __tree_.__equal_range_multi(__k); |
| 1349 | } | 1343 | } |
| 1350 | template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> | 1344 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1351 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1345 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1352 | return __tree_.__equal_range_multi(__k); | 1346 | return __tree_.__equal_range_multi(__k); |
| 1353 | } | 1347 | } |
| ... | @@ -1379,8 +1373,9 @@ template <class _Key, | ... | @@ -1379,8 +1373,9 @@ template <class _Key, |
| 1379 | class _Allocator = allocator<_Key>, | 1373 | class _Allocator = allocator<_Key>, |
| 1380 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | 1374 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, |
| 1381 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | 1375 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> |
| 1382 | multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) | 1376 | multiset(initializer_list<_Key>, |
| 1383 | -> multiset<_Key, _Compare, _Allocator>; | 1377 | _Compare = _Compare(), |
| 1378 | _Allocator = _Allocator()) -> multiset<_Key, _Compare, _Allocator>; | ||
| 1384 | 1379 | ||
| 1385 | template <class _InputIterator, | 1380 | template <class _InputIterator, |
| 1386 | class _Allocator, | 1381 | class _Allocator, |
| ... | @@ -1391,8 +1386,9 @@ multiset(_InputIterator, _InputIterator, _Allocator) | ... | @@ -1391,8 +1386,9 @@ multiset(_InputIterator, _InputIterator, _Allocator) |
| 1391 | 1386 | ||
| 1392 | # if _LIBCPP_STD_VER >= 23 | 1387 | # if _LIBCPP_STD_VER >= 23 |
| 1393 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1388 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1394 | multiset(from_range_t, _Range&&, _Allocator) | 1389 | multiset(from_range_t, |
| 1395 | -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; | 1390 | _Range&&, |
| 1391 | _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; | ||
| 1396 | # endif | 1392 | # endif |
| 1397 | 1393 | ||
| 1398 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1394 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| ... | @@ -1457,7 +1453,7 @@ template <class _Key, class _Allocator> | ... | @@ -1457,7 +1453,7 @@ template <class _Key, class _Allocator> |
| 1457 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> | 1453 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> |
| 1458 | operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { | 1454 | operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { |
| 1459 | return std::lexicographical_compare_three_way( | 1455 | return std::lexicographical_compare_three_way( |
| 1460 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>); | 1456 | __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); |
| 1461 | } | 1457 | } |
| 1462 | 1458 | ||
| 1463 | #endif // _LIBCPP_STD_VER <= 17 | 1459 | #endif // _LIBCPP_STD_VER <= 17 |
lib/libcxx/include/shared_mutex+26-28| ... | @@ -124,33 +124,29 @@ template <class Mutex> | ... | @@ -124,33 +124,29 @@ template <class Mutex> |
| 124 | 124 | ||
| 125 | #include <__config> | 125 | #include <__config> |
| 126 | 126 | ||
| 127 | # ifdef _LIBCPP_HAS_NO_THREADS | 127 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 128 | # error "<shared_mutex> is not supported since libc++ has been configured without support for threads." | 128 | |
| 129 | # endif | 129 | # include <__chrono/duration.h> |
| 130 | 130 | # include <__chrono/steady_clock.h> | |
| 131 | #include <__assert> // all public C++ headers provide the assertion handler | 131 | # include <__chrono/time_point.h> |
| 132 | #include <__availability> | 132 | # include <__condition_variable/condition_variable.h> |
| 133 | #include <__chrono/duration.h> | 133 | # include <__memory/addressof.h> |
| 134 | #include <__chrono/steady_clock.h> | 134 | # include <__mutex/mutex.h> |
| 135 | #include <__chrono/time_point.h> | 135 | # include <__mutex/tag_types.h> |
| 136 | #include <__condition_variable/condition_variable.h> | 136 | # include <__mutex/unique_lock.h> |
| 137 | #include <__memory/addressof.h> | 137 | # include <__system_error/system_error.h> |
| 138 | #include <__mutex/mutex.h> | 138 | # include <__utility/swap.h> |
| 139 | #include <__mutex/tag_types.h> | 139 | # include <cerrno> |
| 140 | #include <__mutex/unique_lock.h> | 140 | # include <version> |
| 141 | #include <__system_error/system_error.h> | ||
| 142 | #include <__utility/swap.h> | ||
| 143 | #include <cerrno> | ||
| 144 | #include <version> | ||
| 145 | 141 | ||
| 146 | _LIBCPP_PUSH_MACROS | 142 | _LIBCPP_PUSH_MACROS |
| 147 | #include <__undef_macros> | 143 | # include <__undef_macros> |
| 148 | 144 | ||
| 149 | #if _LIBCPP_STD_VER >= 14 | 145 | # if _LIBCPP_STD_VER >= 14 |
| 150 | 146 | ||
| 151 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 147 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 152 | # pragma GCC system_header | 148 | # pragma GCC system_header |
| 153 | # endif | 149 | # endif |
| 154 | 150 | ||
| 155 | _LIBCPP_BEGIN_NAMESPACE_STD | 151 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 156 | 152 | ||
| ... | @@ -183,7 +179,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { | ... | @@ -183,7 +179,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { |
| 183 | // native_handle_type native_handle(); // See 30.2.3 | 179 | // native_handle_type native_handle(); // See 30.2.3 |
| 184 | }; | 180 | }; |
| 185 | 181 | ||
| 186 | # if _LIBCPP_STD_VER >= 17 | 182 | # if _LIBCPP_STD_VER >= 17 |
| 187 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex { | 183 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex { |
| 188 | __shared_mutex_base __base_; | 184 | __shared_mutex_base __base_; |
| 189 | 185 | ||
| ... | @@ -220,10 +216,10 @@ public: | ... | @@ -220,10 +216,10 @@ public: |
| 220 | // typedef __shared_mutex_base::native_handle_type native_handle_type; | 216 | // typedef __shared_mutex_base::native_handle_type native_handle_type; |
| 221 | // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } | 217 | // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } |
| 222 | }; | 218 | }; |
| 223 | # endif | 219 | # endif |
| 224 | 220 | ||
| 225 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) | 221 | class _LIBCPP_EXPORTED_FROM_ABI |
| 226 | shared_timed_mutex { | 222 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex { |
| 227 | __shared_mutex_base __base_; | 223 | __shared_mutex_base __base_; |
| 228 | 224 | ||
| 229 | public: | 225 | public: |
| ... | @@ -455,10 +451,12 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu | ... | @@ -455,10 +451,12 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu |
| 455 | 451 | ||
| 456 | _LIBCPP_END_NAMESPACE_STD | 452 | _LIBCPP_END_NAMESPACE_STD |
| 457 | 453 | ||
| 458 | #endif // _LIBCPP_STD_VER >= 14 | 454 | # endif // _LIBCPP_STD_VER >= 14 |
| 459 | 455 | ||
| 460 | _LIBCPP_POP_MACROS | 456 | _LIBCPP_POP_MACROS |
| 461 | 457 | ||
| 458 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 459 | |||
| 462 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 460 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 463 | # include <system_error> | 461 | # include <system_error> |
| 464 | #endif | 462 | #endif |
lib/libcxx/include/span+59-20| ... | @@ -18,6 +18,20 @@ namespace std { | ... | @@ -18,6 +18,20 @@ namespace std { |
| 18 | // constants | 18 | // constants |
| 19 | inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); | 19 | inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); |
| 20 | 20 | ||
| 21 | template<class T> | ||
| 22 | concept integral-constant-like = // exposition only, since C++26 | ||
| 23 | is_integral_v<decltype(T::value)> && | ||
| 24 | !is_same_v<bool, remove_const_t<decltype(T::value)>> && | ||
| 25 | convertible_to<T, decltype(T::value)> && | ||
| 26 | equality_comparable_with<T, decltype(T::value)> && | ||
| 27 | bool_constant<T() == T::value>::value && | ||
| 28 | bool_constant<static_cast<decltype(T::value)>(T()) == T::value>::value; | ||
| 29 | |||
| 30 | template<class T> | ||
| 31 | constexpr size_t maybe-static-ext = dynamic_extent; // exposition only, since C++26 | ||
| 32 | template<integral-constant-like T> | ||
| 33 | constexpr size_t maybe-static-ext<T> = {T::value}; | ||
| 34 | |||
| 21 | // [views.span], class template span | 35 | // [views.span], class template span |
| 22 | template <class ElementType, size_t Extent = dynamic_extent> | 36 | template <class ElementType, size_t Extent = dynamic_extent> |
| 23 | class span; | 37 | class span; |
| ... | @@ -110,7 +124,9 @@ private: | ... | @@ -110,7 +124,9 @@ private: |
| 110 | }; | 124 | }; |
| 111 | 125 | ||
| 112 | template<class It, class EndOrSize> | 126 | template<class It, class EndOrSize> |
| 113 | span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; | 127 | span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; // until C++26 |
| 128 | template<class It, class EndOrSize> | ||
| 129 | span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>, maybe-static-ext<EndOrSize>>; // since C++26 | ||
| 114 | 130 | ||
| 115 | template<class T, size_t N> | 131 | template<class T, size_t N> |
| 116 | span(T (&)[N]) -> span<T, N>; | 132 | span(T (&)[N]) -> span<T, N>; |
| ... | @@ -128,12 +144,16 @@ template<class R> | ... | @@ -128,12 +144,16 @@ template<class R> |
| 128 | 144 | ||
| 129 | */ | 145 | */ |
| 130 | 146 | ||
| 131 | #include <__assert> // all public C++ headers provide the assertion handler | 147 | #include <__assert> |
| 148 | #include <__concepts/convertible_to.h> | ||
| 149 | #include <__concepts/equality_comparable.h> | ||
| 132 | #include <__config> | 150 | #include <__config> |
| 151 | #include <__fwd/array.h> | ||
| 133 | #include <__fwd/span.h> | 152 | #include <__fwd/span.h> |
| 134 | #include <__iterator/bounded_iter.h> | 153 | #include <__iterator/bounded_iter.h> |
| 135 | #include <__iterator/concepts.h> | 154 | #include <__iterator/concepts.h> |
| 136 | #include <__iterator/iterator_traits.h> | 155 | #include <__iterator/iterator_traits.h> |
| 156 | #include <__iterator/reverse_iterator.h> | ||
| 137 | #include <__iterator/wrap_iter.h> | 157 | #include <__iterator/wrap_iter.h> |
| 138 | #include <__memory/pointer_traits.h> | 158 | #include <__memory/pointer_traits.h> |
| 139 | #include <__ranges/concepts.h> | 159 | #include <__ranges/concepts.h> |
| ... | @@ -141,13 +161,20 @@ template<class R> | ... | @@ -141,13 +161,20 @@ template<class R> |
| 141 | #include <__ranges/enable_borrowed_range.h> | 161 | #include <__ranges/enable_borrowed_range.h> |
| 142 | #include <__ranges/enable_view.h> | 162 | #include <__ranges/enable_view.h> |
| 143 | #include <__ranges/size.h> | 163 | #include <__ranges/size.h> |
| 164 | #include <__type_traits/integral_constant.h> | ||
| 165 | #include <__type_traits/is_array.h> | ||
| 166 | #include <__type_traits/is_const.h> | ||
| 144 | #include <__type_traits/is_convertible.h> | 167 | #include <__type_traits/is_convertible.h> |
| 168 | #include <__type_traits/is_integral.h> | ||
| 169 | #include <__type_traits/is_same.h> | ||
| 170 | #include <__type_traits/remove_const.h> | ||
| 171 | #include <__type_traits/remove_cv.h> | ||
| 145 | #include <__type_traits/remove_cvref.h> | 172 | #include <__type_traits/remove_cvref.h> |
| 146 | #include <__type_traits/remove_reference.h> | 173 | #include <__type_traits/remove_reference.h> |
| 147 | #include <__type_traits/type_identity.h> | 174 | #include <__type_traits/type_identity.h> |
| 148 | #include <__utility/forward.h> | 175 | #include <__utility/forward.h> |
| 149 | #include <array> // for array | ||
| 150 | #include <cstddef> // for byte | 176 | #include <cstddef> // for byte |
| 177 | #include <initializer_list> | ||
| 151 | #include <stdexcept> | 178 | #include <stdexcept> |
| 152 | #include <version> | 179 | #include <version> |
| 153 | 180 | ||
| ... | @@ -171,12 +198,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -171,12 +198,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 171 | 198 | ||
| 172 | #if _LIBCPP_STD_VER >= 20 | 199 | #if _LIBCPP_STD_VER >= 20 |
| 173 | 200 | ||
| 174 | template <class _Tp> | ||
| 175 | struct __is_std_array : false_type {}; | ||
| 176 | |||
| 177 | template <class _Tp, size_t _Sz> | ||
| 178 | struct __is_std_array<array<_Tp, _Sz>> : true_type {}; | ||
| 179 | |||
| 180 | template <class _Tp> | 201 | template <class _Tp> |
| 181 | struct __is_std_span : false_type {}; | 202 | struct __is_std_span : false_type {}; |
| 182 | 203 | ||
| ... | @@ -185,12 +206,12 @@ struct __is_std_span<span<_Tp, _Sz>> : true_type {}; | ... | @@ -185,12 +206,12 @@ struct __is_std_span<span<_Tp, _Sz>> : true_type {}; |
| 185 | 206 | ||
| 186 | template <class _Range, class _ElementType> | 207 | template <class _Range, class _ElementType> |
| 187 | concept __span_compatible_range = | 208 | concept __span_compatible_range = |
| 188 | ranges::contiguous_range<_Range> && // | 209 | !__is_std_span<remove_cvref_t<_Range>>::value && // |
| 189 | ranges::sized_range<_Range> && // | 210 | ranges::contiguous_range<_Range> && // |
| 190 | (ranges::borrowed_range<_Range> || is_const_v<_ElementType>)&& // | 211 | ranges::sized_range<_Range> && // |
| 191 | !__is_std_span<remove_cvref_t<_Range>>::value && // | 212 | (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && // |
| 192 | !__is_std_array<remove_cvref_t<_Range>>::value && // | 213 | !__is_std_array<remove_cvref_t<_Range>>::value && // |
| 193 | !is_array_v<remove_cvref_t<_Range>> && // | 214 | !is_array_v<remove_cvref_t<_Range>> && // |
| 194 | is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>; | 215 | is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>; |
| 195 | 216 | ||
| 196 | template <class _From, class _To> | 217 | template <class _From, class _To> |
| ... | @@ -273,7 +294,8 @@ public: | ... | @@ -273,7 +294,8 @@ public: |
| 273 | } | 294 | } |
| 274 | 295 | ||
| 275 | template <__span_array_convertible<element_type> _OtherElementType> | 296 | template <__span_array_convertible<element_type> _OtherElementType> |
| 276 | _LIBCPP_HIDE_FROM_ABI constexpr span(const span<_OtherElementType, _Extent>& __other) : __data_{__other.data()} {} | 297 | _LIBCPP_HIDE_FROM_ABI constexpr span(const span<_OtherElementType, _Extent>& __other) noexcept |
| 298 | : __data_{__other.data()} {} | ||
| 277 | 299 | ||
| 278 | template <__span_array_convertible<element_type> _OtherElementType> | 300 | template <__span_array_convertible<element_type> _OtherElementType> |
| 279 | _LIBCPP_HIDE_FROM_ABI constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept | 301 | _LIBCPP_HIDE_FROM_ABI constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept |
| ... | @@ -304,8 +326,8 @@ public: | ... | @@ -304,8 +326,8 @@ public: |
| 304 | } | 326 | } |
| 305 | 327 | ||
| 306 | template <size_t _Offset, size_t _Count = dynamic_extent> | 328 | template <size_t _Offset, size_t _Count = dynamic_extent> |
| 307 | _LIBCPP_HIDE_FROM_ABI constexpr auto subspan() const noexcept | 329 | _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 308 | -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> { | 330 | subspan() const noexcept -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> { |
| 309 | static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range"); | 331 | static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range"); |
| 310 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, | 332 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, |
| 311 | "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range"); | 333 | "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range"); |
| ... | @@ -564,10 +586,26 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept { | ... | @@ -564,10 +586,26 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept { |
| 564 | return __s.__as_writable_bytes(); | 586 | return __s.__as_writable_bytes(); |
| 565 | } | 587 | } |
| 566 | 588 | ||
| 567 | # if _LIBCPP_STD_VER >= 20 | 589 | # if _LIBCPP_STD_VER >= 26 |
| 590 | template <class _Tp> | ||
| 591 | concept __integral_constant_like = | ||
| 592 | is_integral_v<decltype(_Tp::value)> && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> && | ||
| 593 | convertible_to<_Tp, decltype(_Tp::value)> && equality_comparable_with<_Tp, decltype(_Tp::value)> && | ||
| 594 | bool_constant<_Tp() == _Tp::value>::value && | ||
| 595 | bool_constant<static_cast<decltype(_Tp::value)>(_Tp()) == _Tp::value>::value; | ||
| 596 | |||
| 597 | template <class _Tp> | ||
| 598 | inline constexpr size_t __maybe_static_ext = dynamic_extent; | ||
| 599 | |||
| 600 | template <__integral_constant_like _Tp> | ||
| 601 | inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value}; | ||
| 602 | |||
| 603 | template <contiguous_iterator _It, class _EndOrSize> | ||
| 604 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>, __maybe_static_ext<_EndOrSize>>; | ||
| 605 | # else | ||
| 568 | template <contiguous_iterator _It, class _EndOrSize> | 606 | template <contiguous_iterator _It, class _EndOrSize> |
| 569 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; | 607 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; |
| 570 | # endif // _LIBCPP_STD_VER >= 20 | 608 | # endif |
| 571 | 609 | ||
| 572 | template <class _Tp, size_t _Sz> | 610 | template <class _Tp, size_t _Sz> |
| 573 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; | 611 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; |
| ... | @@ -588,6 +626,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -588,6 +626,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 588 | _LIBCPP_POP_MACROS | 626 | _LIBCPP_POP_MACROS |
| 589 | 627 | ||
| 590 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 628 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 629 | # include <array> | ||
| 591 | # include <concepts> | 630 | # include <concepts> |
| 592 | # include <functional> | 631 | # include <functional> |
| 593 | # include <iterator> | 632 | # include <iterator> |
lib/libcxx/include/sstream+180-19| ... | @@ -48,10 +48,19 @@ public: | ... | @@ -48,10 +48,19 @@ public: |
| 48 | template <class SAlloc> | 48 | template <class SAlloc> |
| 49 | explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s, | 49 | explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s, |
| 50 | ios_base::openmode which = ios_base::in | ios_base::out); // C++20 | 50 | ios_base::openmode which = ios_base::in | ios_base::out); // C++20 |
| 51 | template<class T> | ||
| 52 | explicit basic_stringbuf(const T& t, | ||
| 53 | ios_base::openmode which = ios_base::in | ios_base::out); // Since C++26 | ||
| 54 | template<class T> | ||
| 55 | basic_stringbuf(const T& t, const Allocator& a); // Since C++26 | ||
| 56 | template<class T> | ||
| 57 | basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26 | ||
| 58 | basic_stringbuf(const basic_stringbuf&) = delete; | ||
| 51 | basic_stringbuf(basic_stringbuf&& rhs); | 59 | basic_stringbuf(basic_stringbuf&& rhs); |
| 52 | basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a); // C++20 | 60 | basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a); // C++20 |
| 53 | 61 | ||
| 54 | // [stringbuf.assign] Assign and swap: | 62 | // [stringbuf.assign] Assign and swap: |
| 63 | basic_stringbuf& operator=(const basic_stringbuf&) = delete; | ||
| 55 | basic_stringbuf& operator=(basic_stringbuf&& rhs); | 64 | basic_stringbuf& operator=(basic_stringbuf&& rhs); |
| 56 | void swap(basic_stringbuf& rhs) noexcept(see below); // conditionally noexcept since C++20 | 65 | void swap(basic_stringbuf& rhs) noexcept(see below); // conditionally noexcept since C++20 |
| 57 | 66 | ||
| ... | @@ -67,6 +76,8 @@ public: | ... | @@ -67,6 +76,8 @@ public: |
| 67 | template <class SAlloc> | 76 | template <class SAlloc> |
| 68 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 | 77 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 |
| 69 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 | 78 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 |
| 79 | template<class T> | ||
| 80 | void str(const T& t); // Since C++26 | ||
| 70 | 81 | ||
| 71 | protected: | 82 | protected: |
| 72 | // [stringbuf.virtuals] Overridden virtual functions: | 83 | // [stringbuf.virtuals] Overridden virtual functions: |
| ... | @@ -119,9 +130,17 @@ public: | ... | @@ -119,9 +130,17 @@ public: |
| 119 | template <class SAlloc> | 130 | template <class SAlloc> |
| 120 | explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s, | 131 | explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s, |
| 121 | ios_base::openmode which = ios_base::in); // C++20 | 132 | ios_base::openmode which = ios_base::in); // C++20 |
| 133 | template<class T> | ||
| 134 | explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in); // Since C++26 | ||
| 135 | template<class T> | ||
| 136 | basic_istringstream(const T& t, const Allocator& a); // Since C++26 | ||
| 137 | template<class T> | ||
| 138 | basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26 | ||
| 139 | basic_istringstream(const basic_istringstream&) = delete; | ||
| 122 | basic_istringstream(basic_istringstream&& rhs); | 140 | basic_istringstream(basic_istringstream&& rhs); |
| 123 | 141 | ||
| 124 | // [istringstream.assign] Assign and swap: | 142 | // [istringstream.assign] Assign and swap: |
| 143 | basic_istringstream& operator=(const basic_istringstream&) = delete; | ||
| 125 | basic_istringstream& operator=(basic_istringstream&& rhs); | 144 | basic_istringstream& operator=(basic_istringstream&& rhs); |
| 126 | void swap(basic_istringstream& rhs); | 145 | void swap(basic_istringstream& rhs); |
| 127 | 146 | ||
| ... | @@ -137,6 +156,8 @@ public: | ... | @@ -137,6 +156,8 @@ public: |
| 137 | template <class SAlloc> | 156 | template <class SAlloc> |
| 138 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 | 157 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 |
| 139 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 | 158 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 |
| 159 | template<class T> | ||
| 160 | void str(const T& t); // Since C++26 | ||
| 140 | }; | 161 | }; |
| 141 | 162 | ||
| 142 | template <class charT, class traits, class Allocator> | 163 | template <class charT, class traits, class Allocator> |
| ... | @@ -178,9 +199,17 @@ public: | ... | @@ -178,9 +199,17 @@ public: |
| 178 | template <class SAlloc> | 199 | template <class SAlloc> |
| 179 | explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s, | 200 | explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s, |
| 180 | ios_base::openmode which = ios_base::out); // C++20 | 201 | ios_base::openmode which = ios_base::out); // C++20 |
| 202 | template<class T> | ||
| 203 | explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out); // Since C++26 | ||
| 204 | template<class T> | ||
| 205 | basic_ostringstream(const T& t, const Allocator& a); // Since C++26 | ||
| 206 | template<class T> | ||
| 207 | basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26 | ||
| 208 | basic_ostringstream(const basic_ostringstream&) = delete; | ||
| 181 | basic_ostringstream(basic_ostringstream&& rhs); | 209 | basic_ostringstream(basic_ostringstream&& rhs); |
| 182 | 210 | ||
| 183 | // [ostringstream.assign] Assign and swap: | 211 | // [ostringstream.assign] Assign and swap: |
| 212 | basic_ostringstream& operator=(const basic_ostringstream&) = delete; | ||
| 184 | basic_ostringstream& operator=(basic_ostringstream&& rhs); | 213 | basic_ostringstream& operator=(basic_ostringstream&& rhs); |
| 185 | void swap(basic_ostringstream& rhs); | 214 | void swap(basic_ostringstream& rhs); |
| 186 | 215 | ||
| ... | @@ -196,6 +225,8 @@ public: | ... | @@ -196,6 +225,8 @@ public: |
| 196 | template <class SAlloc> | 225 | template <class SAlloc> |
| 197 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 | 226 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 |
| 198 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 | 227 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 |
| 228 | template<class T> | ||
| 229 | void str(const T& t); // Since C++26 | ||
| 199 | }; | 230 | }; |
| 200 | 231 | ||
| 201 | template <class charT, class traits, class Allocator> | 232 | template <class charT, class traits, class Allocator> |
| ... | @@ -237,9 +268,18 @@ public: | ... | @@ -237,9 +268,18 @@ public: |
| 237 | template <class SAlloc> | 268 | template <class SAlloc> |
| 238 | explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s, | 269 | explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s, |
| 239 | ios_base::openmode which = ios_base::out | ios_base::in); // C++20 | 270 | ios_base::openmode which = ios_base::out | ios_base::in); // C++20 |
| 271 | template<class T> | ||
| 272 | explicit basic_stringstream(const T& t, | ||
| 273 | ios_base::openmode which = ios_base::out | ios_base::in); // Since C++26 | ||
| 274 | template<class T> | ||
| 275 | basic_stringstream(const T& t, const Allocator& a); // Since C++26 | ||
| 276 | template<class T> | ||
| 277 | basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26 | ||
| 278 | basic_stringstream(const basic_stringstream&) = delete; | ||
| 240 | basic_stringstream(basic_stringstream&& rhs); | 279 | basic_stringstream(basic_stringstream&& rhs); |
| 241 | 280 | ||
| 242 | // [stringstream.assign] Assign and swap: | 281 | // [stringstream.assign] Assign and swap: |
| 282 | basic_stringstream& operator=(const basic_stringstream&) = delete; | ||
| 243 | basic_stringstream& operator=(basic_stringstream&& rhs); | 283 | basic_stringstream& operator=(basic_stringstream&& rhs); |
| 244 | void swap(basic_stringstream& rhs); | 284 | void swap(basic_stringstream& rhs); |
| 245 | 285 | ||
| ... | @@ -255,6 +295,8 @@ public: | ... | @@ -255,6 +295,8 @@ public: |
| 255 | template <class SAlloc> | 295 | template <class SAlloc> |
| 256 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 | 296 | void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20 |
| 257 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 | 297 | void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20 |
| 298 | template<class T> | ||
| 299 | void str(const T& t); // Since C++26 | ||
| 258 | }; | 300 | }; |
| 259 | 301 | ||
| 260 | template <class charT, class traits, class Allocator> | 302 | template <class charT, class traits, class Allocator> |
| ... | @@ -270,14 +312,14 @@ typedef basic_stringstream<wchar_t> wstringstream; | ... | @@ -270,14 +312,14 @@ typedef basic_stringstream<wchar_t> wstringstream; |
| 270 | 312 | ||
| 271 | // clang-format on | 313 | // clang-format on |
| 272 | 314 | ||
| 273 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 274 | #include <__availability> | ||
| 275 | #include <__config> | 315 | #include <__config> |
| 276 | #include <__fwd/sstream.h> | 316 | #include <__fwd/sstream.h> |
| 317 | #include <__ostream/basic_ostream.h> | ||
| 318 | #include <__type_traits/is_convertible.h> | ||
| 277 | #include <__utility/swap.h> | 319 | #include <__utility/swap.h> |
| 278 | #include <istream> | 320 | #include <istream> |
| 279 | #include <ostream> | ||
| 280 | #include <string> | 321 | #include <string> |
| 322 | #include <string_view> | ||
| 281 | #include <version> | 323 | #include <version> |
| 282 | 324 | ||
| 283 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 325 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -287,14 +329,6 @@ typedef basic_stringstream<wchar_t> wstringstream; | ... | @@ -287,14 +329,6 @@ typedef basic_stringstream<wchar_t> wstringstream; |
| 287 | _LIBCPP_PUSH_MACROS | 329 | _LIBCPP_PUSH_MACROS |
| 288 | #include <__undef_macros> | 330 | #include <__undef_macros> |
| 289 | 331 | ||
| 290 | // TODO(LLVM-19): Remove this once we drop support for Clang 16, | ||
| 291 | // which had this bug: https://github.com/llvm/llvm-project/issues/40363 | ||
| 292 | #ifdef _WIN32 | ||
| 293 | # define _LIBCPP_HIDE_FROM_ABI_SSTREAM _LIBCPP_ALWAYS_INLINE | ||
| 294 | #else | ||
| 295 | # define _LIBCPP_HIDE_FROM_ABI_SSTREAM _LIBCPP_HIDE_FROM_ABI | ||
| 296 | #endif | ||
| 297 | |||
| 298 | _LIBCPP_BEGIN_NAMESPACE_STD | 332 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 299 | 333 | ||
| 300 | // Class template basic_stringbuf [stringbuf] | 334 | // Class template basic_stringbuf [stringbuf] |
| ... | @@ -364,6 +398,31 @@ public: | ... | @@ -364,6 +398,31 @@ public: |
| 364 | } | 398 | } |
| 365 | #endif // _LIBCPP_STD_VER >= 20 | 399 | #endif // _LIBCPP_STD_VER >= 20 |
| 366 | 400 | ||
| 401 | #if _LIBCPP_STD_VER >= 26 | ||
| 402 | |||
| 403 | template <class _Tp> | ||
| 404 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 405 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const _Tp& __t, | ||
| 406 | ios_base::openmode __which = ios_base::in | ios_base::out) | ||
| 407 | : basic_stringbuf(__t, __which, _Allocator()) {} | ||
| 408 | |||
| 409 | template <class _Tp> | ||
| 410 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 411 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, const _Allocator& __a) | ||
| 412 | : basic_stringbuf(__t, ios_base::in | ios_base::out, __a) {} | ||
| 413 | |||
| 414 | template <class _Tp> | ||
| 415 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 416 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) | ||
| 417 | : __hm_(nullptr), __mode_(__which) { | ||
| 418 | basic_string_view<_CharT, _Traits> __sv = __t; | ||
| 419 | __str_ = string_type(__sv, __a); | ||
| 420 | __init_buf_ptrs(); | ||
| 421 | } | ||
| 422 | |||
| 423 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 424 | |||
| 425 | basic_stringbuf(const basic_stringbuf&) = delete; | ||
| 367 | basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); } | 426 | basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); } |
| 368 | 427 | ||
| 369 | #if _LIBCPP_STD_VER >= 20 | 428 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -374,6 +433,7 @@ public: | ... | @@ -374,6 +433,7 @@ public: |
| 374 | #endif | 433 | #endif |
| 375 | 434 | ||
| 376 | // [stringbuf.assign] Assign and swap: | 435 | // [stringbuf.assign] Assign and swap: |
| 436 | basic_stringbuf& operator=(const basic_stringbuf&) = delete; | ||
| 377 | basic_stringbuf& operator=(basic_stringbuf&& __rhs); | 437 | basic_stringbuf& operator=(basic_stringbuf&& __rhs); |
| 378 | void swap(basic_stringbuf& __rhs) | 438 | void swap(basic_stringbuf& __rhs) |
| 379 | #if _LIBCPP_STD_VER >= 20 | 439 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -391,9 +451,9 @@ public: | ... | @@ -391,9 +451,9 @@ public: |
| 391 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 451 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 392 | string_type str() const; | 452 | string_type str() const; |
| 393 | #else | 453 | #else |
| 394 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return str(__str_.get_allocator()); } | 454 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); } |
| 395 | 455 | ||
| 396 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { | 456 | _LIBCPP_HIDE_FROM_ABI string_type str() && { |
| 397 | const basic_string_view<_CharT, _Traits> __view = view(); | 457 | const basic_string_view<_CharT, _Traits> __view = view(); |
| 398 | typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data(); | 458 | typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data(); |
| 399 | // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator()); | 459 | // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator()); |
| ... | @@ -435,6 +495,18 @@ public: | ... | @@ -435,6 +495,18 @@ public: |
| 435 | } | 495 | } |
| 436 | #endif // _LIBCPP_STD_VER >= 20 | 496 | #endif // _LIBCPP_STD_VER >= 20 |
| 437 | 497 | ||
| 498 | #if _LIBCPP_STD_VER >= 26 | ||
| 499 | |||
| 500 | template <class _Tp> | ||
| 501 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 502 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { | ||
| 503 | basic_string_view<_CharT, _Traits> __sv = __t; | ||
| 504 | __str_ = __sv; | ||
| 505 | __init_buf_ptrs(); | ||
| 506 | } | ||
| 507 | |||
| 508 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 509 | |||
| 438 | protected: | 510 | protected: |
| 439 | // [stringbuf.virtuals] Overridden virtual functions: | 511 | // [stringbuf.virtuals] Overridden virtual functions: |
| 440 | int_type underflow() override; | 512 | int_type underflow() override; |
| ... | @@ -822,12 +894,33 @@ public: | ... | @@ -822,12 +894,33 @@ public: |
| 822 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} | 894 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} |
| 823 | #endif // _LIBCPP_STD_VER >= 20 | 895 | #endif // _LIBCPP_STD_VER >= 20 |
| 824 | 896 | ||
| 897 | #if _LIBCPP_STD_VER >= 26 | ||
| 898 | |||
| 899 | template <class _Tp> | ||
| 900 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 901 | _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in) | ||
| 902 | : basic_istringstream(__t, __which, _Allocator()) {} | ||
| 903 | |||
| 904 | template <class _Tp> | ||
| 905 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 906 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, const _Allocator& __a) | ||
| 907 | : basic_istringstream(__t, ios_base::in, __a) {} | ||
| 908 | |||
| 909 | template <class _Tp> | ||
| 910 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 911 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) | ||
| 912 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {} | ||
| 913 | |||
| 914 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 915 | |||
| 916 | basic_istringstream(const basic_istringstream&) = delete; | ||
| 825 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs) | 917 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs) |
| 826 | : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { | 918 | : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 827 | basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); | 919 | basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); |
| 828 | } | 920 | } |
| 829 | 921 | ||
| 830 | // [istringstream.assign] Assign and swap: | 922 | // [istringstream.assign] Assign and swap: |
| 923 | basic_istringstream& operator=(const basic_istringstream&) = delete; | ||
| 831 | basic_istringstream& operator=(basic_istringstream&& __rhs) { | 924 | basic_istringstream& operator=(basic_istringstream&& __rhs) { |
| 832 | basic_istream<char_type, traits_type>::operator=(std::move(__rhs)); | 925 | basic_istream<char_type, traits_type>::operator=(std::move(__rhs)); |
| 833 | __sb_ = std::move(__rhs.__sb_); | 926 | __sb_ = std::move(__rhs.__sb_); |
| ... | @@ -846,9 +939,9 @@ public: | ... | @@ -846,9 +939,9 @@ public: |
| 846 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 939 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 847 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } | 940 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 848 | #else | 941 | #else |
| 849 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return __sb_.str(); } | 942 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 850 | 943 | ||
| 851 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); } | 944 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 852 | #endif | 945 | #endif |
| 853 | 946 | ||
| 854 | #if _LIBCPP_STD_VER >= 20 | 947 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -871,6 +964,14 @@ public: | ... | @@ -871,6 +964,14 @@ public: |
| 871 | 964 | ||
| 872 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } | 965 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } |
| 873 | #endif // _LIBCPP_STD_VER >= 20 | 966 | #endif // _LIBCPP_STD_VER >= 20 |
| 967 | |||
| 968 | #if _LIBCPP_STD_VER >= 26 | ||
| 969 | template <class _Tp> | ||
| 970 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 971 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { | ||
| 972 | rdbuf()->str(__t); | ||
| 973 | } | ||
| 974 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 874 | }; | 975 | }; |
| 875 | 976 | ||
| 876 | template <class _CharT, class _Traits, class _Allocator> | 977 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -929,12 +1030,33 @@ public: | ... | @@ -929,12 +1030,33 @@ public: |
| 929 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} | 1030 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} |
| 930 | #endif // _LIBCPP_STD_VER >= 20 | 1031 | #endif // _LIBCPP_STD_VER >= 20 |
| 931 | 1032 | ||
| 1033 | #if _LIBCPP_STD_VER >= 26 | ||
| 1034 | |||
| 1035 | template <class _Tp> | ||
| 1036 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1037 | _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out) | ||
| 1038 | : basic_ostringstream(__t, __which | ios_base::out, _Allocator()) {} | ||
| 1039 | |||
| 1040 | template <class _Tp> | ||
| 1041 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1042 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, const _Allocator& __a) | ||
| 1043 | : basic_ostringstream(__t, ios_base::out, __a) {} | ||
| 1044 | |||
| 1045 | template <class _Tp> | ||
| 1046 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1047 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) | ||
| 1048 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {} | ||
| 1049 | |||
| 1050 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 1051 | |||
| 1052 | basic_ostringstream(const basic_ostringstream&) = delete; | ||
| 932 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs) | 1053 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs) |
| 933 | : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { | 1054 | : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 934 | basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_); | 1055 | basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_); |
| 935 | } | 1056 | } |
| 936 | 1057 | ||
| 937 | // [ostringstream.assign] Assign and swap: | 1058 | // [ostringstream.assign] Assign and swap: |
| 1059 | basic_ostringstream& operator=(const basic_ostringstream&) = delete; | ||
| 938 | basic_ostringstream& operator=(basic_ostringstream&& __rhs) { | 1060 | basic_ostringstream& operator=(basic_ostringstream&& __rhs) { |
| 939 | basic_ostream<char_type, traits_type>::operator=(std::move(__rhs)); | 1061 | basic_ostream<char_type, traits_type>::operator=(std::move(__rhs)); |
| 940 | __sb_ = std::move(__rhs.__sb_); | 1062 | __sb_ = std::move(__rhs.__sb_); |
| ... | @@ -954,9 +1076,9 @@ public: | ... | @@ -954,9 +1076,9 @@ public: |
| 954 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 1076 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 955 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } | 1077 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 956 | #else | 1078 | #else |
| 957 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return __sb_.str(); } | 1079 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 958 | 1080 | ||
| 959 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); } | 1081 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 960 | #endif | 1082 | #endif |
| 961 | 1083 | ||
| 962 | #if _LIBCPP_STD_VER >= 20 | 1084 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -979,6 +1101,14 @@ public: | ... | @@ -979,6 +1101,14 @@ public: |
| 979 | 1101 | ||
| 980 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } | 1102 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } |
| 981 | #endif // _LIBCPP_STD_VER >= 20 | 1103 | #endif // _LIBCPP_STD_VER >= 20 |
| 1104 | |||
| 1105 | #if _LIBCPP_STD_VER >= 26 | ||
| 1106 | template <class _Tp> | ||
| 1107 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1108 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { | ||
| 1109 | rdbuf()->str(__t); | ||
| 1110 | } | ||
| 1111 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 982 | }; | 1112 | }; |
| 983 | 1113 | ||
| 984 | template <class _CharT, class _Traits, class _Allocator> | 1114 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -1040,12 +1170,34 @@ public: | ... | @@ -1040,12 +1170,34 @@ public: |
| 1040 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} | 1170 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} |
| 1041 | #endif // _LIBCPP_STD_VER >= 20 | 1171 | #endif // _LIBCPP_STD_VER >= 20 |
| 1042 | 1172 | ||
| 1173 | #if _LIBCPP_STD_VER >= 26 | ||
| 1174 | |||
| 1175 | template <class _Tp> | ||
| 1176 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1177 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const _Tp& __t, | ||
| 1178 | ios_base::openmode __which = ios_base::out | ios_base::in) | ||
| 1179 | : basic_stringstream(__t, __which, _Allocator()) {} | ||
| 1180 | |||
| 1181 | template <class _Tp> | ||
| 1182 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1183 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, const _Allocator& __a) | ||
| 1184 | : basic_stringstream(__t, ios_base::out | ios_base::in, __a) {} | ||
| 1185 | |||
| 1186 | template <class _Tp> | ||
| 1187 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1188 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) | ||
| 1189 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {} | ||
| 1190 | |||
| 1191 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 1192 | |||
| 1193 | basic_stringstream(const basic_stringstream&) = delete; | ||
| 1043 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs) | 1194 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs) |
| 1044 | : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { | 1195 | : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 1045 | basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); | 1196 | basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); |
| 1046 | } | 1197 | } |
| 1047 | 1198 | ||
| 1048 | // [stringstream.assign] Assign and swap: | 1199 | // [stringstream.assign] Assign and swap: |
| 1200 | basic_stringstream& operator=(const basic_stringstream&) = delete; | ||
| 1049 | basic_stringstream& operator=(basic_stringstream&& __rhs) { | 1201 | basic_stringstream& operator=(basic_stringstream&& __rhs) { |
| 1050 | basic_iostream<char_type, traits_type>::operator=(std::move(__rhs)); | 1202 | basic_iostream<char_type, traits_type>::operator=(std::move(__rhs)); |
| 1051 | __sb_ = std::move(__rhs.__sb_); | 1203 | __sb_ = std::move(__rhs.__sb_); |
| ... | @@ -1064,9 +1216,9 @@ public: | ... | @@ -1064,9 +1216,9 @@ public: |
| 1064 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 1216 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 1065 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } | 1217 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 1066 | #else | 1218 | #else |
| 1067 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return __sb_.str(); } | 1219 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 1068 | 1220 | ||
| 1069 | _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); } | 1221 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 1070 | #endif | 1222 | #endif |
| 1071 | 1223 | ||
| 1072 | #if _LIBCPP_STD_VER >= 20 | 1224 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -1089,6 +1241,14 @@ public: | ... | @@ -1089,6 +1241,14 @@ public: |
| 1089 | 1241 | ||
| 1090 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } | 1242 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } |
| 1091 | #endif // _LIBCPP_STD_VER >= 20 | 1243 | #endif // _LIBCPP_STD_VER >= 20 |
| 1244 | |||
| 1245 | #if _LIBCPP_STD_VER >= 26 | ||
| 1246 | template <class _Tp> | ||
| 1247 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> | ||
| 1248 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { | ||
| 1249 | rdbuf()->str(__t); | ||
| 1250 | } | ||
| 1251 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 1092 | }; | 1252 | }; |
| 1093 | 1253 | ||
| 1094 | template <class _CharT, class _Traits, class _Allocator> | 1254 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -1109,6 +1269,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -1109,6 +1269,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 1109 | _LIBCPP_POP_MACROS | 1269 | _LIBCPP_POP_MACROS |
| 1110 | 1270 | ||
| 1111 | #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | 1271 | #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) |
| 1272 | # include <ostream> | ||
| 1112 | # include <type_traits> | 1273 | # include <type_traits> |
| 1113 | #endif | 1274 | #endif |
| 1114 | 1275 |
lib/libcxx/include/stack+25-26| ... | @@ -114,8 +114,8 @@ template <class T, class Container> | ... | @@ -114,8 +114,8 @@ template <class T, class Container> |
| 114 | */ | 114 | */ |
| 115 | 115 | ||
| 116 | #include <__algorithm/ranges_copy.h> | 116 | #include <__algorithm/ranges_copy.h> |
| 117 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 118 | #include <__config> | 117 | #include <__config> |
| 118 | #include <__fwd/stack.h> | ||
| 119 | #include <__iterator/back_insert_iterator.h> | 119 | #include <__iterator/back_insert_iterator.h> |
| 120 | #include <__iterator/iterator_traits.h> | 120 | #include <__iterator/iterator_traits.h> |
| 121 | #include <__memory/uses_allocator.h> | 121 | #include <__memory/uses_allocator.h> |
| ... | @@ -143,9 +143,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -143,9 +143,6 @@ _LIBCPP_PUSH_MACROS |
| 143 | 143 | ||
| 144 | _LIBCPP_BEGIN_NAMESPACE_STD | 144 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 145 | 145 | ||
| 146 | template <class _Tp, class _Container = deque<_Tp> > | ||
| 147 | class _LIBCPP_TEMPLATE_VIS stack; | ||
| 148 | |||
| 149 | template <class _Tp, class _Container> | 146 | template <class _Tp, class _Container> |
| 150 | _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); | 147 | _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); |
| 151 | 148 | ||
| ... | @@ -160,7 +157,7 @@ public: | ... | @@ -160,7 +157,7 @@ public: |
| 160 | typedef typename container_type::reference reference; | 157 | typedef typename container_type::reference reference; |
| 161 | typedef typename container_type::const_reference const_reference; | 158 | typedef typename container_type::const_reference const_reference; |
| 162 | typedef typename container_type::size_type size_type; | 159 | typedef typename container_type::size_type size_type; |
| 163 | static_assert((is_same<_Tp, value_type>::value), ""); | 160 | static_assert(is_same<_Tp, value_type>::value, ""); |
| 164 | 161 | ||
| 165 | protected: | 162 | protected: |
| 166 | container_type c; | 163 | container_type c; |
| ... | @@ -176,10 +173,10 @@ public: | ... | @@ -176,10 +173,10 @@ public: |
| 176 | } | 173 | } |
| 177 | 174 | ||
| 178 | #ifndef _LIBCPP_CXX03_LANG | 175 | #ifndef _LIBCPP_CXX03_LANG |
| 179 | _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) | 176 | _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible<container_type>::value) |
| 180 | : c(std::move(__q.c)) {} | 177 | : c(std::move(__q.c)) {} |
| 181 | 178 | ||
| 182 | _LIBCPP_HIDE_FROM_ABI stack& operator=(stack&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) { | 179 | _LIBCPP_HIDE_FROM_ABI stack& operator=(stack&& __q) noexcept(is_nothrow_move_assignable<container_type>::value) { |
| 183 | c = std::move(__q.c); | 180 | c = std::move(__q.c); |
| 184 | return *this; | 181 | return *this; |
| 185 | } | 182 | } |
| ... | @@ -213,7 +210,7 @@ public: | ... | @@ -213,7 +210,7 @@ public: |
| 213 | #endif // _LIBCPP_CXX03_LANG | 210 | #endif // _LIBCPP_CXX03_LANG |
| 214 | 211 | ||
| 215 | #if _LIBCPP_STD_VER >= 23 | 212 | #if _LIBCPP_STD_VER >= 23 |
| 216 | template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> | 213 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 217 | _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} | 214 | _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} |
| 218 | 215 | ||
| 219 | template <_ContainerCompatibleRange<_Tp> _Range> | 216 | template <_ContainerCompatibleRange<_Tp> _Range> |
| ... | @@ -221,20 +218,20 @@ public: | ... | @@ -221,20 +218,20 @@ public: |
| 221 | 218 | ||
| 222 | template <class _InputIterator, | 219 | template <class _InputIterator, |
| 223 | class _Alloc, | 220 | class _Alloc, |
| 224 | class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 221 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 225 | class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> | 222 | __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 226 | _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) | 223 | _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) |
| 227 | : c(__first, __last, __alloc) {} | 224 | : c(__first, __last, __alloc) {} |
| 228 | 225 | ||
| 229 | template <_ContainerCompatibleRange<_Tp> _Range, | 226 | template <_ContainerCompatibleRange<_Tp> _Range, |
| 230 | class _Alloc, | 227 | class _Alloc, |
| 231 | class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> | 228 | __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 232 | _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc) | 229 | _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc) |
| 233 | : c(from_range, std::forward<_Range>(__range), __alloc) {} | 230 | : c(from_range, std::forward<_Range>(__range), __alloc) {} |
| 234 | 231 | ||
| 235 | #endif | 232 | #endif |
| 236 | 233 | ||
| 237 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 234 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 238 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 235 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 239 | _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } | 236 | _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } |
| 240 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } | 237 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } |
| ... | @@ -257,13 +254,13 @@ public: | ... | @@ -257,13 +254,13 @@ public: |
| 257 | template <class... _Args> | 254 | template <class... _Args> |
| 258 | _LIBCPP_HIDE_FROM_ABI | 255 | _LIBCPP_HIDE_FROM_ABI |
| 259 | # if _LIBCPP_STD_VER >= 17 | 256 | # if _LIBCPP_STD_VER >= 17 |
| 260 | decltype(auto) | 257 | decltype(auto) |
| 261 | emplace(_Args&&... __args) { | 258 | emplace(_Args&&... __args) { |
| 262 | return c.emplace_back(std::forward<_Args>(__args)...); | 259 | return c.emplace_back(std::forward<_Args>(__args)...); |
| 263 | } | 260 | } |
| 264 | # else | 261 | # else |
| 265 | void | 262 | void |
| 266 | emplace(_Args&&... __args) { | 263 | emplace(_Args&&... __args) { |
| 267 | c.emplace_back(std::forward<_Args>(__args)...); | 264 | c.emplace_back(std::forward<_Args>(__args)...); |
| 268 | } | 265 | } |
| 269 | # endif | 266 | # endif |
| ... | @@ -271,7 +268,7 @@ public: | ... | @@ -271,7 +268,7 @@ public: |
| 271 | 268 | ||
| 272 | _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); } | 269 | _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); } |
| 273 | 270 | ||
| 274 | _LIBCPP_HIDE_FROM_ABI void swap(stack& __s) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) { | 271 | _LIBCPP_HIDE_FROM_ABI void swap(stack& __s) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) { |
| 275 | using std::swap; | 272 | using std::swap; |
| 276 | swap(c, __s.c); | 273 | swap(c, __s.c); |
| 277 | } | 274 | } |
| ... | @@ -297,7 +294,7 @@ stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>; | ... | @@ -297,7 +294,7 @@ stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>; |
| 297 | #endif | 294 | #endif |
| 298 | 295 | ||
| 299 | #if _LIBCPP_STD_VER >= 23 | 296 | #if _LIBCPP_STD_VER >= 23 |
| 300 | template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> | 297 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 301 | stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>; | 298 | stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>; |
| 302 | 299 | ||
| 303 | template <ranges::input_range _Range> | 300 | template <ranges::input_range _Range> |
| ... | @@ -305,14 +302,16 @@ stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; | ... | @@ -305,14 +302,16 @@ stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; |
| 305 | 302 | ||
| 306 | template <class _InputIterator, | 303 | template <class _InputIterator, |
| 307 | class _Alloc, | 304 | class _Alloc, |
| 308 | class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 305 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 309 | class = __enable_if_t<__is_allocator<_Alloc>::value>> | 306 | __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 310 | stack(_InputIterator, _InputIterator, _Alloc) | 307 | stack(_InputIterator, |
| 311 | -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | 308 | _InputIterator, |
| 309 | _Alloc) -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | ||
| 312 | 310 | ||
| 313 | template <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>> | 311 | template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 314 | stack(from_range_t, _Range&&, _Alloc) | 312 | stack(from_range_t, |
| 315 | -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | 313 | _Range&&, |
| 314 | _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | ||
| 316 | 315 | ||
| 317 | #endif | 316 | #endif |
| 318 | 317 | ||
| ... | @@ -357,7 +356,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y | ... | @@ -357,7 +356,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y |
| 357 | 356 | ||
| 358 | #endif | 357 | #endif |
| 359 | 358 | ||
| 360 | template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> | 359 | template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0> |
| 361 | inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) | 360 | inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) |
| 362 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 361 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 363 | __x.swap(__y); | 362 | __x.swap(__y); |
lib/libcxx/include/stdexcept+7-8| ... | @@ -17,14 +17,14 @@ namespace std | ... | @@ -17,14 +17,14 @@ namespace std |
| 17 | { | 17 | { |
| 18 | 18 | ||
| 19 | class logic_error; | 19 | class logic_error; |
| 20 | class domain_error; | 20 | class domain_error; |
| 21 | class invalid_argument; | 21 | class invalid_argument; |
| 22 | class length_error; | 22 | class length_error; |
| 23 | class out_of_range; | 23 | class out_of_range; |
| 24 | class runtime_error; | 24 | class runtime_error; |
| 25 | class range_error; | 25 | class range_error; |
| 26 | class overflow_error; | 26 | class overflow_error; |
| 27 | class underflow_error; | 27 | class underflow_error; |
| 28 | 28 | ||
| 29 | for each class xxx_error: | 29 | for each class xxx_error: |
| 30 | 30 | ||
| ... | @@ -41,7 +41,6 @@ public: | ... | @@ -41,7 +41,6 @@ public: |
| 41 | 41 | ||
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 45 | #include <__config> | 44 | #include <__config> |
| 46 | #include <__exception/exception.h> | 45 | #include <__exception/exception.h> |
| 47 | #include <__fwd/string.h> | 46 | #include <__fwd/string.h> |
lib/libcxx/include/stdlib.h+5-7| ... | @@ -110,21 +110,19 @@ extern "C++" { | ... | @@ -110,21 +110,19 @@ extern "C++" { |
| 110 | 110 | ||
| 111 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined | 111 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined |
| 112 | # if !defined(_LIBCPP_MSVCRT) | 112 | # if !defined(_LIBCPP_MSVCRT) |
| 113 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } | 113 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } |
| 114 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { | 114 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } |
| 115 | return __builtin_llabs(__x); | ||
| 116 | } | ||
| 117 | # endif // !defined(_LIBCPP_MSVCRT) | 115 | # endif // !defined(_LIBCPP_MSVCRT) |
| 118 | 116 | ||
| 119 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { | 117 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { |
| 120 | return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h | 118 | return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { | 121 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { |
| 124 | return __builtin_fabs(__lcpp_x); | 122 | return __builtin_fabs(__lcpp_x); |
| 125 | } | 123 | } |
| 126 | 124 | ||
| 127 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { | 125 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { |
| 128 | return __builtin_fabsl(__lcpp_x); | 126 | return __builtin_fabsl(__lcpp_x); |
| 129 | } | 127 | } |
| 130 | 128 |
lib/libcxx/include/stop_token+13-11| ... | @@ -33,19 +33,21 @@ namespace std { | ... | @@ -33,19 +33,21 @@ namespace std { |
| 33 | 33 | ||
| 34 | #include <__config> | 34 | #include <__config> |
| 35 | 35 | ||
| 36 | #ifdef _LIBCPP_HAS_NO_THREADS | 36 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 37 | # error "<stop_token> is not supported since libc++ has been configured without support for threads." | ||
| 38 | #endif | ||
| 39 | 37 | ||
| 40 | #include <__assert> // all public C++ headers provide the assertion handler | 38 | # if _LIBCPP_STD_VER >= 20 |
| 41 | #include <__stop_token/stop_callback.h> | 39 | # include <__stop_token/stop_callback.h> |
| 42 | #include <__stop_token/stop_source.h> | 40 | # include <__stop_token/stop_source.h> |
| 43 | #include <__stop_token/stop_token.h> | 41 | # include <__stop_token/stop_token.h> |
| 44 | #include <version> | 42 | # endif |
| 45 | 43 | ||
| 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 44 | # include <version> |
| 47 | # pragma GCC system_header | 45 | |
| 48 | #endif | 46 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 47 | # pragma GCC system_header | ||
| 48 | # endif | ||
| 49 | |||
| 50 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 49 | 51 | ||
| 50 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 52 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 51 | # include <iosfwd> | 53 | # include <iosfwd> |
lib/libcxx/include/streambuf+9-2| ... | @@ -107,9 +107,12 @@ protected: | ... | @@ -107,9 +107,12 @@ protected: |
| 107 | 107 | ||
| 108 | */ | 108 | */ |
| 109 | 109 | ||
| 110 | #include <__assert> // all public C++ headers provide the assertion handler | 110 | #include <__assert> |
| 111 | #include <__config> | 111 | #include <__config> |
| 112 | #include <__fwd/streambuf.h> | 112 | #include <__fwd/streambuf.h> |
| 113 | #include <__locale> | ||
| 114 | #include <__type_traits/is_same.h> | ||
| 115 | #include <__utility/is_valid_range.h> | ||
| 113 | #include <climits> | 116 | #include <climits> |
| 114 | #include <ios> | 117 | #include <ios> |
| 115 | #include <iosfwd> | 118 | #include <iosfwd> |
| ... | @@ -134,7 +137,7 @@ public: | ... | @@ -134,7 +137,7 @@ public: |
| 134 | typedef typename traits_type::pos_type pos_type; | 137 | typedef typename traits_type::pos_type pos_type; |
| 135 | typedef typename traits_type::off_type off_type; | 138 | typedef typename traits_type::off_type off_type; |
| 136 | 139 | ||
| 137 | static_assert((is_same<_CharT, typename traits_type::char_type>::value), | 140 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 138 | "traits_type::char_type must be the same type as CharT"); | 141 | "traits_type::char_type must be the same type as CharT"); |
| 139 | 142 | ||
| 140 | virtual ~basic_streambuf(); | 143 | virtual ~basic_streambuf(); |
| ... | @@ -233,6 +236,9 @@ protected: | ... | @@ -233,6 +236,9 @@ protected: |
| 233 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; } | 236 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; } |
| 234 | 237 | ||
| 235 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { | 238 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { |
| 239 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range"); | ||
| 240 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range"); | ||
| 241 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gnext, __gend), "[gnext, gend) must be a valid range"); | ||
| 236 | __binp_ = __gbeg; | 242 | __binp_ = __gbeg; |
| 237 | __ninp_ = __gnext; | 243 | __ninp_ = __gnext; |
| 238 | __einp_ = __gend; | 244 | __einp_ = __gend; |
| ... | @@ -248,6 +254,7 @@ protected: | ... | @@ -248,6 +254,7 @@ protected: |
| 248 | _LIBCPP_HIDE_FROM_ABI void __pbump(streamsize __n) { __nout_ += __n; } | 254 | _LIBCPP_HIDE_FROM_ABI void __pbump(streamsize __n) { __nout_ += __n; } |
| 249 | 255 | ||
| 250 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setp(char_type* __pbeg, char_type* __pend) { | 256 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setp(char_type* __pbeg, char_type* __pend) { |
| 257 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__pbeg, __pend), "[pbeg, pend) must be a valid range"); | ||
| 251 | __bout_ = __nout_ = __pbeg; | 258 | __bout_ = __nout_ = __pbeg; |
| 252 | __eout_ = __pend; | 259 | __eout_ = __pend; |
| 253 | } | 260 | } |
lib/libcxx/include/string+302-124| ... | @@ -407,6 +407,24 @@ template<class charT, class traits, class Allocator> | ... | @@ -407,6 +407,24 @@ template<class charT, class traits, class Allocator> |
| 407 | basic_string<charT, traits, Allocator> | 407 | basic_string<charT, traits, Allocator> |
| 408 | operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20 | 408 | operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20 |
| 409 | 409 | ||
| 410 | template<class charT, class traits, class Allocator> | ||
| 411 | constexpr basic_string<charT, traits, Allocator> | ||
| 412 | operator+(const basic_string<charT, traits, Allocator>& lhs, | ||
| 413 | type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26 | ||
| 414 | template<class charT, class traits, class Allocator> | ||
| 415 | constexpr basic_string<charT, traits, Allocator> | ||
| 416 | operator+(basic_string<charT, traits, Allocator>&& lhs, | ||
| 417 | type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26 | ||
| 418 | template<class charT, class traits, class Allocator> | ||
| 419 | constexpr basic_string<charT, traits, Allocator> | ||
| 420 | operator+(type_identity_t<basic_string_view<charT, traits>> lhs, | ||
| 421 | const basic_string<charT, traits, Allocator>& rhs); // Since C++26 | ||
| 422 | template<class charT, class traits, class Allocator> | ||
| 423 | constexpr basic_string<charT, traits, Allocator> | ||
| 424 | operator+(type_identity_t<basic_string_view<charT, traits>> lhs, | ||
| 425 | basic_string<charT, traits, Allocator>&& rhs); // Since C++26 | ||
| 426 | |||
| 427 | |||
| 410 | template<class charT, class traits, class Allocator> | 428 | template<class charT, class traits, class Allocator> |
| 411 | bool operator==(const basic_string<charT, traits, Allocator>& lhs, | 429 | bool operator==(const basic_string<charT, traits, Allocator>& lhs, |
| 412 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | 430 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 |
| ... | @@ -572,13 +590,15 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -572,13 +590,15 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 572 | #include <__algorithm/min.h> | 590 | #include <__algorithm/min.h> |
| 573 | #include <__algorithm/remove.h> | 591 | #include <__algorithm/remove.h> |
| 574 | #include <__algorithm/remove_if.h> | 592 | #include <__algorithm/remove_if.h> |
| 575 | #include <__assert> // all public C++ headers provide the assertion handler | 593 | #include <__assert> |
| 576 | #include <__config> | 594 | #include <__config> |
| 595 | #include <__debug_utils/sanitizers.h> | ||
| 577 | #include <__format/enable_insertable.h> | 596 | #include <__format/enable_insertable.h> |
| 578 | #include <__functional/hash.h> | 597 | #include <__functional/hash.h> |
| 579 | #include <__functional/unary_function.h> | 598 | #include <__functional/unary_function.h> |
| 580 | #include <__fwd/string.h> | 599 | #include <__fwd/string.h> |
| 581 | #include <__ios/fpos.h> | 600 | #include <__ios/fpos.h> |
| 601 | #include <__iterator/bounded_iter.h> | ||
| 582 | #include <__iterator/distance.h> | 602 | #include <__iterator/distance.h> |
| 583 | #include <__iterator/iterator_traits.h> | 603 | #include <__iterator/iterator_traits.h> |
| 584 | #include <__iterator/reverse_iterator.h> | 604 | #include <__iterator/reverse_iterator.h> |
| ... | @@ -599,14 +619,16 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -599,14 +619,16 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 599 | #include <__ranges/size.h> | 619 | #include <__ranges/size.h> |
| 600 | #include <__string/char_traits.h> | 620 | #include <__string/char_traits.h> |
| 601 | #include <__string/extern_template_lists.h> | 621 | #include <__string/extern_template_lists.h> |
| 622 | #include <__type_traits/conditional.h> | ||
| 602 | #include <__type_traits/is_allocator.h> | 623 | #include <__type_traits/is_allocator.h> |
| 603 | #include <__type_traits/is_array.h> | 624 | #include <__type_traits/is_array.h> |
| 604 | #include <__type_traits/is_convertible.h> | 625 | #include <__type_traits/is_convertible.h> |
| 605 | #include <__type_traits/is_nothrow_default_constructible.h> | 626 | #include <__type_traits/is_nothrow_assignable.h> |
| 606 | #include <__type_traits/is_nothrow_move_assignable.h> | 627 | #include <__type_traits/is_nothrow_constructible.h> |
| 607 | #include <__type_traits/is_same.h> | 628 | #include <__type_traits/is_same.h> |
| 608 | #include <__type_traits/is_standard_layout.h> | 629 | #include <__type_traits/is_standard_layout.h> |
| 609 | #include <__type_traits/is_trivial.h> | 630 | #include <__type_traits/is_trivial.h> |
| 631 | #include <__type_traits/is_trivially_relocatable.h> | ||
| 610 | #include <__type_traits/noexcept_move_assign_container.h> | 632 | #include <__type_traits/noexcept_move_assign_container.h> |
| 611 | #include <__type_traits/remove_cvref.h> | 633 | #include <__type_traits/remove_cvref.h> |
| 612 | #include <__type_traits/void_t.h> | 634 | #include <__type_traits/void_t.h> |
| ... | @@ -659,7 +681,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -659,7 +681,6 @@ _LIBCPP_PUSH_MACROS |
| 659 | #else | 681 | #else |
| 660 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS | 682 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS |
| 661 | #endif | 683 | #endif |
| 662 | #define _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED false | ||
| 663 | 684 | ||
| 664 | _LIBCPP_BEGIN_NAMESPACE_STD | 685 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 665 | 686 | ||
| ... | @@ -685,6 +706,28 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -685,6 +706,28 @@ template <class _CharT, class _Traits, class _Allocator> |
| 685 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 706 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 686 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); | 707 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); |
| 687 | 708 | ||
| 709 | #if _LIBCPP_STD_VER >= 26 | ||
| 710 | |||
| 711 | template <class _CharT, class _Traits, class _Allocator> | ||
| 712 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 713 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | ||
| 714 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs); | ||
| 715 | |||
| 716 | template <class _CharT, class _Traits, class _Allocator> | ||
| 717 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 718 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs); | ||
| 719 | |||
| 720 | template <class _CharT, class _Traits, class _Allocator> | ||
| 721 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 722 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | ||
| 723 | const basic_string<_CharT, _Traits, _Allocator>& __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, basic_string<_CharT, _Traits, _Allocator>&& __rhs); | ||
| 728 | |||
| 729 | #endif | ||
| 730 | |||
| 688 | extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ | 731 | extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ |
| 689 | <char, char_traits<char>, allocator<char> >(char const*, string const&); | 732 | <char, char_traits<char>, allocator<char> >(char const*, string const&); |
| 690 | 733 | ||
| ... | @@ -724,21 +767,72 @@ public: | ... | @@ -724,21 +767,72 @@ public: |
| 724 | typedef typename __alloc_traits::pointer pointer; | 767 | typedef typename __alloc_traits::pointer pointer; |
| 725 | typedef typename __alloc_traits::const_pointer const_pointer; | 768 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 726 | 769 | ||
| 727 | static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array"); | 770 | // A basic_string contains the following members which may be trivially relocatable: |
| 728 | static_assert((is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout"); | 771 | // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes |
| 729 | static_assert((is_trivial<value_type>::value), "Character type of basic_string must be trivial"); | 772 | // - size_type: is always trivially relocatable, since it has to be an integral type |
| 730 | static_assert((is_same<_CharT, typename traits_type::char_type>::value), | 773 | // - value_type: is always trivially relocatable, since it has to be trivial |
| 731 | "traits_type::char_type must be the same type as CharT"); | 774 | // - unsigned char: is a fundamental type, so it's trivially relocatable |
| 732 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 775 | // - allocator_type: may or may not be trivially relocatable, so it's checked |
| 733 | "Allocator::value_type must be same type as value_type"); | 776 | // |
| 777 | // This string implementation doesn't contain any references into itself. It only contains a bit that says whether | ||
| 778 | // it is in small or large string mode, so the entire structure is trivially relocatable if its members are. | ||
| 779 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | ||
| 780 | // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially | ||
| 781 | // relocatable. Because the object's memory might be poisoned when its content | ||
| 782 | // is kept inside objects memory (short string optimization), instead of in allocated | ||
| 783 | // external memory. In such cases, the destructor is responsible for unpoisoning | ||
| 784 | // the memory to avoid triggering false positives. | ||
| 785 | // Therefore it's crucial to ensure the destructor is called. | ||
| 786 | using __trivially_relocatable = void; | ||
| 787 | #else | ||
| 788 | using __trivially_relocatable = __conditional_t< | ||
| 789 | __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value, | ||
| 790 | basic_string, | ||
| 791 | void>; | ||
| 792 | #endif | ||
| 793 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | ||
| 794 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { | ||
| 795 | if (__libcpp_is_constant_evaluated()) | ||
| 796 | return __ptr; | ||
| 797 | |||
| 798 | pointer volatile __copy_ptr = __ptr; | ||
| 799 | |||
| 800 | return const_cast<pointer&>(__copy_ptr); | ||
| 801 | } | ||
| 734 | 802 | ||
| 735 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | 803 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer |
| 736 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | 804 | __asan_volatile_wrapper(const_pointer const& __ptr) const { |
| 737 | "original allocator"); | 805 | if (__libcpp_is_constant_evaluated()) |
| 806 | return __ptr; | ||
| 738 | 807 | ||
| 739 | // TODO: Implement iterator bounds checking without requiring the global database. | 808 | const_pointer volatile __copy_ptr = __ptr; |
| 809 | |||
| 810 | return const_cast<const_pointer&>(__copy_ptr); | ||
| 811 | } | ||
| 812 | # define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR) | ||
| 813 | #else | ||
| 814 | # define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR | ||
| 815 | #endif | ||
| 816 | |||
| 817 | static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array"); | ||
| 818 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout"); | ||
| 819 | static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial"); | ||
| 820 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | ||
| 821 | "traits_type::char_type must be the same type as CharT"); | ||
| 822 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | ||
| 823 | "Allocator::value_type must be same type as value_type"); | ||
| 824 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | ||
| 825 | |||
| 826 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 827 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's | ||
| 828 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is | ||
| 829 | // considered contiguous. | ||
| 830 | typedef __bounded_iter<__wrap_iter<pointer>> iterator; | ||
| 831 | typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator; | ||
| 832 | #else | ||
| 740 | typedef __wrap_iter<pointer> iterator; | 833 | typedef __wrap_iter<pointer> iterator; |
| 741 | typedef __wrap_iter<const_pointer> const_iterator; | 834 | typedef __wrap_iter<const_pointer> const_iterator; |
| 835 | #endif | ||
| 742 | typedef std::reverse_iterator<iterator> reverse_iterator; | 836 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 743 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 837 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 744 | 838 | ||
| ... | @@ -818,23 +912,9 @@ private: | ... | @@ -818,23 +912,9 @@ private: |
| 818 | 912 | ||
| 819 | static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size."); | 913 | static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size."); |
| 820 | 914 | ||
| 821 | union __ulx { | 915 | union __rep { |
| 822 | __long __lx; | 916 | __short __s; |
| 823 | __short __lxx; | 917 | __long __l; |
| 824 | }; | ||
| 825 | |||
| 826 | enum { __n_words = sizeof(__ulx) / sizeof(size_type) }; | ||
| 827 | |||
| 828 | struct __raw { | ||
| 829 | size_type __words[__n_words]; | ||
| 830 | }; | ||
| 831 | |||
| 832 | struct __rep { | ||
| 833 | union { | ||
| 834 | __short __s; | ||
| 835 | __long __l; | ||
| 836 | __raw __r; | ||
| 837 | }; | ||
| 838 | }; | 918 | }; |
| 839 | 919 | ||
| 840 | __compressed_pair<__rep, allocator_type> __r_; | 920 | __compressed_pair<__rep, allocator_type> __r_; |
| ... | @@ -868,10 +948,33 @@ private: | ... | @@ -868,10 +948,33 @@ private: |
| 868 | __init_with_sentinel(std::move(__first), std::move(__last)); | 948 | __init_with_sentinel(std::move(__first), std::move(__last)); |
| 869 | } | 949 | } |
| 870 | 950 | ||
| 871 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { return iterator(__p); } | 951 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { |
| 952 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 953 | // Bound the iterator according to the size (and not the capacity, unlike vector). | ||
| 954 | // | ||
| 955 | // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified, | ||
| 956 | // regardless of whether reallocation occurs. This allows us to check for out-of-bounds accesses using logical size, | ||
| 957 | // a stricter check, since correct code can never rely on being able to access newly-added elements via an existing | ||
| 958 | // iterator. | ||
| 959 | return std::__make_bounded_iter( | ||
| 960 | std::__wrap_iter<pointer>(__p), | ||
| 961 | std::__wrap_iter<pointer>(__get_pointer()), | ||
| 962 | std::__wrap_iter<pointer>(__get_pointer() + size())); | ||
| 963 | #else | ||
| 964 | return iterator(__p); | ||
| 965 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 966 | } | ||
| 872 | 967 | ||
| 873 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const { | 968 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const { |
| 969 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 970 | // Bound the iterator according to the size (and not the capacity, unlike vector). | ||
| 971 | return std::__make_bounded_iter( | ||
| 972 | std::__wrap_iter<const_pointer>(__p), | ||
| 973 | std::__wrap_iter<const_pointer>(__get_pointer()), | ||
| 974 | std::__wrap_iter<const_pointer>(__get_pointer() + size())); | ||
| 975 | #else | ||
| 874 | return const_iterator(__p); | 976 | return const_iterator(__p); |
| 977 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 875 | } | 978 | } |
| 876 | 979 | ||
| 877 | public: | 980 | public: |
| ... | @@ -922,7 +1025,11 @@ public: | ... | @@ -922,7 +1025,11 @@ public: |
| 922 | // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS | 1025 | // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS |
| 923 | // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first. | 1026 | // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first. |
| 924 | // __str's memory needs to be unpoisoned only in the case where it's a short string. | 1027 | // __str's memory needs to be unpoisoned only in the case where it's a short string. |
| 925 | : __r_([](basic_string &__s) -> decltype(__s.__r_)&& { if(!__s.__is_long()) __s.__annotate_delete(); return std::move(__s.__r_); }(__str)) { | 1028 | : __r_([](basic_string& __s) -> decltype(__s.__r_)&& { |
| 1029 | if (!__s.__is_long()) | ||
| 1030 | __s.__annotate_delete(); | ||
| 1031 | return std::move(__s.__r_); | ||
| 1032 | }(__str)) { | ||
| 926 | __str.__r_.first() = __rep(); | 1033 | __str.__r_.first() = __rep(); |
| 927 | __str.__annotate_new(0); | 1034 | __str.__annotate_new(0); |
| 928 | if (!__is_long()) | 1035 | if (!__is_long()) |
| ... | @@ -1054,8 +1161,8 @@ public: | ... | @@ -1054,8 +1161,8 @@ public: |
| 1054 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1161 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1055 | !__is_same_uncvref<_Tp, basic_string>::value, | 1162 | !__is_same_uncvref<_Tp, basic_string>::value, |
| 1056 | int> = 0> | 1163 | int> = 0> |
| 1057 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string( | 1164 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1058 | const _Tp& __t, const allocator_type& __a) | 1165 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) |
| 1059 | : __r_(__default_init_tag(), __a) { | 1166 | : __r_(__default_init_tag(), __a) { |
| 1060 | __self_view __sv = __t; | 1167 | __self_view __sv = __t; |
| 1061 | __init(__sv.data(), __sv.size()); | 1168 | __init(__sv.data(), __sv.size()); |
| ... | @@ -1122,8 +1229,8 @@ public: | ... | @@ -1122,8 +1229,8 @@ public: |
| 1122 | } | 1229 | } |
| 1123 | 1230 | ||
| 1124 | #ifndef _LIBCPP_CXX03_LANG | 1231 | #ifndef _LIBCPP_CXX03_LANG |
| 1125 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(basic_string&& __str) | 1232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1126 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { | 1233 | operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { |
| 1127 | __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | 1234 | __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 1128 | return *this; | 1235 | return *this; |
| 1129 | } | 1236 | } |
| ... | @@ -1138,7 +1245,7 @@ public: | ... | @@ -1138,7 +1245,7 @@ public: |
| 1138 | #if _LIBCPP_STD_VER >= 23 | 1245 | #if _LIBCPP_STD_VER >= 23 |
| 1139 | basic_string& operator=(nullptr_t) = delete; | 1246 | basic_string& operator=(nullptr_t) = delete; |
| 1140 | #endif | 1247 | #endif |
| 1141 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string& operator=(value_type __c); | 1248 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); |
| 1142 | 1249 | ||
| 1143 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { | 1250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { |
| 1144 | return __make_iterator(__get_pointer()); | 1251 | return __make_iterator(__get_pointer()); |
| ... | @@ -1213,7 +1320,7 @@ public: | ... | @@ -1213,7 +1320,7 @@ public: |
| 1213 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; | 1320 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; |
| 1214 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT; | 1321 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT; |
| 1215 | 1322 | ||
| 1216 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | 1323 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { |
| 1217 | return size() == 0; | 1324 | return size() == 0; |
| 1218 | } | 1325 | } |
| 1219 | 1326 | ||
| ... | @@ -1287,8 +1394,8 @@ public: | ... | @@ -1287,8 +1394,8 @@ public: |
| 1287 | int> = 0> | 1394 | int> = 0> |
| 1288 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1395 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1289 | 1396 | ||
| 1290 | basic_string& | 1397 | basic_string& |
| 1291 | append(const _Tp& __t, size_type __pos, size_type __n = npos); | 1398 | append(const _Tp& __t, size_type __pos, size_type __n = npos); |
| 1292 | 1399 | ||
| 1293 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n); | 1400 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n); |
| 1294 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s); | 1401 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s); |
| ... | @@ -1379,8 +1486,8 @@ public: | ... | @@ -1379,8 +1486,8 @@ public: |
| 1379 | return *this = __str; | 1486 | return *this = __str; |
| 1380 | } | 1487 | } |
| 1381 | #ifndef _LIBCPP_CXX03_LANG | 1488 | #ifndef _LIBCPP_CXX03_LANG |
| 1382 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(basic_string&& __str) | 1489 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1383 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { | 1490 | assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { |
| 1384 | *this = std::move(__str); | 1491 | *this = std::move(__str); |
| 1385 | return *this; | 1492 | return *this; |
| 1386 | } | 1493 | } |
| ... | @@ -1589,7 +1696,7 @@ public: | ... | @@ -1589,7 +1696,7 @@ public: |
| 1589 | #if _LIBCPP_STD_VER >= 14 | 1696 | #if _LIBCPP_STD_VER >= 14 |
| 1590 | _NOEXCEPT; | 1697 | _NOEXCEPT; |
| 1591 | #else | 1698 | #else |
| 1592 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value); | 1699 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 1593 | #endif | 1700 | #endif |
| 1594 | 1701 | ||
| 1595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } | 1702 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } |
| ... | @@ -1794,6 +1901,23 @@ private: | ... | @@ -1794,6 +1901,23 @@ private: |
| 1794 | template <class _Iterator, class _Sentinel> | 1901 | template <class _Iterator, class _Sentinel> |
| 1795 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); | 1902 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); |
| 1796 | 1903 | ||
| 1904 | // Copy [__first, __last) into [__dest, __dest + (__last - __first)). Assumes that the ranges don't overlap. | ||
| 1905 | template <class _ForwardIter, class _Sent> | ||
| 1906 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type* | ||
| 1907 | __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) { | ||
| 1908 | #ifndef _LIBCPP_CXX03_LANG | ||
| 1909 | if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value && | ||
| 1910 | is_same<value_type, __iter_value_type<_ForwardIter>>::value && is_same<_ForwardIter, _Sent>::value) { | ||
| 1911 | traits_type::copy(__dest, std::__to_address(__first), __last - __first); | ||
| 1912 | return __dest + (__last - __first); | ||
| 1913 | } | ||
| 1914 | #endif | ||
| 1915 | |||
| 1916 | for (; __first != __last; ++__first) | ||
| 1917 | traits_type::assign(*__dest++, *__first); | ||
| 1918 | return __dest; | ||
| 1919 | } | ||
| 1920 | |||
| 1797 | template <class _ForwardIterator, class _Sentinel> | 1921 | template <class _ForwardIterator, class _Sentinel> |
| 1798 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator | 1922 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator |
| 1799 | __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _Sentinel __last) { | 1923 | __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _Sentinel __last) { |
| ... | @@ -1813,8 +1937,7 @@ private: | ... | @@ -1813,8 +1937,7 @@ private: |
| 1813 | __sz += __n; | 1937 | __sz += __n; |
| 1814 | __set_size(__sz); | 1938 | __set_size(__sz); |
| 1815 | traits_type::assign(__p[__sz], value_type()); | 1939 | traits_type::assign(__p[__sz], value_type()); |
| 1816 | for (__p += __ip; __first != __last; ++__p, ++__first) | 1940 | __copy_non_overlapping_range(__first, __last, __p + __ip); |
| 1817 | traits_type::assign(*__p, *__first); | ||
| 1818 | 1941 | ||
| 1819 | return begin() + __ip; | 1942 | return begin() + __ip; |
| 1820 | } | 1943 | } |
| ... | @@ -1865,16 +1988,18 @@ private: | ... | @@ -1865,16 +1988,18 @@ private: |
| 1865 | __r_.first().__l.__data_ = __p; | 1988 | __r_.first().__l.__data_ = __p; |
| 1866 | } | 1989 | } |
| 1867 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT { | 1990 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT { |
| 1868 | return __r_.first().__l.__data_; | 1991 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_); |
| 1869 | } | 1992 | } |
| 1870 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT { | 1993 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT { |
| 1871 | return __r_.first().__l.__data_; | 1994 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_); |
| 1872 | } | 1995 | } |
| 1873 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_short_pointer() _NOEXCEPT { | 1996 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer |
| 1874 | return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]); | 1997 | __get_short_pointer() _NOEXCEPT { |
| 1998 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0])); | ||
| 1875 | } | 1999 | } |
| 1876 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_short_pointer() const _NOEXCEPT { | 2000 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer |
| 1877 | return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]); | 2001 | __get_short_pointer() const _NOEXCEPT { |
| 2002 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0])); | ||
| 1878 | } | 2003 | } |
| 1879 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT { | 2004 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT { |
| 1880 | return __is_long() ? __get_long_pointer() : __get_short_pointer(); | 2005 | return __is_long() ? __get_long_pointer() : __get_short_pointer(); |
| ... | @@ -1889,45 +2014,42 @@ private: | ... | @@ -1889,45 +2014,42 @@ private: |
| 1889 | (void)__old_mid; | 2014 | (void)__old_mid; |
| 1890 | (void)__new_mid; | 2015 | (void)__new_mid; |
| 1891 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | 2016 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) |
| 1892 | const void* __begin = data(); | 2017 | #if defined(__APPLE__) |
| 1893 | const void* __end = data() + capacity() + 1; | 2018 | // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) |
| 1894 | if (__asan_annotate_container_with_allocator<allocator_type>::value && !__libcpp_is_constant_evaluated()) | 2019 | if(!__is_long()) |
| 1895 | __sanitizer_annotate_contiguous_container(__begin, __end, __old_mid, __new_mid); | 2020 | return; |
| 2021 | #endif | ||
| 2022 | std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid); | ||
| 1896 | #endif | 2023 | #endif |
| 1897 | } | 2024 | } |
| 1898 | 2025 | ||
| 1899 | // ASan: short string is poisoned if and only if this function returns true. | ||
| 1900 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __asan_short_string_is_annotated() const _NOEXCEPT { | ||
| 1901 | return _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED && !__libcpp_is_constant_evaluated(); | ||
| 1902 | } | ||
| 1903 | |||
| 1904 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { | 2026 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 1905 | (void) __current_size; | 2027 | (void)__current_size; |
| 1906 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | 2028 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) |
| 1907 | if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long())) | 2029 | if (!__libcpp_is_constant_evaluated()) |
| 1908 | __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); | 2030 | __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); |
| 1909 | #endif | 2031 | #endif |
| 1910 | } | 2032 | } |
| 1911 | 2033 | ||
| 1912 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { | 2034 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { |
| 1913 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | 2035 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) |
| 1914 | if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long())) | 2036 | if (!__libcpp_is_constant_evaluated()) |
| 1915 | __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); | 2037 | __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); |
| 1916 | #endif | 2038 | #endif |
| 1917 | } | 2039 | } |
| 1918 | 2040 | ||
| 1919 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { | 2041 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { |
| 1920 | (void) __n; | 2042 | (void)__n; |
| 1921 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | 2043 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) |
| 1922 | if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long())) | 2044 | if (!__libcpp_is_constant_evaluated()) |
| 1923 | __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); | 2045 | __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); |
| 1924 | #endif | 2046 | #endif |
| 1925 | } | 2047 | } |
| 1926 | 2048 | ||
| 1927 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { | 2049 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { |
| 1928 | (void) __old_size; | 2050 | (void)__old_size; |
| 1929 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | 2051 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) |
| 1930 | if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long())) | 2052 | if (!__libcpp_is_constant_evaluated()) |
| 1931 | __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); | 2053 | __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); |
| 1932 | #endif | 2054 | #endif |
| 1933 | } | 2055 | } |
| ... | @@ -1936,17 +2058,15 @@ private: | ... | @@ -1936,17 +2058,15 @@ private: |
| 1936 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT { | 2058 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT { |
| 1937 | return (__s + (__a - 1)) & ~(__a - 1); | 2059 | return (__s + (__a - 1)) & ~(__a - 1); |
| 1938 | } | 2060 | } |
| 1939 | enum { | 2061 | enum { __alignment = 8 }; |
| 1940 | __alignment = 8 | ||
| 1941 | }; | ||
| 1942 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT { | 2062 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT { |
| 1943 | if (__s < __min_cap) { | 2063 | if (__s < __min_cap) { |
| 1944 | return static_cast<size_type>(__min_cap) - 1; | 2064 | return static_cast<size_type>(__min_cap) - 1; |
| 1945 | } | 2065 | } |
| 1946 | size_type __guess = | 2066 | const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor; |
| 1947 | __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1; | 2067 | size_type __guess = __align_it<__boundary>(__s + 1) - 1; |
| 1948 | if (__guess == __min_cap) | 2068 | if (__guess == __min_cap) |
| 1949 | ++__guess; | 2069 | __guess += __endian_factor; |
| 1950 | return __guess; | 2070 | return __guess; |
| 1951 | } | 2071 | } |
| 1952 | 2072 | ||
| ... | @@ -1979,15 +2099,15 @@ private: | ... | @@ -1979,15 +2099,15 @@ private: |
| 1979 | 2099 | ||
| 1980 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | 2100 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1981 | #if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 | 2101 | #if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 |
| 1982 | _LIBCPP_HIDE_FROM_ABI | 2102 | _LIBCPP_HIDE_FROM_ABI |
| 1983 | #endif | 2103 | #endif |
| 1984 | _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by( | 2104 | _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by( |
| 1985 | size_type __old_cap, | 2105 | size_type __old_cap, |
| 1986 | size_type __delta_cap, | 2106 | size_type __delta_cap, |
| 1987 | size_type __old_sz, | 2107 | size_type __old_sz, |
| 1988 | size_type __n_copy, | 2108 | size_type __n_copy, |
| 1989 | size_type __n_del, | 2109 | size_type __n_del, |
| 1990 | size_type __n_add = 0); | 2110 | size_type __n_add = 0); |
| 1991 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __grow_by_without_replace( | 2111 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __grow_by_without_replace( |
| 1992 | size_type __old_cap, | 2112 | size_type __old_cap, |
| 1993 | size_type __delta_cap, | 2113 | size_type __delta_cap, |
| ... | @@ -2050,14 +2170,14 @@ private: | ... | @@ -2050,14 +2170,14 @@ private: |
| 2050 | __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {} | 2170 | __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {} |
| 2051 | 2171 | ||
| 2052 | #ifndef _LIBCPP_CXX03_LANG | 2172 | #ifndef _LIBCPP_CXX03_LANG |
| 2053 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(basic_string& __str, false_type) | 2173 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2054 | _NOEXCEPT_(__alloc_traits::is_always_equal::value); | 2174 | __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value); |
| 2055 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void | 2175 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void |
| 2056 | __move_assign(basic_string& __str, true_type) | 2176 | __move_assign(basic_string& __str, true_type) |
| 2057 | # if _LIBCPP_STD_VER >= 17 | 2177 | # if _LIBCPP_STD_VER >= 17 |
| 2058 | _NOEXCEPT; | 2178 | noexcept; |
| 2059 | # else | 2179 | # else |
| 2060 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 2180 | noexcept(is_nothrow_move_assignable<allocator_type>::value); |
| 2061 | # endif | 2181 | # endif |
| 2062 | #endif | 2182 | #endif |
| 2063 | 2183 | ||
| ... | @@ -2122,6 +2242,10 @@ private: | ... | @@ -2122,6 +2242,10 @@ private: |
| 2122 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&); | 2242 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&); |
| 2123 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*); | 2243 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*); |
| 2124 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type); | 2244 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type); |
| 2245 | #if _LIBCPP_STD_VER >= 26 | ||
| 2246 | friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>); | ||
| 2247 | friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&); | ||
| 2248 | #endif | ||
| 2125 | }; | 2249 | }; |
| 2126 | 2250 | ||
| 2127 | // These declarations must appear before any functions are implicitly used | 2251 | // These declarations must appear before any functions are implicitly used |
| ... | @@ -2153,8 +2277,8 @@ template <class _CharT, | ... | @@ -2153,8 +2277,8 @@ template <class _CharT, |
| 2153 | class _Traits, | 2277 | class _Traits, |
| 2154 | class _Allocator = allocator<_CharT>, | 2278 | class _Allocator = allocator<_CharT>, |
| 2155 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 2279 | class = enable_if_t<__is_allocator<_Allocator>::value> > |
| 2156 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) | 2280 | explicit basic_string(basic_string_view<_CharT, _Traits>, |
| 2157 | -> basic_string<_CharT, _Traits, _Allocator>; | 2281 | const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>; |
| 2158 | 2282 | ||
| 2159 | template <class _CharT, | 2283 | template <class _CharT, |
| 2160 | class _Traits, | 2284 | class _Traits, |
| ... | @@ -2333,9 +2457,8 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir | ... | @@ -2333,9 +2457,8 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir |
| 2333 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 2457 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2334 | try { | 2458 | try { |
| 2335 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 2459 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2336 | for (; __first != __last; ++__first, (void)++__p) | 2460 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p)); |
| 2337 | traits_type::assign(*__p, *__first); | 2461 | traits_type::assign(*__end, value_type()); |
| 2338 | traits_type::assign(*__p, value_type()); | ||
| 2339 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 2462 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2340 | } catch (...) { | 2463 | } catch (...) { |
| 2341 | if (__is_long()) | 2464 | if (__is_long()) |
| ... | @@ -2380,7 +2503,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ | ... | @@ -2380,7 +2503,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2380 | __old_sz = __n_copy + __n_add + __sec_cp_sz; | 2503 | __old_sz = __n_copy + __n_add + __sec_cp_sz; |
| 2381 | __set_long_size(__old_sz); | 2504 | __set_long_size(__old_sz); |
| 2382 | traits_type::assign(__p[__old_sz], value_type()); | 2505 | traits_type::assign(__p[__old_sz], value_type()); |
| 2383 | __annotate_new(__old_cap + __delta_cap); | 2506 | __annotate_new(__old_sz); |
| 2384 | } | 2507 | } |
| 2385 | 2508 | ||
| 2386 | // __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it | 2509 | // __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it |
| ... | @@ -2389,15 +2512,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ | ... | @@ -2389,15 +2512,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2389 | template <class _CharT, class _Traits, class _Allocator> | 2512 | template <class _CharT, class _Traits, class _Allocator> |
| 2390 | void _LIBCPP_CONSTEXPR_SINCE_CXX20 | 2513 | void _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 2391 | #if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 | 2514 | #if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 |
| 2392 | _LIBCPP_HIDE_FROM_ABI | 2515 | _LIBCPP_HIDE_FROM_ABI |
| 2393 | #endif | 2516 | #endif |
| 2394 | _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by( | 2517 | _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by( |
| 2395 | size_type __old_cap, | 2518 | size_type __old_cap, |
| 2396 | size_type __delta_cap, | 2519 | size_type __delta_cap, |
| 2397 | size_type __old_sz, | 2520 | size_type __old_sz, |
| 2398 | size_type __n_copy, | 2521 | size_type __n_copy, |
| 2399 | size_type __n_del, | 2522 | size_type __n_del, |
| 2400 | size_type __n_add) { | 2523 | size_type __n_add) { |
| 2401 | size_type __ms = max_size(); | 2524 | size_type __ms = max_size(); |
| 2402 | if (__delta_cap > __ms - __old_cap) | 2525 | if (__delta_cap > __ms - __old_cap) |
| 2403 | __throw_length_error(); | 2526 | __throw_length_error(); |
| ... | @@ -2548,9 +2671,8 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) | ... | @@ -2548,9 +2671,8 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) |
| 2548 | #ifndef _LIBCPP_CXX03_LANG | 2671 | #ifndef _LIBCPP_CXX03_LANG |
| 2549 | 2672 | ||
| 2550 | template <class _CharT, class _Traits, class _Allocator> | 2673 | template <class _CharT, class _Traits, class _Allocator> |
| 2551 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 2674 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign( |
| 2552 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) | 2675 | basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) { |
| 2553 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) { | ||
| 2554 | if (__alloc() != __str.__alloc()) | 2676 | if (__alloc() != __str.__alloc()) |
| 2555 | assign(__str); | 2677 | assign(__str); |
| 2556 | else | 2678 | else |
| ... | @@ -2561,9 +2683,9 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -2561,9 +2683,9 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2561 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void | 2683 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void |
| 2562 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) | 2684 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) |
| 2563 | # if _LIBCPP_STD_VER >= 17 | 2685 | # if _LIBCPP_STD_VER >= 17 |
| 2564 | _NOEXCEPT | 2686 | noexcept |
| 2565 | # else | 2687 | # else |
| 2566 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 2688 | noexcept(is_nothrow_move_assignable<allocator_type>::value) |
| 2567 | # endif | 2689 | # endif |
| 2568 | { | 2690 | { |
| 2569 | __annotate_delete(); | 2691 | __annotate_delete(); |
| ... | @@ -2802,10 +2924,8 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For | ... | @@ -2802,10 +2924,8 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For |
| 2802 | if (__cap - __sz < __n) | 2924 | if (__cap - __sz < __n) |
| 2803 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); | 2925 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); |
| 2804 | __annotate_increase(__n); | 2926 | __annotate_increase(__n); |
| 2805 | pointer __p = __get_pointer() + __sz; | 2927 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz)); |
| 2806 | for (; __first != __last; ++__p, (void)++__first) | 2928 | traits_type::assign(*__end, value_type()); |
| 2807 | traits_type::assign(*__p, *__first); | ||
| 2808 | traits_type::assign(*__p, value_type()); | ||
| 2809 | __set_size(__sz + __n); | 2929 | __set_size(__sz + __n); |
| 2810 | } else { | 2930 | } else { |
| 2811 | const basic_string __temp(__first, __last, __alloc()); | 2931 | const basic_string __temp(__first, __last, __alloc()); |
| ... | @@ -3238,23 +3358,34 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target | ... | @@ -3238,23 +3358,34 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3238 | __p = __get_long_pointer(); | 3358 | __p = __get_long_pointer(); |
| 3239 | } else { | 3359 | } else { |
| 3240 | if (__target_capacity > __cap) { | 3360 | if (__target_capacity > __cap) { |
| 3361 | // Extend | ||
| 3362 | // - called from reserve should propagate the exception thrown. | ||
| 3241 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); | 3363 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); |
| 3242 | __new_data = __allocation.ptr; | 3364 | __new_data = __allocation.ptr; |
| 3243 | __target_capacity = __allocation.count - 1; | 3365 | __target_capacity = __allocation.count - 1; |
| 3244 | } else { | 3366 | } else { |
| 3367 | // Shrink | ||
| 3368 | // - called from shrink_to_fit should not throw. | ||
| 3369 | // - called from reserve may throw but is not required to. | ||
| 3245 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 3370 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 3246 | try { | 3371 | try { |
| 3247 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 3372 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 3248 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); | 3373 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); |
| 3374 | |||
| 3375 | // The Standard mandates shrink_to_fit() does not increase the capacity. | ||
| 3376 | // With equal capacity keep the existing buffer. This avoids extra work | ||
| 3377 | // due to swapping the elements. | ||
| 3378 | if (__allocation.count - 1 > __target_capacity) { | ||
| 3379 | __alloc_traits::deallocate(__alloc(), __allocation.ptr, __allocation.count); | ||
| 3380 | __annotate_new(__sz); // Undoes the __annotate_delete() | ||
| 3381 | return; | ||
| 3382 | } | ||
| 3249 | __new_data = __allocation.ptr; | 3383 | __new_data = __allocation.ptr; |
| 3250 | __target_capacity = __allocation.count - 1; | 3384 | __target_capacity = __allocation.count - 1; |
| 3251 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 3385 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 3252 | } catch (...) { | 3386 | } catch (...) { |
| 3253 | return; | 3387 | return; |
| 3254 | } | 3388 | } |
| 3255 | #else // _LIBCPP_HAS_NO_EXCEPTIONS | ||
| 3256 | if (__new_data == nullptr) | ||
| 3257 | return; | ||
| 3258 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 3389 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 3259 | } | 3390 | } |
| 3260 | __begin_lifetime(__new_data, __target_capacity + 1); | 3391 | __begin_lifetime(__new_data, __target_capacity + 1); |
| ... | @@ -3306,7 +3437,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat | ... | @@ -3306,7 +3437,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 3306 | #if _LIBCPP_STD_VER >= 14 | 3437 | #if _LIBCPP_STD_VER >= 14 |
| 3307 | _NOEXCEPT | 3438 | _NOEXCEPT |
| 3308 | #else | 3439 | #else |
| 3309 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) | 3440 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 3310 | #endif | 3441 | #endif |
| 3311 | { | 3442 | { |
| 3312 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( | 3443 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( |
| ... | @@ -3702,17 +3833,10 @@ template <class _Allocator> | ... | @@ -3702,17 +3833,10 @@ template <class _Allocator> |
| 3702 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | 3833 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool |
| 3703 | operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, | 3834 | operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, |
| 3704 | const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT { | 3835 | const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT { |
| 3705 | size_t __lhs_sz = __lhs.size(); | 3836 | size_t __sz = __lhs.size(); |
| 3706 | if (__lhs_sz != __rhs.size()) | 3837 | if (__sz != __rhs.size()) |
| 3707 | return false; | 3838 | return false; |
| 3708 | const char* __lp = __lhs.data(); | 3839 | return char_traits<char>::compare(__lhs.data(), __rhs.data(), __sz) == 0; |
| 3709 | const char* __rp = __rhs.data(); | ||
| 3710 | if (__lhs.__is_long()) | ||
| 3711 | return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0; | ||
| 3712 | for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) | ||
| 3713 | if (*__lp != *__rp) | ||
| 3714 | return false; | ||
| 3715 | return true; | ||
| 3716 | } | 3840 | } |
| 3717 | 3841 | ||
| 3718 | #if _LIBCPP_STD_VER <= 17 | 3842 | #if _LIBCPP_STD_VER <= 17 |
| ... | @@ -3987,6 +4111,60 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { | ... | @@ -3987,6 +4111,60 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { |
| 3987 | 4111 | ||
| 3988 | #endif // _LIBCPP_CXX03_LANG | 4112 | #endif // _LIBCPP_CXX03_LANG |
| 3989 | 4113 | ||
| 4114 | #if _LIBCPP_STD_VER >= 26 | ||
| 4115 | |||
| 4116 | template <class _CharT, class _Traits, class _Allocator> | ||
| 4117 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 4118 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | ||
| 4119 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { | ||
| 4120 | using _String = basic_string<_CharT, _Traits, _Allocator>; | ||
| 4121 | typename _String::size_type __lhs_sz = __lhs.size(); | ||
| 4122 | typename _String::size_type __rhs_sz = __rhs.size(); | ||
| 4123 | _String __r(__uninitialized_size_tag(), | ||
| 4124 | __lhs_sz + __rhs_sz, | ||
| 4125 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | ||
| 4126 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4127 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | ||
| 4128 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | ||
| 4129 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | ||
| 4130 | return __r; | ||
| 4131 | } | ||
| 4132 | |||
| 4133 | template <class _CharT, class _Traits, class _Allocator> | ||
| 4134 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 4135 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, | ||
| 4136 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { | ||
| 4137 | __lhs.append(__rhs); | ||
| 4138 | return std::move(__lhs); | ||
| 4139 | } | ||
| 4140 | |||
| 4141 | template <class _CharT, class _Traits, class _Allocator> | ||
| 4142 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 4143 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | ||
| 4144 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | ||
| 4145 | using _String = basic_string<_CharT, _Traits, _Allocator>; | ||
| 4146 | typename _String::size_type __lhs_sz = __lhs.size(); | ||
| 4147 | typename _String::size_type __rhs_sz = __rhs.size(); | ||
| 4148 | _String __r(__uninitialized_size_tag(), | ||
| 4149 | __lhs_sz + __rhs_sz, | ||
| 4150 | _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); | ||
| 4151 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4152 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | ||
| 4153 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | ||
| 4154 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | ||
| 4155 | return __r; | ||
| 4156 | } | ||
| 4157 | |||
| 4158 | template <class _CharT, class _Traits, class _Allocator> | ||
| 4159 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 4160 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | ||
| 4161 | basic_string<_CharT, _Traits, _Allocator>&& __rhs) { | ||
| 4162 | __rhs.insert(0, __lhs); | ||
| 4163 | return std::move(__rhs); | ||
| 4164 | } | ||
| 4165 | |||
| 4166 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 4167 | |||
| 3990 | // swap | 4168 | // swap |
| 3991 | 4169 | ||
| 3992 | template <class _CharT, class _Traits, class _Allocator> | 4170 | template <class _CharT, class _Traits, class _Allocator> |
lib/libcxx/include/string_view+27-25| ... | @@ -206,15 +206,17 @@ namespace std { | ... | @@ -206,15 +206,17 @@ namespace std { |
| 206 | // clang-format on | 206 | // clang-format on |
| 207 | 207 | ||
| 208 | #include <__algorithm/min.h> | 208 | #include <__algorithm/min.h> |
| 209 | #include <__assert> // all public C++ headers provide the assertion handler | 209 | #include <__assert> |
| 210 | #include <__config> | 210 | #include <__config> |
| 211 | #include <__functional/hash.h> | 211 | #include <__functional/hash.h> |
| 212 | #include <__functional/unary_function.h> | 212 | #include <__functional/unary_function.h> |
| 213 | #include <__fwd/ostream.h> | ||
| 213 | #include <__fwd/string_view.h> | 214 | #include <__fwd/string_view.h> |
| 214 | #include <__iterator/bounded_iter.h> | 215 | #include <__iterator/bounded_iter.h> |
| 215 | #include <__iterator/concepts.h> | 216 | #include <__iterator/concepts.h> |
| 216 | #include <__iterator/iterator_traits.h> | 217 | #include <__iterator/iterator_traits.h> |
| 217 | #include <__iterator/reverse_iterator.h> | 218 | #include <__iterator/reverse_iterator.h> |
| 219 | #include <__iterator/wrap_iter.h> | ||
| 218 | #include <__memory/pointer_traits.h> | 220 | #include <__memory/pointer_traits.h> |
| 219 | #include <__ranges/concepts.h> | 221 | #include <__ranges/concepts.h> |
| 220 | #include <__ranges/data.h> | 222 | #include <__ranges/data.h> |
| ... | @@ -278,10 +280,12 @@ public: | ... | @@ -278,10 +280,12 @@ public: |
| 278 | using const_pointer = const _CharT*; | 280 | using const_pointer = const _CharT*; |
| 279 | using reference = _CharT&; | 281 | using reference = _CharT&; |
| 280 | using const_reference = const _CharT&; | 282 | using const_reference = const _CharT&; |
| 281 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 283 | #if defined(_LIBCPP_ABI_BOUNDED_ITERATORS) |
| 282 | using const_iterator = __bounded_iter<const_pointer>; | 284 | using const_iterator = __bounded_iter<const_pointer>; |
| 285 | #elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW) | ||
| 286 | using const_iterator = __wrap_iter<const_pointer>; | ||
| 283 | #else | 287 | #else |
| 284 | using const_iterator = const_pointer; // See [string.view.iterators] | 288 | using const_iterator = const_pointer; |
| 285 | #endif | 289 | #endif |
| 286 | using iterator = const_iterator; | 290 | using iterator = const_iterator; |
| 287 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | 291 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| ... | @@ -290,10 +294,10 @@ public: | ... | @@ -290,10 +294,10 @@ public: |
| 290 | using difference_type = ptrdiff_t; | 294 | using difference_type = ptrdiff_t; |
| 291 | static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); | 295 | static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); |
| 292 | 296 | ||
| 293 | static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array"); | 297 | static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array"); |
| 294 | static_assert((is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout"); | 298 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout"); |
| 295 | static_assert((is_trivial<value_type>::value), "Character type of basic_string_view must be trivial"); | 299 | static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial"); |
| 296 | static_assert((is_same<_CharT, typename traits_type::char_type>::value), | 300 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 297 | "traits_type::char_type must be the same type as CharT"); | 301 | "traits_type::char_type must be the same type as CharT"); |
| 298 | 302 | ||
| 299 | // [string.view.cons], construct/copy | 303 | // [string.view.cons], construct/copy |
| ... | @@ -307,9 +311,10 @@ public: | ... | @@ -307,9 +311,10 @@ public: |
| 307 | : __data_(__s), | 311 | : __data_(__s), |
| 308 | __size_(__len) { | 312 | __size_(__len) { |
| 309 | #if _LIBCPP_STD_VER >= 14 | 313 | #if _LIBCPP_STD_VER >= 14 |
| 310 | // This will result in creating an invalid `string_view` object -- some calculations involving `size` would | 314 | // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input |
| 311 | // overflow, making it effectively truncated. | 315 | // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently |
| 312 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 316 | // passed in a negative length. |
| 317 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | ||
| 313 | __len <= static_cast<size_type>(numeric_limits<difference_type>::max()), | 318 | __len <= static_cast<size_type>(numeric_limits<difference_type>::max()), |
| 314 | "string_view::string_view(_CharT *, size_t): length does not fit in difference_type"); | 319 | "string_view::string_view(_CharT *, size_t): length does not fit in difference_type"); |
| 315 | _LIBCPP_ASSERT_NON_NULL( | 320 | _LIBCPP_ASSERT_NON_NULL( |
| ... | @@ -353,7 +358,7 @@ public: | ... | @@ -353,7 +358,7 @@ public: |
| 353 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 358 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 354 | return std::__make_bounded_iter(data(), data(), data() + size()); | 359 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 355 | #else | 360 | #else |
| 356 | return __data_; | 361 | return const_iterator(__data_); |
| 357 | #endif | 362 | #endif |
| 358 | } | 363 | } |
| 359 | 364 | ||
| ... | @@ -361,7 +366,7 @@ public: | ... | @@ -361,7 +366,7 @@ public: |
| 361 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 366 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 362 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); | 367 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 363 | #else | 368 | #else |
| 364 | return __data_ + __size_; | 369 | return const_iterator(__data_ + __size_); |
| 365 | #endif | 370 | #endif |
| 366 | } | 371 | } |
| 367 | 372 | ||
| ... | @@ -390,9 +395,7 @@ public: | ... | @@ -390,9 +395,7 @@ public: |
| 390 | return numeric_limits<size_type>::max() / sizeof(value_type); | 395 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 391 | } | 396 | } |
| 392 | 397 | ||
| 393 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { | 398 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } |
| 394 | return __size_ == 0; | ||
| 395 | } | ||
| 396 | 399 | ||
| 397 | // [string.view.access], element access | 400 | // [string.view.access], element access |
| 398 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT { | 401 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT { |
| ... | @@ -900,32 +903,31 @@ struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_ | ... | @@ -900,32 +903,31 @@ struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_ |
| 900 | #if _LIBCPP_STD_VER >= 14 | 903 | #if _LIBCPP_STD_VER >= 14 |
| 901 | inline namespace literals { | 904 | inline namespace literals { |
| 902 | inline namespace string_view_literals { | 905 | inline namespace string_view_literals { |
| 903 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char> | 906 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept { |
| 904 | operator""sv(const char* __str, size_t __len) _NOEXCEPT { | ||
| 905 | return basic_string_view<char>(__str, __len); | 907 | return basic_string_view<char>(__str, __len); |
| 906 | } | 908 | } |
| 907 | 909 | ||
| 908 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 910 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 909 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<wchar_t> | 911 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t> |
| 910 | operator""sv(const wchar_t* __str, size_t __len) _NOEXCEPT { | 912 | operator""sv(const wchar_t* __str, size_t __len) noexcept { |
| 911 | return basic_string_view<wchar_t>(__str, __len); | 913 | return basic_string_view<wchar_t>(__str, __len); |
| 912 | } | 914 | } |
| 913 | # endif | 915 | # endif |
| 914 | 916 | ||
| 915 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | 917 | # ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 916 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char8_t> | 918 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t> |
| 917 | operator""sv(const char8_t* __str, size_t __len) _NOEXCEPT { | 919 | operator""sv(const char8_t* __str, size_t __len) noexcept { |
| 918 | return basic_string_view<char8_t>(__str, __len); | 920 | return basic_string_view<char8_t>(__str, __len); |
| 919 | } | 921 | } |
| 920 | # endif | 922 | # endif |
| 921 | 923 | ||
| 922 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char16_t> | 924 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t> |
| 923 | operator""sv(const char16_t* __str, size_t __len) _NOEXCEPT { | 925 | operator""sv(const char16_t* __str, size_t __len) noexcept { |
| 924 | return basic_string_view<char16_t>(__str, __len); | 926 | return basic_string_view<char16_t>(__str, __len); |
| 925 | } | 927 | } |
| 926 | 928 | ||
| 927 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char32_t> | 929 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t> |
| 928 | operator""sv(const char32_t* __str, size_t __len) _NOEXCEPT { | 930 | operator""sv(const char32_t* __str, size_t __len) noexcept { |
| 929 | return basic_string_view<char32_t>(__str, __len); | 931 | return basic_string_view<char32_t>(__str, __len); |
| 930 | } | 932 | } |
| 931 | } // namespace string_view_literals | 933 | } // namespace string_view_literals |
lib/libcxx/include/strstream+22-19| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | /* | 13 | /* |
| 14 | strstream synopsis | 14 | strstream synopsis |
| 15 | 15 | ||
| 16 | class strstreambuf | 16 | class strstreambuf // Removed in C++26 |
| 17 | : public basic_streambuf<char> | 17 | : public basic_streambuf<char> |
| 18 | { | 18 | { |
| 19 | public: | 19 | public: |
| ... | @@ -63,7 +63,7 @@ private: | ... | @@ -63,7 +63,7 @@ private: |
| 63 | void (*pfree)(void*); // exposition only | 63 | void (*pfree)(void*); // exposition only |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | class istrstream | 66 | class istrstream // Removed in C++26 |
| 67 | : public basic_istream<char> | 67 | : public basic_istream<char> |
| 68 | { | 68 | { |
| 69 | public: | 69 | public: |
| ... | @@ -81,7 +81,7 @@ private: | ... | @@ -81,7 +81,7 @@ private: |
| 81 | strstreambuf sb; // exposition only | 81 | strstreambuf sb; // exposition only |
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | class ostrstream | 84 | class ostrstream // Removed in C++26 |
| 85 | : public basic_ostream<char> | 85 | : public basic_ostream<char> |
| 86 | { | 86 | { |
| 87 | public: | 87 | public: |
| ... | @@ -99,7 +99,7 @@ private: | ... | @@ -99,7 +99,7 @@ private: |
| 99 | strstreambuf sb; // exposition only | 99 | strstreambuf sb; // exposition only |
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | class strstream | 102 | class strstream // Removed in C++26 |
| 103 | : public basic_iostream<char> | 103 | : public basic_iostream<char> |
| 104 | { | 104 | { |
| 105 | public: | 105 | public: |
| ... | @@ -129,7 +129,6 @@ private: | ... | @@ -129,7 +129,6 @@ private: |
| 129 | 129 | ||
| 130 | */ | 130 | */ |
| 131 | 131 | ||
| 132 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 133 | #include <__config> | 132 | #include <__config> |
| 134 | #include <istream> | 133 | #include <istream> |
| 135 | #include <ostream> | 134 | #include <ostream> |
| ... | @@ -139,19 +138,21 @@ private: | ... | @@ -139,19 +138,21 @@ private: |
| 139 | # pragma GCC system_header | 138 | # pragma GCC system_header |
| 140 | #endif | 139 | #endif |
| 141 | 140 | ||
| 141 | #if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 142 | |||
| 142 | _LIBCPP_PUSH_MACROS | 143 | _LIBCPP_PUSH_MACROS |
| 143 | #include <__undef_macros> | 144 | # include <__undef_macros> |
| 144 | 145 | ||
| 145 | _LIBCPP_BEGIN_NAMESPACE_STD | 146 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 146 | 147 | ||
| 147 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf { | 148 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf { |
| 148 | public: | 149 | public: |
| 149 | #ifndef _LIBCPP_CXX03_LANG | 150 | # ifndef _LIBCPP_CXX03_LANG |
| 150 | _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {} | 151 | _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {} |
| 151 | explicit strstreambuf(streamsize __alsize); | 152 | explicit strstreambuf(streamsize __alsize); |
| 152 | #else | 153 | # else |
| 153 | explicit strstreambuf(streamsize __alsize = 0); | 154 | explicit strstreambuf(streamsize __alsize = 0); |
| 154 | #endif | 155 | # endif |
| 155 | strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); | 156 | strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); |
| 156 | strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); | 157 | strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); |
| 157 | strstreambuf(const char* __gnext, streamsize __n); | 158 | strstreambuf(const char* __gnext, streamsize __n); |
| ... | @@ -161,10 +162,10 @@ public: | ... | @@ -161,10 +162,10 @@ public: |
| 161 | strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); | 162 | strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); |
| 162 | strstreambuf(const unsigned char* __gnext, streamsize __n); | 163 | strstreambuf(const unsigned char* __gnext, streamsize __n); |
| 163 | 164 | ||
| 164 | #ifndef _LIBCPP_CXX03_LANG | 165 | # ifndef _LIBCPP_CXX03_LANG |
| 165 | _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs); | 166 | _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs); |
| 166 | _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs); | 167 | _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs); |
| 167 | #endif // _LIBCPP_CXX03_LANG | 168 | # endif // _LIBCPP_CXX03_LANG |
| 168 | 169 | ||
| 169 | ~strstreambuf() override; | 170 | ~strstreambuf() override; |
| 170 | 171 | ||
| ... | @@ -198,7 +199,7 @@ private: | ... | @@ -198,7 +199,7 @@ private: |
| 198 | void __init(char* __gnext, streamsize __n, char* __pbeg); | 199 | void __init(char* __gnext, streamsize __n, char* __pbeg); |
| 199 | }; | 200 | }; |
| 200 | 201 | ||
| 201 | #ifndef _LIBCPP_CXX03_LANG | 202 | # ifndef _LIBCPP_CXX03_LANG |
| 202 | 203 | ||
| 203 | inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs) | 204 | inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs) |
| 204 | : streambuf(__rhs), | 205 | : streambuf(__rhs), |
| ... | @@ -227,7 +228,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf& | ... | @@ -227,7 +228,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf& |
| 227 | return *this; | 228 | return *this; |
| 228 | } | 229 | } |
| 229 | 230 | ||
| 230 | #endif // _LIBCPP_CXX03_LANG | 231 | # endif // _LIBCPP_CXX03_LANG |
| 231 | 232 | ||
| 232 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream { | 233 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream { |
| 233 | public: | 234 | public: |
| ... | @@ -236,7 +237,7 @@ public: | ... | @@ -236,7 +237,7 @@ public: |
| 236 | _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} | 237 | _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} |
| 237 | _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} | 238 | _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} |
| 238 | 239 | ||
| 239 | #ifndef _LIBCPP_CXX03_LANG | 240 | # ifndef _LIBCPP_CXX03_LANG |
| 240 | _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension | 241 | _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension |
| 241 | : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { | 242 | : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 242 | istream::set_rdbuf(&__sb_); | 243 | istream::set_rdbuf(&__sb_); |
| ... | @@ -247,7 +248,7 @@ public: | ... | @@ -247,7 +248,7 @@ public: |
| 247 | istream::operator=(std::move(__rhs)); | 248 | istream::operator=(std::move(__rhs)); |
| 248 | return *this; | 249 | return *this; |
| 249 | } | 250 | } |
| 250 | #endif // _LIBCPP_CXX03_LANG | 251 | # endif // _LIBCPP_CXX03_LANG |
| 251 | 252 | ||
| 252 | ~istrstream() override; | 253 | ~istrstream() override; |
| 253 | 254 | ||
| ... | @@ -269,7 +270,7 @@ public: | ... | @@ -269,7 +270,7 @@ public: |
| 269 | _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) | 270 | _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) |
| 270 | : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} | 271 | : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} |
| 271 | 272 | ||
| 272 | #ifndef _LIBCPP_CXX03_LANG | 273 | # ifndef _LIBCPP_CXX03_LANG |
| 273 | _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension | 274 | _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension |
| 274 | : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { | 275 | : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 275 | ostream::set_rdbuf(&__sb_); | 276 | ostream::set_rdbuf(&__sb_); |
| ... | @@ -280,7 +281,7 @@ public: | ... | @@ -280,7 +281,7 @@ public: |
| 280 | ostream::operator=(std::move(__rhs)); | 281 | ostream::operator=(std::move(__rhs)); |
| 281 | return *this; | 282 | return *this; |
| 282 | } | 283 | } |
| 283 | #endif // _LIBCPP_CXX03_LANG | 284 | # endif // _LIBCPP_CXX03_LANG |
| 284 | 285 | ||
| 285 | ~ostrstream() override; | 286 | ~ostrstream() override; |
| 286 | 287 | ||
| ... | @@ -311,7 +312,7 @@ public: | ... | @@ -311,7 +312,7 @@ public: |
| 311 | _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) | 312 | _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) |
| 312 | : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} | 313 | : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} |
| 313 | 314 | ||
| 314 | #ifndef _LIBCPP_CXX03_LANG | 315 | # ifndef _LIBCPP_CXX03_LANG |
| 315 | _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension | 316 | _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension |
| 316 | : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { | 317 | : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 317 | iostream::set_rdbuf(&__sb_); | 318 | iostream::set_rdbuf(&__sb_); |
| ... | @@ -322,7 +323,7 @@ public: | ... | @@ -322,7 +323,7 @@ public: |
| 322 | iostream::operator=(std::move(__rhs)); | 323 | iostream::operator=(std::move(__rhs)); |
| 323 | return *this; | 324 | return *this; |
| 324 | } | 325 | } |
| 325 | #endif // _LIBCPP_CXX03_LANG | 326 | # endif // _LIBCPP_CXX03_LANG |
| 326 | 327 | ||
| 327 | ~strstream() override; | 328 | ~strstream() override; |
| 328 | 329 | ||
| ... | @@ -345,4 +346,6 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -345,4 +346,6 @@ _LIBCPP_END_NAMESPACE_STD |
| 345 | 346 | ||
| 346 | _LIBCPP_POP_MACROS | 347 | _LIBCPP_POP_MACROS |
| 347 | 348 | ||
| 349 | #endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 350 | |||
| 348 | #endif // _LIBCPP_STRSTREAM | 351 | #endif // _LIBCPP_STRSTREAM |
lib/libcxx/include/syncstream+2| ... | @@ -117,7 +117,9 @@ namespace std { | ... | @@ -117,7 +117,9 @@ namespace std { |
| 117 | 117 | ||
| 118 | #include <__config> | 118 | #include <__config> |
| 119 | #include <__utility/move.h> | 119 | #include <__utility/move.h> |
| 120 | #include <ios> | ||
| 120 | #include <iosfwd> // required for declaration of default arguments | 121 | #include <iosfwd> // required for declaration of default arguments |
| 122 | #include <streambuf> | ||
| 121 | #include <string> | 123 | #include <string> |
| 122 | 124 | ||
| 123 | #ifndef _LIBCPP_HAS_NO_THREADS | 125 | #ifndef _LIBCPP_HAS_NO_THREADS |
lib/libcxx/include/system_error-1| ... | @@ -144,7 +144,6 @@ template <> struct hash<std::error_condition>; | ... | @@ -144,7 +144,6 @@ template <> struct hash<std::error_condition>; |
| 144 | 144 | ||
| 145 | */ | 145 | */ |
| 146 | 146 | ||
| 147 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 148 | #include <__config> | 147 | #include <__config> |
| 149 | #include <__system_error/errc.h> | 148 | #include <__system_error/errc.h> |
| 150 | #include <__system_error/error_category.h> | 149 | #include <__system_error/error_category.h> |
lib/libcxx/include/thread+13-15| ... | @@ -88,27 +88,25 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); | ... | @@ -88,27 +88,25 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
| 88 | 88 | ||
| 89 | #include <__config> | 89 | #include <__config> |
| 90 | 90 | ||
| 91 | #ifdef _LIBCPP_HAS_NO_THREADS | 91 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 92 | # error "<thread> is not supported since libc++ has been configured without support for threads." | ||
| 93 | #endif | ||
| 94 | 92 | ||
| 95 | #include <__assert> // all public C++ headers provide the assertion handler | 93 | # include <__thread/formatter.h> |
| 96 | #include <__availability> | 94 | # include <__thread/jthread.h> |
| 97 | #include <__thread/formatter.h> | 95 | # include <__thread/support.h> |
| 98 | #include <__thread/jthread.h> | 96 | # include <__thread/this_thread.h> |
| 99 | #include <__thread/this_thread.h> | 97 | # include <__thread/thread.h> |
| 100 | #include <__thread/thread.h> | 98 | # include <version> |
| 101 | #include <__threading_support> | ||
| 102 | #include <version> | ||
| 103 | 99 | ||
| 104 | // standard-mandated includes | 100 | // standard-mandated includes |
| 105 | 101 | ||
| 106 | // [thread.syn] | 102 | // [thread.syn] |
| 107 | #include <compare> | 103 | # include <compare> |
| 108 | 104 | ||
| 109 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 105 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 110 | # pragma GCC system_header | 106 | # pragma GCC system_header |
| 111 | #endif | 107 | # endif |
| 108 | |||
| 109 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | ||
| 112 | 110 | ||
| 113 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | 111 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) |
| 114 | # include <cstddef> | 112 | # include <cstddef> |
lib/libcxx/include/tuple+127-171| ... | @@ -132,7 +132,12 @@ tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++ | ... | @@ -132,7 +132,12 @@ tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++ |
| 132 | template <class Alloc, class ...T> | 132 | template <class Alloc, class ...T> |
| 133 | tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17 | 133 | tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17 |
| 134 | 134 | ||
| 135 | inline constexpr unspecified ignore; | 135 | struct ignore-type { // exposition only // Since C++26 |
| 136 | constexpr const ignore-type& | ||
| 137 | operator=(const auto &) const noexcept | ||
| 138 | { return *this; } | ||
| 139 | }; | ||
| 140 | inline constexpr ignore-type ignore; | ||
| 136 | 141 | ||
| 137 | template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 | 142 | template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 |
| 138 | template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14 | 143 | template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14 |
| ... | @@ -205,16 +210,17 @@ template <class... Types> | ... | @@ -205,16 +210,17 @@ template <class... Types> |
| 205 | 210 | ||
| 206 | // clang-format on | 211 | // clang-format on |
| 207 | 212 | ||
| 208 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 209 | #include <__compare/common_comparison_category.h> | 213 | #include <__compare/common_comparison_category.h> |
| 210 | #include <__compare/synth_three_way.h> | 214 | #include <__compare/synth_three_way.h> |
| 211 | #include <__config> | 215 | #include <__config> |
| 212 | #include <__functional/invoke.h> | 216 | #include <__functional/invoke.h> |
| 213 | #include <__fwd/array.h> | 217 | #include <__fwd/array.h> |
| 214 | #include <__fwd/get.h> | 218 | #include <__fwd/pair.h> |
| 215 | #include <__fwd/tuple.h> | 219 | #include <__fwd/tuple.h> |
| 216 | #include <__memory/allocator_arg_t.h> | 220 | #include <__memory/allocator_arg_t.h> |
| 217 | #include <__memory/uses_allocator.h> | 221 | #include <__memory/uses_allocator.h> |
| 222 | #include <__tuple/find_index.h> | ||
| 223 | #include <__tuple/ignore.h> | ||
| 218 | #include <__tuple/make_tuple_types.h> | 224 | #include <__tuple/make_tuple_types.h> |
| 219 | #include <__tuple/sfinae_helpers.h> | 225 | #include <__tuple/sfinae_helpers.h> |
| 220 | #include <__tuple/tuple_element.h> | 226 | #include <__tuple/tuple_element.h> |
| ... | @@ -222,7 +228,6 @@ template <class... Types> | ... | @@ -222,7 +228,6 @@ template <class... Types> |
| 222 | #include <__tuple/tuple_like_ext.h> | 228 | #include <__tuple/tuple_like_ext.h> |
| 223 | #include <__tuple/tuple_size.h> | 229 | #include <__tuple/tuple_size.h> |
| 224 | #include <__tuple/tuple_types.h> | 230 | #include <__tuple/tuple_types.h> |
| 225 | #include <__type_traits/apply_cv.h> | ||
| 226 | #include <__type_traits/common_reference.h> | 231 | #include <__type_traits/common_reference.h> |
| 227 | #include <__type_traits/common_type.h> | 232 | #include <__type_traits/common_type.h> |
| 228 | #include <__type_traits/conditional.h> | 233 | #include <__type_traits/conditional.h> |
| ... | @@ -233,23 +238,15 @@ template <class... Types> | ... | @@ -233,23 +238,15 @@ template <class... Types> |
| 233 | #include <__type_traits/is_assignable.h> | 238 | #include <__type_traits/is_assignable.h> |
| 234 | #include <__type_traits/is_constructible.h> | 239 | #include <__type_traits/is_constructible.h> |
| 235 | #include <__type_traits/is_convertible.h> | 240 | #include <__type_traits/is_convertible.h> |
| 236 | #include <__type_traits/is_copy_assignable.h> | ||
| 237 | #include <__type_traits/is_copy_constructible.h> | ||
| 238 | #include <__type_traits/is_default_constructible.h> | ||
| 239 | #include <__type_traits/is_empty.h> | 241 | #include <__type_traits/is_empty.h> |
| 240 | #include <__type_traits/is_final.h> | 242 | #include <__type_traits/is_final.h> |
| 241 | #include <__type_traits/is_implicitly_default_constructible.h> | 243 | #include <__type_traits/is_implicitly_default_constructible.h> |
| 242 | #include <__type_traits/is_move_assignable.h> | ||
| 243 | #include <__type_traits/is_move_constructible.h> | ||
| 244 | #include <__type_traits/is_nothrow_assignable.h> | 244 | #include <__type_traits/is_nothrow_assignable.h> |
| 245 | #include <__type_traits/is_nothrow_constructible.h> | 245 | #include <__type_traits/is_nothrow_constructible.h> |
| 246 | #include <__type_traits/is_nothrow_copy_assignable.h> | ||
| 247 | #include <__type_traits/is_nothrow_copy_constructible.h> | ||
| 248 | #include <__type_traits/is_nothrow_default_constructible.h> | ||
| 249 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 250 | #include <__type_traits/is_reference.h> | 246 | #include <__type_traits/is_reference.h> |
| 251 | #include <__type_traits/is_same.h> | 247 | #include <__type_traits/is_same.h> |
| 252 | #include <__type_traits/is_swappable.h> | 248 | #include <__type_traits/is_swappable.h> |
| 249 | #include <__type_traits/is_trivially_relocatable.h> | ||
| 253 | #include <__type_traits/lazy.h> | 250 | #include <__type_traits/lazy.h> |
| 254 | #include <__type_traits/maybe_const.h> | 251 | #include <__type_traits/maybe_const.h> |
| 255 | #include <__type_traits/nat.h> | 252 | #include <__type_traits/nat.h> |
| ... | @@ -260,7 +257,6 @@ template <class... Types> | ... | @@ -260,7 +257,6 @@ template <class... Types> |
| 260 | #include <__utility/forward.h> | 257 | #include <__utility/forward.h> |
| 261 | #include <__utility/integer_sequence.h> | 258 | #include <__utility/integer_sequence.h> |
| 262 | #include <__utility/move.h> | 259 | #include <__utility/move.h> |
| 263 | #include <__utility/pair.h> | ||
| 264 | #include <__utility/piecewise_construct.h> | 260 | #include <__utility/piecewise_construct.h> |
| 265 | #include <__utility/swap.h> | 261 | #include <__utility/swap.h> |
| 266 | #include <cstddef> | 262 | #include <cstddef> |
| ... | @@ -289,15 +285,14 @@ class __tuple_leaf; | ... | @@ -289,15 +285,14 @@ class __tuple_leaf; |
| 289 | 285 | ||
| 290 | template <size_t _Ip, class _Hp, bool _Ep> | 286 | template <size_t _Ip, class _Hp, bool _Ep> |
| 291 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 287 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 292 | swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) | 288 | swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<_Hp>) { |
| 293 | _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value) { | ||
| 294 | swap(__x.get(), __y.get()); | 289 | swap(__x.get(), __y.get()); |
| 295 | } | 290 | } |
| 296 | 291 | ||
| 297 | template <size_t _Ip, class _Hp, bool _Ep> | 292 | template <size_t _Ip, class _Hp, bool _Ep> |
| 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 299 | swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y) | 294 | swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, |
| 300 | _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) { | 295 | const __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<const _Hp>) { |
| 301 | swap(__x.get(), __y.get()); | 296 | swap(__x.get(), __y.get()); |
| 302 | } | 297 | } |
| 303 | 298 | ||
| ... | @@ -314,10 +309,10 @@ class __tuple_leaf { | ... | @@ -314,10 +309,10 @@ class __tuple_leaf { |
| 314 | # endif | 309 | # endif |
| 315 | } | 310 | } |
| 316 | 311 | ||
| 317 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&); | ||
| 318 | |||
| 319 | public: | 312 | public: |
| 320 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() { | 313 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete; |
| 314 | |||
| 315 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) : __value_() { | ||
| 321 | static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple"); | 316 | static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple"); |
| 322 | } | 317 | } |
| 323 | 318 | ||
| ... | @@ -337,34 +332,34 @@ public: | ... | @@ -337,34 +332,34 @@ public: |
| 337 | static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple"); | 332 | static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple"); |
| 338 | } | 333 | } |
| 339 | 334 | ||
| 340 | template <class _Tp, | 335 | template < |
| 341 | class = __enable_if_t< | 336 | class _Tp, |
| 342 | _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value > > | 337 | __enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value, int> = 0> |
| 343 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) | 338 | _LIBCPP_HIDE_FROM_ABI |
| 344 | _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) | 339 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value) |
| 345 | : __value_(std::forward<_Tp>(__t)) { | 340 | : __value_(std::forward<_Tp>(__t)) { |
| 346 | static_assert(__can_bind_reference<_Tp&&>(), | 341 | static_assert(__can_bind_reference<_Tp&&>(), |
| 347 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); | 342 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); |
| 348 | } | 343 | } |
| 349 | 344 | ||
| 350 | template <class _Tp, class _Alloc> | 345 | template <class _Tp, class _Alloc> |
| 351 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf( | 346 | _LIBCPP_HIDE_FROM_ABI |
| 352 | integral_constant<int, 0>, const _Alloc&, _Tp&& __t) | 347 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) |
| 353 | : __value_(std::forward<_Tp>(__t)) { | 348 | : __value_(std::forward<_Tp>(__t)) { |
| 354 | static_assert(__can_bind_reference<_Tp&&>(), | 349 | static_assert(__can_bind_reference<_Tp&&>(), |
| 355 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); | 350 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); |
| 356 | } | 351 | } |
| 357 | 352 | ||
| 358 | template <class _Tp, class _Alloc> | 353 | template <class _Tp, class _Alloc> |
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf( | 354 | _LIBCPP_HIDE_FROM_ABI |
| 360 | integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t) | 355 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t) |
| 361 | : __value_(allocator_arg_t(), __a, std::forward<_Tp>(__t)) { | 356 | : __value_(allocator_arg_t(), __a, std::forward<_Tp>(__t)) { |
| 362 | static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple"); | 357 | static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple"); |
| 363 | } | 358 | } |
| 364 | 359 | ||
| 365 | template <class _Tp, class _Alloc> | 360 | template <class _Tp, class _Alloc> |
| 366 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf( | 361 | _LIBCPP_HIDE_FROM_ABI |
| 367 | integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) | 362 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) |
| 368 | : __value_(std::forward<_Tp>(__t), __a) { | 363 | : __value_(std::forward<_Tp>(__t), __a) { |
| 369 | static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple"); | 364 | static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple"); |
| 370 | } | 365 | } |
| ... | @@ -372,14 +367,14 @@ public: | ... | @@ -372,14 +367,14 @@ public: |
| 372 | _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default; | 367 | _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default; |
| 373 | _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t) = default; | 368 | _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t) = default; |
| 374 | 369 | ||
| 375 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(__tuple_leaf& __t) | 370 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int |
| 376 | _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { | 371 | swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) { |
| 377 | std::swap(*this, __t); | 372 | std::swap(*this, __t); |
| 378 | return 0; | 373 | return 0; |
| 379 | } | 374 | } |
| 380 | 375 | ||
| 381 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __t) const | 376 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __t) const |
| 382 | _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) { | 377 | noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) { |
| 383 | std::swap(*this, __t); | 378 | std::swap(*this, __t); |
| 384 | return 0; | 379 | return 0; |
| 385 | } | 380 | } |
| ... | @@ -390,10 +385,10 @@ public: | ... | @@ -390,10 +385,10 @@ public: |
| 390 | 385 | ||
| 391 | template <size_t _Ip, class _Hp> | 386 | template <size_t _Ip, class _Hp> |
| 392 | class __tuple_leaf<_Ip, _Hp, true> : private _Hp { | 387 | class __tuple_leaf<_Ip, _Hp, true> : private _Hp { |
| 393 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&); | ||
| 394 | |||
| 395 | public: | 388 | public: |
| 396 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {} | 389 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete; |
| 390 | |||
| 391 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) {} | ||
| 397 | 392 | ||
| 398 | template <class _Alloc> | 393 | template <class _Alloc> |
| 399 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {} | 394 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {} |
| ... | @@ -406,10 +401,10 @@ public: | ... | @@ -406,10 +401,10 @@ public: |
| 406 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : _Hp(__a) {} | 401 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : _Hp(__a) {} |
| 407 | 402 | ||
| 408 | template <class _Tp, | 403 | template <class _Tp, |
| 409 | class = __enable_if_t< | 404 | __enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value, |
| 410 | _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value > > | 405 | int> = 0> |
| 411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) | 406 | _LIBCPP_HIDE_FROM_ABI |
| 412 | _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) | 407 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value) |
| 413 | : _Hp(std::forward<_Tp>(__t)) {} | 408 | : _Hp(std::forward<_Tp>(__t)) {} |
| 414 | 409 | ||
| 415 | template <class _Tp, class _Alloc> | 410 | template <class _Tp, class _Alloc> |
| ... | @@ -427,14 +422,14 @@ public: | ... | @@ -427,14 +422,14 @@ public: |
| 427 | __tuple_leaf(__tuple_leaf const&) = default; | 422 | __tuple_leaf(__tuple_leaf const&) = default; |
| 428 | __tuple_leaf(__tuple_leaf&&) = default; | 423 | __tuple_leaf(__tuple_leaf&&) = default; |
| 429 | 424 | ||
| 430 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(__tuple_leaf& __t) | 425 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int |
| 431 | _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { | 426 | swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) { |
| 432 | std::swap(*this, __t); | 427 | std::swap(*this, __t); |
| 433 | return 0; | 428 | return 0; |
| 434 | } | 429 | } |
| 435 | 430 | ||
| 436 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __rhs) const | 431 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __rhs) const |
| 437 | _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) { | 432 | noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) { |
| 438 | std::swap(*this, __rhs); | 433 | std::swap(*this, __rhs); |
| 439 | return 0; | 434 | return 0; |
| 440 | } | 435 | } |
| ... | @@ -462,14 +457,17 @@ struct __tuple_impl; | ... | @@ -462,14 +457,17 @@ struct __tuple_impl; |
| 462 | template <size_t... _Indx, class... _Tp> | 457 | template <size_t... _Indx, class... _Tp> |
| 463 | struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...> | 458 | struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...> |
| 464 | : public __tuple_leaf<_Indx, _Tp>... { | 459 | : public __tuple_leaf<_Indx, _Tp>... { |
| 465 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() | 460 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept( |
| 466 | _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {} | 461 | __all<is_nothrow_default_constructible<_Tp>::value...>::value) {} |
| 467 | 462 | ||
| 468 | template <size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up> | 463 | template <size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up> |
| 469 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl( | 464 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl( |
| 470 | __tuple_indices<_Uf...>, __tuple_types<_Tf...>, __tuple_indices<_Ul...>, __tuple_types<_Tl...>, _Up&&... __u) | 465 | __tuple_indices<_Uf...>, |
| 471 | _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value && | 466 | __tuple_types<_Tf...>, |
| 472 | __all<is_nothrow_default_constructible<_Tl>::value...>::value)) | 467 | __tuple_indices<_Ul...>, |
| 468 | __tuple_types<_Tl...>, | ||
| 469 | _Up&&... __u) noexcept(__all<is_nothrow_constructible<_Tf, _Up>::value...>::value && | ||
| 470 | __all<is_nothrow_default_constructible<_Tl>::value...>::value) | ||
| 473 | : __tuple_leaf<_Uf, _Tf>(std::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {} | 471 | : __tuple_leaf<_Uf, _Tf>(std::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {} |
| 474 | 472 | ||
| 475 | template <class _Alloc, size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up> | 473 | template <class _Alloc, size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up> |
| ... | @@ -484,8 +482,8 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. | ... | @@ -484,8 +482,8 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. |
| 484 | : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, std::forward<_Up>(__u))..., | 482 | : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, std::forward<_Up>(__u))..., |
| 485 | __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {} | 483 | __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {} |
| 486 | 484 | ||
| 487 | template <class _Tuple, class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value> > | 485 | template <class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0> |
| 488 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) _NOEXCEPT_( | 486 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) noexcept( |
| 489 | (__all<is_nothrow_constructible< | 487 | (__all<is_nothrow_constructible< |
| 490 | _Tp, | 488 | _Tp, |
| 491 | typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) | 489 | typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) |
| ... | @@ -493,7 +491,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. | ... | @@ -493,7 +491,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. |
| 493 | std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>( | 491 | std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>( |
| 494 | std::get<_Indx>(__t)))... {} | 492 | std::get<_Indx>(__t)))... {} |
| 495 | 493 | ||
| 496 | template <class _Alloc, class _Tuple, class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value> > | 494 | template <class _Alloc, class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0> |
| 497 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) | 495 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) |
| 498 | : __tuple_leaf<_Indx, _Tp>( | 496 | : __tuple_leaf<_Indx, _Tp>( |
| 499 | __uses_alloc_ctor<_Tp, | 497 | __uses_alloc_ctor<_Tp, |
| ... | @@ -506,13 +504,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. | ... | @@ -506,13 +504,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. |
| 506 | __tuple_impl(const __tuple_impl&) = default; | 504 | __tuple_impl(const __tuple_impl&) = default; |
| 507 | __tuple_impl(__tuple_impl&&) = default; | 505 | __tuple_impl(__tuple_impl&&) = default; |
| 508 | 506 | ||
| 509 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__tuple_impl& __t) | 507 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 510 | _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) { | 508 | swap(__tuple_impl& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { |
| 511 | std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...); | 509 | std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...); |
| 512 | } | 510 | } |
| 513 | 511 | ||
| 514 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(const __tuple_impl& __t) const | 512 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(const __tuple_impl& __t) const |
| 515 | _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value) { | 513 | noexcept(__all<__is_nothrow_swappable_v<const _Tp>...>::value) { |
| 516 | std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...); | 514 | std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...); |
| 517 | } | 515 | } |
| 518 | }; | 516 | }; |
| ... | @@ -548,18 +546,16 @@ class _LIBCPP_TEMPLATE_VIS tuple { | ... | @@ -548,18 +546,16 @@ class _LIBCPP_TEMPLATE_VIS tuple { |
| 548 | get(const tuple<_Up...>&&) _NOEXCEPT; | 546 | get(const tuple<_Up...>&&) _NOEXCEPT; |
| 549 | 547 | ||
| 550 | public: | 548 | public: |
| 551 | // [tuple.cnstr] | 549 | using __trivially_relocatable = __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; |
| 552 | 550 | ||
| 553 | _LIBCPP_DIAGNOSTIC_PUSH | 551 | // [tuple.cnstr] |
| 554 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") | ||
| 555 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") | ||
| 556 | 552 | ||
| 557 | // tuple() constructors (including allocator_arg_t variants) | 553 | // tuple() constructors (including allocator_arg_t variants) |
| 558 | template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible, | 554 | template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible, |
| 559 | template <class...> class _IsDefault = is_default_constructible, | 555 | template <class...> class _IsDefault = is_default_constructible, |
| 560 | __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0> | 556 | __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0> |
| 561 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) tuple() | 557 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) |
| 562 | _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value) {} | 558 | tuple() noexcept(_And<is_nothrow_default_constructible<_Tp>...>::value) {} |
| 563 | 559 | ||
| 564 | template <class _Alloc, | 560 | template <class _Alloc, |
| 565 | template <class...> class _IsImpDefault = __is_implicitly_default_constructible, | 561 | template <class...> class _IsImpDefault = __is_implicitly_default_constructible, |
| ... | @@ -577,9 +573,9 @@ public: | ... | @@ -577,9 +573,9 @@ public: |
| 577 | // tuple(const T&...) constructors (including allocator_arg_t variants) | 573 | // tuple(const T&...) constructors (including allocator_arg_t variants) |
| 578 | template <template <class...> class _And = _And, | 574 | template <template <class...> class _And = _And, |
| 579 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0> | 575 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0> |
| 580 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit( | 576 | _LIBCPP_HIDE_FROM_ABI |
| 581 | _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) tuple(const _Tp&... __t) | 577 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) |
| 582 | _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value) | 578 | tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value) |
| 583 | : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), | 579 | : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), |
| 584 | typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), | 580 | typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), |
| 585 | typename __make_tuple_indices<0>::type(), | 581 | typename __make_tuple_indices<0>::type(), |
| ... | @@ -589,8 +585,8 @@ public: | ... | @@ -589,8 +585,8 @@ public: |
| 589 | template <class _Alloc, | 585 | template <class _Alloc, |
| 590 | template <class...> class _And = _And, | 586 | template <class...> class _And = _And, |
| 591 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0> | 587 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0> |
| 592 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit( | 588 | _LIBCPP_HIDE_FROM_ABI |
| 593 | _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) | 589 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) |
| 594 | tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t) | 590 | tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t) |
| 595 | : __base_(allocator_arg_t(), | 591 | : __base_(allocator_arg_t(), |
| 596 | __a, | 592 | __a, |
| ... | @@ -616,7 +612,7 @@ public: | ... | @@ -616,7 +612,7 @@ public: |
| 616 | __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value, | 612 | __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value, |
| 617 | int> = 0> | 613 | int> = 0> |
| 618 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) | 614 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) |
| 619 | tuple(_Up&&... __u) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value)) | 615 | tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value) |
| 620 | : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), | 616 | : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), |
| 621 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), | 617 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), |
| 622 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), | 618 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), |
| ... | @@ -681,16 +677,16 @@ public: | ... | @@ -681,16 +677,16 @@ public: |
| 681 | _Not<is_constructible<_Tp, _OtherTuple> >... > > > {}; | 677 | _Not<is_constructible<_Tp, _OtherTuple> >... > > > {}; |
| 682 | 678 | ||
| 683 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0> | 679 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0> |
| 684 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit( | 680 | _LIBCPP_HIDE_FROM_ABI |
| 685 | _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) tuple(const tuple<_Up...>& __t) | 681 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) |
| 686 | _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)) | 682 | tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value) |
| 687 | : __base_(__t) {} | 683 | : __base_(__t) {} |
| 688 | 684 | ||
| 689 | template <class... _Up, | 685 | template <class... _Up, |
| 690 | class _Alloc, | 686 | class _Alloc, |
| 691 | __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0> | 687 | __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0> |
| 692 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit( | 688 | _LIBCPP_HIDE_FROM_ABI |
| 693 | _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) | 689 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) |
| 694 | tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) | 690 | tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) |
| 695 | : __base_(allocator_arg_t(), __a, __t) {} | 691 | : __base_(allocator_arg_t(), __a, __t) {} |
| 696 | 692 | ||
| ... | @@ -710,7 +706,7 @@ public: | ... | @@ -710,7 +706,7 @@ public: |
| 710 | // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) | 706 | // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) |
| 711 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> | 707 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> |
| 712 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) | 708 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) |
| 713 | tuple(tuple<_Up...>&& __t) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value)) | 709 | tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value) |
| 714 | : __base_(std::move(__t)) {} | 710 | : __base_(std::move(__t)) {} |
| 715 | 711 | ||
| 716 | template <class _Alloc, | 712 | template <class _Alloc, |
| ... | @@ -765,9 +761,9 @@ public: | ... | @@ -765,9 +761,9 @@ public: |
| 765 | class _Up2, | 761 | class _Up2, |
| 766 | template <class...> class _And = _And, | 762 | template <class...> class _And = _And, |
| 767 | __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0> | 763 | __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0> |
| 768 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit( | 764 | _LIBCPP_HIDE_FROM_ABI |
| 769 | _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) tuple(const pair<_Up1, _Up2>& __p) | 765 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) |
| 770 | _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)) | 766 | tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value) |
| 771 | : __base_(__p) {} | 767 | : __base_(__p) {} |
| 772 | 768 | ||
| 773 | template <class _Alloc, | 769 | template <class _Alloc, |
| ... | @@ -775,8 +771,8 @@ public: | ... | @@ -775,8 +771,8 @@ public: |
| 775 | class _Up2, | 771 | class _Up2, |
| 776 | template <class...> class _And = _And, | 772 | template <class...> class _And = _And, |
| 777 | __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0> | 773 | __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0> |
| 778 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit( | 774 | _LIBCPP_HIDE_FROM_ABI |
| 779 | _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) | 775 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) |
| 780 | tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) | 776 | tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) |
| 781 | : __base_(allocator_arg_t(), __a, __p) {} | 777 | : __base_(allocator_arg_t(), __a, __p) {} |
| 782 | 778 | ||
| ... | @@ -803,9 +799,9 @@ public: | ... | @@ -803,9 +799,9 @@ public: |
| 803 | class _Up2, | 799 | class _Up2, |
| 804 | template <class...> class _And = _And, | 800 | template <class...> class _And = _And, |
| 805 | __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0> | 801 | __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0> |
| 806 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit( | 802 | _LIBCPP_HIDE_FROM_ABI |
| 807 | _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) tuple(pair<_Up1, _Up2>&& __p) | 803 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) |
| 808 | _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)) | 804 | tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value) |
| 809 | : __base_(std::move(__p)) {} | 805 | : __base_(std::move(__p)) {} |
| 810 | 806 | ||
| 811 | template <class _Alloc, | 807 | template <class _Alloc, |
| ... | @@ -813,8 +809,8 @@ public: | ... | @@ -813,8 +809,8 @@ public: |
| 813 | class _Up2, | 809 | class _Up2, |
| 814 | template <class...> class _And = _And, | 810 | template <class...> class _And = _And, |
| 815 | __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0> | 811 | __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0> |
| 816 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit( | 812 | _LIBCPP_HIDE_FROM_ABI |
| 817 | _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) | 813 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) |
| 818 | tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) | 814 | tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) |
| 819 | : __base_(allocator_arg_t(), __a, std::move(__p)) {} | 815 | : __base_(allocator_arg_t(), __a, std::move(__p)) {} |
| 820 | 816 | ||
| ... | @@ -835,12 +831,10 @@ public: | ... | @@ -835,12 +831,10 @@ public: |
| 835 | : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} | 831 | : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} |
| 836 | # endif // _LIBCPP_STD_VER >= 23 | 832 | # endif // _LIBCPP_STD_VER >= 23 |
| 837 | 833 | ||
| 838 | _LIBCPP_DIAGNOSTIC_POP | ||
| 839 | |||
| 840 | // [tuple.assign] | 834 | // [tuple.assign] |
| 841 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 835 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 842 | operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) | 836 | operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) |
| 843 | _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value)) { | 837 | noexcept(_And<is_nothrow_copy_assignable<_Tp>...>::value) { |
| 844 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 838 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 845 | return *this; | 839 | return *this; |
| 846 | } | 840 | } |
| ... | @@ -864,7 +858,7 @@ public: | ... | @@ -864,7 +858,7 @@ public: |
| 864 | 858 | ||
| 865 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 859 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 866 | operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) | 860 | operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) |
| 867 | _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value)) { | 861 | noexcept(_And<is_nothrow_move_assignable<_Tp>...>::value) { |
| 868 | std::__memberwise_forward_assign( | 862 | std::__memberwise_forward_assign( |
| 869 | *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 863 | *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 870 | return *this; | 864 | return *this; |
| ... | @@ -875,7 +869,7 @@ public: | ... | @@ -875,7 +869,7 @@ public: |
| 875 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value, | 869 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value, |
| 876 | int> = 0> | 870 | int> = 0> |
| 877 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple) | 871 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple) |
| 878 | _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value)) { | 872 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { |
| 879 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 873 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 880 | return *this; | 874 | return *this; |
| 881 | } | 875 | } |
| ... | @@ -884,7 +878,7 @@ public: | ... | @@ -884,7 +878,7 @@ public: |
| 884 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value, | 878 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value, |
| 885 | int> = 0> | 879 | int> = 0> |
| 886 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple) | 880 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple) |
| 887 | _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value)) { | 881 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { |
| 888 | std::__memberwise_forward_assign( | 882 | std::__memberwise_forward_assign( |
| 889 | *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 883 | *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 890 | return *this; | 884 | return *this; |
| ... | @@ -949,7 +943,7 @@ public: | ... | @@ -949,7 +943,7 @@ public: |
| 949 | class _Up2, | 943 | class _Up2, |
| 950 | __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0> | 944 | __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0> |
| 951 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2> const& __pair) | 945 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2> const& __pair) |
| 952 | _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value)) { | 946 | noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) { |
| 953 | std::get<0>(*this) = __pair.first; | 947 | std::get<0>(*this) = __pair.first; |
| 954 | std::get<1>(*this) = __pair.second; | 948 | std::get<1>(*this) = __pair.second; |
| 955 | return *this; | 949 | return *this; |
| ... | @@ -957,7 +951,7 @@ public: | ... | @@ -957,7 +951,7 @@ public: |
| 957 | 951 | ||
| 958 | template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0> | 952 | template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0> |
| 959 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2>&& __pair) | 953 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2>&& __pair) |
| 960 | _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value)) { | 954 | noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) { |
| 961 | std::get<0>(*this) = std::forward<_Up1>(__pair.first); | 955 | std::get<0>(*this) = std::forward<_Up1>(__pair.first); |
| 962 | std::get<1>(*this) = std::forward<_Up2>(__pair.second); | 956 | std::get<1>(*this) = std::forward<_Up2>(__pair.second); |
| 963 | return *this; | 957 | return *this; |
| ... | @@ -967,9 +961,9 @@ public: | ... | @@ -967,9 +961,9 @@ public: |
| 967 | template < | 961 | template < |
| 968 | class _Up, | 962 | class _Up, |
| 969 | size_t _Np, | 963 | size_t _Np, |
| 970 | class = __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value > > | 964 | __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> |
| 971 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array) | 965 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array) |
| 972 | _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value)) { | 966 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { |
| 973 | std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 967 | std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 974 | return *this; | 968 | return *this; |
| 975 | } | 969 | } |
| ... | @@ -978,9 +972,9 @@ public: | ... | @@ -978,9 +972,9 @@ public: |
| 978 | template <class _Up, | 972 | template <class _Up, |
| 979 | size_t _Np, | 973 | size_t _Np, |
| 980 | class = void, | 974 | class = void, |
| 981 | class = __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value > > | 975 | __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0> |
| 982 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array) | 976 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array) |
| 983 | _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value)) { | 977 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { |
| 984 | std::__memberwise_forward_assign( | 978 | std::__memberwise_forward_assign( |
| 985 | *this, | 979 | *this, |
| 986 | std::move(__array), | 980 | std::move(__array), |
| ... | @@ -991,7 +985,7 @@ public: | ... | @@ -991,7 +985,7 @@ public: |
| 991 | 985 | ||
| 992 | // [tuple.swap] | 986 | // [tuple.swap] |
| 993 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple& __t) | 987 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple& __t) |
| 994 | _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) { | 988 | noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { |
| 995 | __base_.swap(__t.__base_); | 989 | __base_.swap(__t.__base_); |
| 996 | } | 990 | } |
| 997 | 991 | ||
| ... | @@ -1048,9 +1042,9 @@ template <class _Alloc, class... _Tp> | ... | @@ -1048,9 +1042,9 @@ template <class _Alloc, class... _Tp> |
| 1048 | tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; | 1042 | tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; |
| 1049 | # endif | 1043 | # endif |
| 1050 | 1044 | ||
| 1051 | template <class... _Tp, __enable_if_t<__all<__is_swappable<_Tp>::value...>::value, int> = 0> | 1045 | template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0> |
| 1052 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) | 1046 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) |
| 1053 | _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) { | 1047 | noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { |
| 1054 | __t.swap(__u); | 1048 | __t.swap(__u); |
| 1055 | } | 1049 | } |
| 1056 | 1050 | ||
| ... | @@ -1095,40 +1089,6 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT { | ... | @@ -1095,40 +1089,6 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT { |
| 1095 | 1089 | ||
| 1096 | # if _LIBCPP_STD_VER >= 14 | 1090 | # if _LIBCPP_STD_VER >= 14 |
| 1097 | 1091 | ||
| 1098 | namespace __find_detail { | ||
| 1099 | |||
| 1100 | static constexpr size_t __not_found = static_cast<size_t>(-1); | ||
| 1101 | static constexpr size_t __ambiguous = __not_found - 1; | ||
| 1102 | |||
| 1103 | inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) { | ||
| 1104 | return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous); | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | template <size_t _Nx> | ||
| 1108 | inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) { | ||
| 1109 | return __i == _Nx | ||
| 1110 | ? __not_found | ||
| 1111 | : __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]); | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | template <class _T1, class... _Args> | ||
| 1115 | struct __find_exactly_one_checked { | ||
| 1116 | static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...}; | ||
| 1117 | static constexpr size_t value = __find_detail::__find_idx(0, __matches); | ||
| 1118 | static_assert(value != __not_found, "type not found in type list"); | ||
| 1119 | static_assert(value != __ambiguous, "type occurs more than once in type list"); | ||
| 1120 | }; | ||
| 1121 | |||
| 1122 | template <class _T1> | ||
| 1123 | struct __find_exactly_one_checked<_T1> { | ||
| 1124 | static_assert(!is_same<_T1, _T1>::value, "type not in empty type list"); | ||
| 1125 | }; | ||
| 1126 | |||
| 1127 | } // namespace __find_detail | ||
| 1128 | |||
| 1129 | template <typename _T1, typename... _Args> | ||
| 1130 | struct __find_exactly_one_t : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {}; | ||
| 1131 | |||
| 1132 | template <class _T1, class... _Args> | 1092 | template <class _T1, class... _Args> |
| 1133 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept { | 1093 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept { |
| 1134 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); | 1094 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); |
| ... | @@ -1158,22 +1118,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T | ... | @@ -1158,22 +1118,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T |
| 1158 | return tuple<_Tp&...>(__t...); | 1118 | return tuple<_Tp&...>(__t...); |
| 1159 | } | 1119 | } |
| 1160 | 1120 | ||
| 1161 | template <class _Up> | ||
| 1162 | struct __ignore_t { | ||
| 1163 | template <class _Tp> | ||
| 1164 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const __ignore_t& operator=(_Tp&&) const { | ||
| 1165 | return *this; | ||
| 1166 | } | ||
| 1167 | }; | ||
| 1168 | |||
| 1169 | # if _LIBCPP_STD_VER >= 17 | ||
| 1170 | inline constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); | ||
| 1171 | # else | ||
| 1172 | namespace { | ||
| 1173 | constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); | ||
| 1174 | } // namespace | ||
| 1175 | # endif | ||
| 1176 | |||
| 1177 | template <class... _Tp> | 1121 | template <class... _Tp> |
| 1178 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...> | 1122 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...> |
| 1179 | make_tuple(_Tp&&... __t) { | 1123 | make_tuple(_Tp&&... __t) { |
| ... | @@ -1336,14 +1280,14 @@ struct __tuple_cat_return_ref_imp; | ... | @@ -1336,14 +1280,14 @@ struct __tuple_cat_return_ref_imp; |
| 1336 | template <class... _Types, size_t... _I0, class _Tuple0> | 1280 | template <class... _Types, size_t... _I0, class _Tuple0> |
| 1337 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> { | 1281 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> { |
| 1338 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; | 1282 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; |
| 1339 | typedef tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type; | 1283 | typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type; |
| 1340 | }; | 1284 | }; |
| 1341 | 1285 | ||
| 1342 | template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples> | 1286 | template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples> |
| 1343 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...> | 1287 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...> |
| 1344 | : public __tuple_cat_return_ref_imp< | 1288 | : public __tuple_cat_return_ref_imp< |
| 1345 | tuple<_Types..., | 1289 | tuple<_Types..., |
| 1346 | __apply_cv_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>, | 1290 | __copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>, |
| 1347 | typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type, | 1291 | typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type, |
| 1348 | _Tuple1, | 1292 | _Tuple1, |
| 1349 | _Tuples...> {}; | 1293 | _Tuples...> {}; |
| ... | @@ -1363,8 +1307,8 @@ template <class... _Types, size_t... _I0, size_t... _J0> | ... | @@ -1363,8 +1307,8 @@ template <class... _Types, size_t... _I0, size_t... _J0> |
| 1363 | struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > { | 1307 | struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > { |
| 1364 | template <class _Tuple0> | 1308 | template <class _Tuple0> |
| 1365 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 1309 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 1366 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type | 1310 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type |
| 1367 | operator()(tuple<_Types...> __t, _Tuple0&& __t0) { | 1311 | operator()(tuple<_Types...> __t, _Tuple0&& __t0) { |
| 1368 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty | 1312 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty |
| 1369 | return std::forward_as_tuple( | 1313 | return std::forward_as_tuple( |
| 1370 | std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...); | 1314 | std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...); |
| ... | @@ -1372,12 +1316,12 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J | ... | @@ -1372,12 +1316,12 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1372 | 1316 | ||
| 1373 | template <class _Tuple0, class _Tuple1, class... _Tuples> | 1317 | template <class _Tuple0, class _Tuple1, class... _Tuples> |
| 1374 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 1318 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 1375 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type | 1319 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type |
| 1376 | operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) { | 1320 | operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) { |
| 1377 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty | 1321 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty |
| 1378 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; | 1322 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; |
| 1379 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1; | 1323 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1; |
| 1380 | return __tuple_cat<tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>, | 1324 | return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>, |
| 1381 | typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type, | 1325 | typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type, |
| 1382 | typename __make_tuple_indices<tuple_size<_T1>::value>::type>()( | 1326 | typename __make_tuple_indices<tuple_size<_T1>::value>::type>()( |
| 1383 | std::forward_as_tuple( | 1327 | std::forward_as_tuple( |
| ... | @@ -1398,21 +1342,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { | ... | @@ -1398,21 +1342,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { |
| 1398 | template <class... _Tp, class _Alloc> | 1342 | template <class... _Tp, class _Alloc> |
| 1399 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; | 1343 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; |
| 1400 | 1344 | ||
| 1401 | template <class _T1, class _T2> | ||
| 1402 | template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | ||
| 1403 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_T1, _T2>::pair( | ||
| 1404 | piecewise_construct_t, | ||
| 1405 | tuple<_Args1...>& __first_args, | ||
| 1406 | tuple<_Args2...>& __second_args, | ||
| 1407 | __tuple_indices<_I1...>, | ||
| 1408 | __tuple_indices<_I2...>) | ||
| 1409 | : first(std::forward<_Args1>(std::get<_I1>(__first_args))...), | ||
| 1410 | second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {} | ||
| 1411 | |||
| 1412 | # if _LIBCPP_STD_VER >= 17 | 1345 | # if _LIBCPP_STD_VER >= 17 |
| 1413 | template <class _Tp> | ||
| 1414 | inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; | ||
| 1415 | |||
| 1416 | # define _LIBCPP_NOEXCEPT_RETURN(...) \ | 1346 | # define _LIBCPP_NOEXCEPT_RETURN(...) \ |
| 1417 | noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } | 1347 | noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } |
| 1418 | 1348 | ||
| ... | @@ -1430,15 +1360,41 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& | ... | @@ -1430,15 +1360,41 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& |
| 1430 | std::forward<_Tuple>(__t), | 1360 | std::forward<_Tuple>(__t), |
| 1431 | typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})) | 1361 | typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})) |
| 1432 | 1362 | ||
| 1363 | #if _LIBCPP_STD_VER >= 20 | ||
| 1433 | template <class _Tp, class _Tuple, size_t... _Idx> | 1364 | template <class _Tp, class _Tuple, size_t... _Idx> |
| 1434 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) | 1365 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) |
| 1366 | noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))) | ||
| 1367 | requires is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> { | ||
| 1368 | return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); | ||
| 1369 | } | ||
| 1370 | #else | ||
| 1371 | template <class _Tp, class _Tuple, size_t... _Idx> | ||
| 1372 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>, | ||
| 1373 | enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr) | ||
| 1435 | _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)) | 1374 | _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)) |
| 1375 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 1376 | |||
| 1377 | template <class _Tp, class _Tuple, | ||
| 1378 | class _Seq = typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type, class = void> | ||
| 1379 | inline constexpr bool __can_make_from_tuple = false; | ||
| 1436 | 1380 | ||
| 1381 | template <class _Tp, class _Tuple, size_t... _Idx> | ||
| 1382 | inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>, | ||
| 1383 | enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true; | ||
| 1384 | |||
| 1385 | // Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9, | ||
| 1386 | // the standard allows to impose requirements, we constraint std::make_from_tuple to make std::make_from_tuple | ||
| 1387 | // SFINAE friendly and also avoid worse diagnostic messages. We still keep the constraints of std::__make_from_tuple_impl | ||
| 1388 | // so that std::__make_from_tuple_impl will have the same advantages when used alone. | ||
| 1389 | #if _LIBCPP_STD_VER >= 20 | ||
| 1437 | template <class _Tp, class _Tuple> | 1390 | template <class _Tp, class _Tuple> |
| 1391 | requires __can_make_from_tuple<_Tp, _Tuple> // strengthen | ||
| 1392 | #else | ||
| 1393 | template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp, _Tuple>>> // strengthen | ||
| 1394 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 1438 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t) | 1395 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t) |
| 1439 | _LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>( | 1396 | _LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>( |
| 1440 | std::forward<_Tuple>(__t), typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})) | 1397 | std::forward<_Tuple>(__t), typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})) |
| 1441 | |||
| 1442 | # undef _LIBCPP_NOEXCEPT_RETURN | 1398 | # undef _LIBCPP_NOEXCEPT_RETURN |
| 1443 | 1399 | ||
| 1444 | # endif // _LIBCPP_STD_VER >= 17 | 1400 | # endif // _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/type_traits+29-52| ... | @@ -416,9 +416,9 @@ namespace std | ... | @@ -416,9 +416,9 @@ namespace std |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | */ | 418 | */ |
| 419 | #include <__assert> // all public C++ headers provide the assertion handler | 419 | |
| 420 | #include <__config> | 420 | #include <__config> |
| 421 | #include <__fwd/hash.h> // This is https://llvm.org/PR56938 | 421 | #include <__fwd/functional.h> // This is https://llvm.org/PR56938 |
| 422 | #include <__type_traits/add_const.h> | 422 | #include <__type_traits/add_const.h> |
| 423 | #include <__type_traits/add_cv.h> | 423 | #include <__type_traits/add_cv.h> |
| 424 | #include <__type_traits/add_lvalue_reference.h> | 424 | #include <__type_traits/add_lvalue_reference.h> |
| ... | @@ -428,115 +428,92 @@ namespace std | ... | @@ -428,115 +428,92 @@ namespace std |
| 428 | #include <__type_traits/aligned_storage.h> | 428 | #include <__type_traits/aligned_storage.h> |
| 429 | #include <__type_traits/aligned_union.h> | 429 | #include <__type_traits/aligned_union.h> |
| 430 | #include <__type_traits/alignment_of.h> | 430 | #include <__type_traits/alignment_of.h> |
| 431 | #include <__type_traits/apply_cv.h> | ||
| 432 | #include <__type_traits/can_extract_key.h> | ||
| 433 | #include <__type_traits/common_reference.h> | ||
| 434 | #include <__type_traits/common_type.h> | 431 | #include <__type_traits/common_type.h> |
| 435 | #include <__type_traits/conditional.h> | 432 | #include <__type_traits/conditional.h> |
| 436 | #include <__type_traits/conjunction.h> | ||
| 437 | #include <__type_traits/decay.h> | 433 | #include <__type_traits/decay.h> |
| 438 | #include <__type_traits/dependent_type.h> | ||
| 439 | #include <__type_traits/disjunction.h> | ||
| 440 | #include <__type_traits/enable_if.h> | 434 | #include <__type_traits/enable_if.h> |
| 441 | #include <__type_traits/extent.h> | 435 | #include <__type_traits/extent.h> |
| 442 | #include <__type_traits/has_unique_object_representation.h> | ||
| 443 | #include <__type_traits/has_virtual_destructor.h> | 436 | #include <__type_traits/has_virtual_destructor.h> |
| 444 | #include <__type_traits/integral_constant.h> | 437 | #include <__type_traits/integral_constant.h> |
| 445 | #include <__type_traits/invoke.h> | ||
| 446 | #include <__type_traits/is_abstract.h> | 438 | #include <__type_traits/is_abstract.h> |
| 447 | #include <__type_traits/is_aggregate.h> | ||
| 448 | #include <__type_traits/is_arithmetic.h> | 439 | #include <__type_traits/is_arithmetic.h> |
| 449 | #include <__type_traits/is_array.h> | 440 | #include <__type_traits/is_array.h> |
| 450 | #include <__type_traits/is_assignable.h> | 441 | #include <__type_traits/is_assignable.h> |
| 451 | #include <__type_traits/is_base_of.h> | 442 | #include <__type_traits/is_base_of.h> |
| 452 | #include <__type_traits/is_bounded_array.h> | ||
| 453 | #include <__type_traits/is_callable.h> | ||
| 454 | #include <__type_traits/is_char_like_type.h> | ||
| 455 | #include <__type_traits/is_class.h> | 443 | #include <__type_traits/is_class.h> |
| 456 | #include <__type_traits/is_compound.h> | 444 | #include <__type_traits/is_compound.h> |
| 457 | #include <__type_traits/is_const.h> | 445 | #include <__type_traits/is_const.h> |
| 458 | #include <__type_traits/is_constant_evaluated.h> | ||
| 459 | #include <__type_traits/is_constructible.h> | 446 | #include <__type_traits/is_constructible.h> |
| 460 | #include <__type_traits/is_convertible.h> | 447 | #include <__type_traits/is_convertible.h> |
| 461 | #include <__type_traits/is_copy_assignable.h> | ||
| 462 | #include <__type_traits/is_copy_constructible.h> | ||
| 463 | #include <__type_traits/is_default_constructible.h> | ||
| 464 | #include <__type_traits/is_destructible.h> | 448 | #include <__type_traits/is_destructible.h> |
| 465 | #include <__type_traits/is_empty.h> | 449 | #include <__type_traits/is_empty.h> |
| 466 | #include <__type_traits/is_enum.h> | 450 | #include <__type_traits/is_enum.h> |
| 467 | #include <__type_traits/is_final.h> | ||
| 468 | #include <__type_traits/is_floating_point.h> | 451 | #include <__type_traits/is_floating_point.h> |
| 469 | #include <__type_traits/is_function.h> | 452 | #include <__type_traits/is_function.h> |
| 470 | #include <__type_traits/is_fundamental.h> | 453 | #include <__type_traits/is_fundamental.h> |
| 471 | #include <__type_traits/is_implicitly_default_constructible.h> | ||
| 472 | #include <__type_traits/is_integral.h> | 454 | #include <__type_traits/is_integral.h> |
| 473 | #include <__type_traits/is_literal_type.h> | 455 | #include <__type_traits/is_literal_type.h> |
| 474 | #include <__type_traits/is_member_function_pointer.h> | ||
| 475 | #include <__type_traits/is_member_object_pointer.h> | ||
| 476 | #include <__type_traits/is_member_pointer.h> | 456 | #include <__type_traits/is_member_pointer.h> |
| 477 | #include <__type_traits/is_move_assignable.h> | ||
| 478 | #include <__type_traits/is_move_constructible.h> | ||
| 479 | #include <__type_traits/is_nothrow_assignable.h> | 457 | #include <__type_traits/is_nothrow_assignable.h> |
| 480 | #include <__type_traits/is_nothrow_constructible.h> | 458 | #include <__type_traits/is_nothrow_constructible.h> |
| 481 | #include <__type_traits/is_nothrow_convertible.h> | ||
| 482 | #include <__type_traits/is_nothrow_copy_assignable.h> | ||
| 483 | #include <__type_traits/is_nothrow_copy_constructible.h> | ||
| 484 | #include <__type_traits/is_nothrow_default_constructible.h> | ||
| 485 | #include <__type_traits/is_nothrow_destructible.h> | 459 | #include <__type_traits/is_nothrow_destructible.h> |
| 486 | #include <__type_traits/is_nothrow_move_assignable.h> | ||
| 487 | #include <__type_traits/is_nothrow_move_constructible.h> | ||
| 488 | #include <__type_traits/is_null_pointer.h> | ||
| 489 | #include <__type_traits/is_object.h> | 460 | #include <__type_traits/is_object.h> |
| 490 | #include <__type_traits/is_pod.h> | 461 | #include <__type_traits/is_pod.h> |
| 491 | #include <__type_traits/is_pointer.h> | 462 | #include <__type_traits/is_pointer.h> |
| 492 | #include <__type_traits/is_polymorphic.h> | 463 | #include <__type_traits/is_polymorphic.h> |
| 493 | #include <__type_traits/is_reference.h> | 464 | #include <__type_traits/is_reference.h> |
| 494 | #include <__type_traits/is_reference_wrapper.h> | ||
| 495 | #include <__type_traits/is_referenceable.h> | ||
| 496 | #include <__type_traits/is_same.h> | 465 | #include <__type_traits/is_same.h> |
| 497 | #include <__type_traits/is_scalar.h> | 466 | #include <__type_traits/is_scalar.h> |
| 498 | #include <__type_traits/is_scoped_enum.h> | ||
| 499 | #include <__type_traits/is_signed.h> | 467 | #include <__type_traits/is_signed.h> |
| 500 | #include <__type_traits/is_specialization.h> | ||
| 501 | #include <__type_traits/is_standard_layout.h> | 468 | #include <__type_traits/is_standard_layout.h> |
| 502 | #include <__type_traits/is_swappable.h> | ||
| 503 | #include <__type_traits/is_trivial.h> | 469 | #include <__type_traits/is_trivial.h> |
| 504 | #include <__type_traits/is_trivially_assignable.h> | 470 | #include <__type_traits/is_trivially_assignable.h> |
| 505 | #include <__type_traits/is_trivially_constructible.h> | 471 | #include <__type_traits/is_trivially_constructible.h> |
| 506 | #include <__type_traits/is_trivially_copy_assignable.h> | ||
| 507 | #include <__type_traits/is_trivially_copy_constructible.h> | ||
| 508 | #include <__type_traits/is_trivially_copyable.h> | 472 | #include <__type_traits/is_trivially_copyable.h> |
| 509 | #include <__type_traits/is_trivially_default_constructible.h> | ||
| 510 | #include <__type_traits/is_trivially_destructible.h> | 473 | #include <__type_traits/is_trivially_destructible.h> |
| 511 | #include <__type_traits/is_trivially_move_assignable.h> | ||
| 512 | #include <__type_traits/is_trivially_move_constructible.h> | ||
| 513 | #include <__type_traits/is_unbounded_array.h> | ||
| 514 | #include <__type_traits/is_union.h> | 474 | #include <__type_traits/is_union.h> |
| 515 | #include <__type_traits/is_unsigned.h> | 475 | #include <__type_traits/is_unsigned.h> |
| 516 | #include <__type_traits/is_void.h> | 476 | #include <__type_traits/is_void.h> |
| 517 | #include <__type_traits/is_volatile.h> | 477 | #include <__type_traits/is_volatile.h> |
| 518 | #include <__type_traits/make_const_lvalue_ref.h> | ||
| 519 | #include <__type_traits/make_signed.h> | 478 | #include <__type_traits/make_signed.h> |
| 520 | #include <__type_traits/make_unsigned.h> | 479 | #include <__type_traits/make_unsigned.h> |
| 521 | #include <__type_traits/maybe_const.h> | ||
| 522 | #include <__type_traits/negation.h> | ||
| 523 | #include <__type_traits/rank.h> | 480 | #include <__type_traits/rank.h> |
| 524 | #include <__type_traits/remove_all_extents.h> | 481 | #include <__type_traits/remove_all_extents.h> |
| 525 | #include <__type_traits/remove_const.h> | 482 | #include <__type_traits/remove_const.h> |
| 526 | #include <__type_traits/remove_const_ref.h> | ||
| 527 | #include <__type_traits/remove_cv.h> | 483 | #include <__type_traits/remove_cv.h> |
| 528 | #include <__type_traits/remove_extent.h> | 484 | #include <__type_traits/remove_extent.h> |
| 529 | #include <__type_traits/remove_pointer.h> | 485 | #include <__type_traits/remove_pointer.h> |
| 530 | #include <__type_traits/remove_reference.h> | 486 | #include <__type_traits/remove_reference.h> |
| 531 | #include <__type_traits/remove_volatile.h> | 487 | #include <__type_traits/remove_volatile.h> |
| 532 | #include <__type_traits/result_of.h> | 488 | #include <__type_traits/result_of.h> |
| 533 | #include <__type_traits/type_identity.h> | ||
| 534 | #include <__type_traits/underlying_type.h> | 489 | #include <__type_traits/underlying_type.h> |
| 535 | #include <__type_traits/unwrap_ref.h> | 490 | |
| 536 | #include <__type_traits/void_t.h> | 491 | #if _LIBCPP_STD_VER >= 14 |
| 537 | #include <__utility/declval.h> | 492 | # include <__type_traits/is_final.h> |
| 538 | #include <cstddef> | 493 | # include <__type_traits/is_null_pointer.h> |
| 539 | #include <cstdint> | 494 | #endif |
| 495 | |||
| 496 | #if _LIBCPP_STD_VER >= 17 | ||
| 497 | # include <__type_traits/conjunction.h> | ||
| 498 | # include <__type_traits/disjunction.h> | ||
| 499 | # include <__type_traits/has_unique_object_representation.h> | ||
| 500 | # include <__type_traits/invoke.h> | ||
| 501 | # include <__type_traits/is_aggregate.h> | ||
| 502 | # include <__type_traits/is_swappable.h> | ||
| 503 | # include <__type_traits/negation.h> | ||
| 504 | # include <__type_traits/void_t.h> | ||
| 505 | #endif | ||
| 506 | |||
| 507 | #if _LIBCPP_STD_VER >= 20 | ||
| 508 | # include <__type_traits/common_reference.h> | ||
| 509 | # include <__type_traits/is_bounded_array.h> | ||
| 510 | # include <__type_traits/is_constant_evaluated.h> | ||
| 511 | # include <__type_traits/is_nothrow_convertible.h> | ||
| 512 | # include <__type_traits/is_unbounded_array.h> | ||
| 513 | # include <__type_traits/type_identity.h> | ||
| 514 | # include <__type_traits/unwrap_ref.h> | ||
| 515 | #endif | ||
| 516 | |||
| 540 | #include <version> | 517 | #include <version> |
| 541 | 518 | ||
| 542 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 519 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/typeindex-1| ... | @@ -45,7 +45,6 @@ struct hash<type_index> | ... | @@ -45,7 +45,6 @@ struct hash<type_index> |
| 45 | 45 | ||
| 46 | */ | 46 | */ |
| 47 | 47 | ||
| 48 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 49 | #include <__config> | 48 | #include <__config> |
| 50 | #include <__functional/unary_function.h> | 49 | #include <__functional/unary_function.h> |
| 51 | #include <typeinfo> | 50 | #include <typeinfo> |
lib/libcxx/include/typeinfo+14-3| ... | @@ -56,8 +56,6 @@ public: | ... | @@ -56,8 +56,6 @@ public: |
| 56 | 56 | ||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 60 | #include <__availability> | ||
| 61 | #include <__config> | 59 | #include <__config> |
| 62 | #include <__exception/exception.h> | 60 | #include <__exception/exception.h> |
| 63 | #include <__type_traits/is_constant_evaluated.h> | 61 | #include <__type_traits/is_constant_evaluated.h> |
| ... | @@ -277,7 +275,20 @@ struct __type_info_implementations { | ... | @@ -277,7 +275,20 @@ struct __type_info_implementations { |
| 277 | __impl; | 275 | __impl; |
| 278 | }; | 276 | }; |
| 279 | 277 | ||
| 280 | class _LIBCPP_EXPORTED_FROM_ABI type_info { | 278 | # if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__) |
| 279 | # if __has_feature(ptrauth_type_info_vtable_pointer_discrimination) | ||
| 280 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ | ||
| 281 | [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]] | ||
| 282 | # else | ||
| 283 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ | ||
| 284 | [[_Clang::__ptrauth_vtable_pointer__( \ | ||
| 285 | process_independent, no_address_discrimination, no_extra_discrimination)]] | ||
| 286 | # endif | ||
| 287 | # else | ||
| 288 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH | ||
| 289 | # endif | ||
| 290 | |||
| 291 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info { | ||
| 281 | type_info& operator=(const type_info&); | 292 | type_info& operator=(const type_info&); |
| 282 | type_info(const type_info&); | 293 | type_info(const type_info&); |
| 283 | 294 |
lib/libcxx/include/unordered_map+42-62| ... | @@ -584,8 +584,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> | ... | @@ -584,8 +584,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 584 | */ | 584 | */ |
| 585 | 585 | ||
| 586 | #include <__algorithm/is_permutation.h> | 586 | #include <__algorithm/is_permutation.h> |
| 587 | #include <__assert> // all public C++ headers provide the assertion handler | 587 | #include <__assert> |
| 588 | #include <__availability> | ||
| 589 | #include <__config> | 588 | #include <__config> |
| 590 | #include <__functional/is_transparent.h> | 589 | #include <__functional/is_transparent.h> |
| 591 | #include <__functional/operations.h> | 590 | #include <__functional/operations.h> |
| ... | @@ -651,7 +650,7 @@ public: | ... | @@ -651,7 +650,7 @@ public: |
| 651 | return static_cast<const _Hash&>(*this)(__x); | 650 | return static_cast<const _Hash&>(*this)(__x); |
| 652 | } | 651 | } |
| 653 | #endif | 652 | #endif |
| 654 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) { | 653 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) { |
| 655 | using std::swap; | 654 | using std::swap; |
| 656 | swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y)); | 655 | swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y)); |
| 657 | } | 656 | } |
| ... | @@ -675,7 +674,7 @@ public: | ... | @@ -675,7 +674,7 @@ public: |
| 675 | return __hash_(__x); | 674 | return __hash_(__x); |
| 676 | } | 675 | } |
| 677 | #endif | 676 | #endif |
| 678 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) { | 677 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) { |
| 679 | using std::swap; | 678 | using std::swap; |
| 680 | swap(__hash_, __y.__hash_); | 679 | swap(__hash_, __y.__hash_); |
| 681 | } | 680 | } |
| ... | @@ -726,7 +725,7 @@ public: | ... | @@ -726,7 +725,7 @@ public: |
| 726 | return static_cast<const _Pred&>(*this)(__x, __y); | 725 | return static_cast<const _Pred&>(*this)(__x, __y); |
| 727 | } | 726 | } |
| 728 | #endif | 727 | #endif |
| 729 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) { | 728 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) { |
| 730 | using std::swap; | 729 | using std::swap; |
| 731 | swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y)); | 730 | swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y)); |
| 732 | } | 731 | } |
| ... | @@ -769,7 +768,7 @@ public: | ... | @@ -769,7 +768,7 @@ public: |
| 769 | return __pred_(__x, __y); | 768 | return __pred_(__x, __y); |
| 770 | } | 769 | } |
| 771 | #endif | 770 | #endif |
| 772 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) { | 771 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) { |
| 773 | using std::swap; | 772 | using std::swap; |
| 774 | swap(__pred_, __y.__pred_); | 773 | swap(__pred_, __y.__pred_); |
| 775 | } | 774 | } |
| ... | @@ -793,12 +792,12 @@ public: | ... | @@ -793,12 +792,12 @@ public: |
| 793 | private: | 792 | private: |
| 794 | allocator_type& __na_; | 793 | allocator_type& __na_; |
| 795 | 794 | ||
| 796 | __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); | ||
| 797 | |||
| 798 | public: | 795 | public: |
| 799 | bool __first_constructed; | 796 | bool __first_constructed; |
| 800 | bool __second_constructed; | 797 | bool __second_constructed; |
| 801 | 798 | ||
| 799 | __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete; | ||
| 800 | |||
| 802 | _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT | 801 | _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT |
| 803 | : __na_(__na), | 802 | : __na_(__na), |
| 804 | __first_constructed(false), | 803 | __first_constructed(false), |
| ... | @@ -877,13 +876,12 @@ public: | ... | @@ -877,13 +876,12 @@ public: |
| 877 | return *this; | 876 | return *this; |
| 878 | } | 877 | } |
| 879 | 878 | ||
| 880 | template <class _ValueTp, class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> > | 879 | template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0> |
| 881 | _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(_ValueTp&& __v) { | 880 | _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(_ValueTp&& __v) { |
| 882 | __ref() = std::forward<_ValueTp>(__v); | 881 | __ref() = std::forward<_ValueTp>(__v); |
| 883 | return *this; | 882 | return *this; |
| 884 | } | 883 | } |
| 885 | 884 | ||
| 886 | private: | ||
| 887 | __hash_value_type(const __hash_value_type& __v) = delete; | 885 | __hash_value_type(const __hash_value_type& __v) = delete; |
| 888 | __hash_value_type(__hash_value_type&& __v) = delete; | 886 | __hash_value_type(__hash_value_type&& __v) = delete; |
| 889 | template <class... _Args> | 887 | template <class... _Args> |
| ... | @@ -907,8 +905,7 @@ public: | ... | @@ -907,8 +905,7 @@ public: |
| 907 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } | 905 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } |
| 908 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } | 906 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } |
| 909 | 907 | ||
| 910 | private: | 908 | ~__hash_value_type() = delete; |
| 911 | ~__hash_value_type(); | ||
| 912 | }; | 909 | }; |
| 913 | 910 | ||
| 914 | #endif | 911 | #endif |
| ... | @@ -1037,7 +1034,7 @@ public: | ... | @@ -1037,7 +1034,7 @@ public: |
| 1037 | typedef pair<const key_type, mapped_type> value_type; | 1034 | typedef pair<const key_type, mapped_type> value_type; |
| 1038 | typedef value_type& reference; | 1035 | typedef value_type& reference; |
| 1039 | typedef const value_type& const_reference; | 1036 | typedef const value_type& const_reference; |
| 1040 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), | 1037 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, |
| 1041 | "Allocator::value_type must be same type as value_type"); | 1038 | "Allocator::value_type must be same type as value_type"); |
| 1042 | 1039 | ||
| 1043 | private: | 1040 | private: |
| ... | @@ -1060,12 +1057,10 @@ private: | ... | @@ -1060,12 +1057,10 @@ private: |
| 1060 | typedef unique_ptr<__node, _Dp> __node_holder; | 1057 | typedef unique_ptr<__node, _Dp> __node_holder; |
| 1061 | typedef allocator_traits<allocator_type> __alloc_traits; | 1058 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1062 | 1059 | ||
| 1063 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | 1060 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 1064 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 1065 | "original allocator"); | ||
| 1066 | 1061 | ||
| 1067 | static_assert((is_same<typename __table::__container_value_type, value_type>::value), ""); | 1062 | static_assert(is_same<typename __table::__container_value_type, value_type>::value, ""); |
| 1068 | static_assert((is_same<typename __table::__node_value_type, __value_type>::value), ""); | 1063 | static_assert(is_same<typename __table::__node_value_type, __value_type>::value, ""); |
| 1069 | 1064 | ||
| 1070 | public: | 1065 | public: |
| 1071 | typedef typename __alloc_traits::pointer pointer; | 1066 | typedef typename __alloc_traits::pointer pointer; |
| ... | @@ -1207,7 +1202,7 @@ public: | ... | @@ -1207,7 +1202,7 @@ public: |
| 1207 | return allocator_type(__table_.__node_alloc()); | 1202 | return allocator_type(__table_.__node_alloc()); |
| 1208 | } | 1203 | } |
| 1209 | 1204 | ||
| 1210 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 1205 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 1211 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 1206 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1212 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 1207 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1213 | 1208 | ||
| ... | @@ -1245,12 +1240,12 @@ public: | ... | @@ -1245,12 +1240,12 @@ public: |
| 1245 | return __table_.__insert_unique(std::move(__x)).first; | 1240 | return __table_.__insert_unique(std::move(__x)).first; |
| 1246 | } | 1241 | } |
| 1247 | 1242 | ||
| 1248 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | 1243 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1249 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) { | 1244 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) { |
| 1250 | return __table_.__insert_unique(std::forward<_Pp>(__x)); | 1245 | return __table_.__insert_unique(std::forward<_Pp>(__x)); |
| 1251 | } | 1246 | } |
| 1252 | 1247 | ||
| 1253 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | 1248 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1254 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, _Pp&& __x) { | 1249 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, _Pp&& __x) { |
| 1255 | return insert(std::forward<_Pp>(__x)).first; | 1250 | return insert(std::forward<_Pp>(__x)).first; |
| 1256 | } | 1251 | } |
| ... | @@ -1374,7 +1369,7 @@ public: | ... | @@ -1374,7 +1369,7 @@ public: |
| 1374 | } | 1369 | } |
| 1375 | #endif | 1370 | #endif |
| 1376 | 1371 | ||
| 1377 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) { | 1372 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 1378 | __table_.swap(__u.__table_); | 1373 | __table_.swap(__u.__table_); |
| 1379 | } | 1374 | } |
| 1380 | 1375 | ||
| ... | @@ -1384,13 +1379,11 @@ public: | ... | @@ -1384,13 +1379,11 @@ public: |
| 1384 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 1379 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 1385 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 1380 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 1386 | #if _LIBCPP_STD_VER >= 20 | 1381 | #if _LIBCPP_STD_VER >= 20 |
| 1387 | template <class _K2, | 1382 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1388 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1389 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1383 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1390 | return __table_.find(__k); | 1384 | return __table_.find(__k); |
| 1391 | } | 1385 | } |
| 1392 | template <class _K2, | 1386 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1393 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1394 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1387 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1395 | return __table_.find(__k); | 1388 | return __table_.find(__k); |
| 1396 | } | 1389 | } |
| ... | @@ -1398,8 +1391,7 @@ public: | ... | @@ -1398,8 +1391,7 @@ public: |
| 1398 | 1391 | ||
| 1399 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } | 1392 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } |
| 1400 | #if _LIBCPP_STD_VER >= 20 | 1393 | #if _LIBCPP_STD_VER >= 20 |
| 1401 | template <class _K2, | 1394 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1402 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1403 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1395 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1404 | return __table_.__count_unique(__k); | 1396 | return __table_.__count_unique(__k); |
| 1405 | } | 1397 | } |
| ... | @@ -1408,8 +1400,7 @@ public: | ... | @@ -1408,8 +1400,7 @@ public: |
| 1408 | #if _LIBCPP_STD_VER >= 20 | 1400 | #if _LIBCPP_STD_VER >= 20 |
| 1409 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1401 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1410 | 1402 | ||
| 1411 | template <class _K2, | 1403 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1412 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1413 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1404 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1414 | return find(__k) != end(); | 1405 | return find(__k) != end(); |
| 1415 | } | 1406 | } |
| ... | @@ -1422,13 +1413,11 @@ public: | ... | @@ -1422,13 +1413,11 @@ public: |
| 1422 | return __table_.__equal_range_unique(__k); | 1413 | return __table_.__equal_range_unique(__k); |
| 1423 | } | 1414 | } |
| 1424 | #if _LIBCPP_STD_VER >= 20 | 1415 | #if _LIBCPP_STD_VER >= 20 |
| 1425 | template <class _K2, | 1416 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1426 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1427 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1417 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1428 | return __table_.__equal_range_unique(__k); | 1418 | return __table_.__equal_range_unique(__k); |
| 1429 | } | 1419 | } |
| 1430 | template <class _K2, | 1420 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1431 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1432 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1421 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1433 | return __table_.__equal_range_unique(__k); | 1422 | return __table_.__equal_range_unique(__k); |
| 1434 | } | 1423 | } |
| ... | @@ -1848,7 +1837,8 @@ public: | ... | @@ -1848,7 +1837,8 @@ public: |
| 1848 | typedef pair<const key_type, mapped_type> value_type; | 1837 | typedef pair<const key_type, mapped_type> value_type; |
| 1849 | typedef value_type& reference; | 1838 | typedef value_type& reference; |
| 1850 | typedef const value_type& const_reference; | 1839 | typedef const value_type& const_reference; |
| 1851 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), | 1840 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 1841 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, | ||
| 1852 | "Allocator::value_type must be same type as value_type"); | 1842 | "Allocator::value_type must be same type as value_type"); |
| 1853 | 1843 | ||
| 1854 | private: | 1844 | private: |
| ... | @@ -1868,13 +1858,9 @@ private: | ... | @@ -1868,13 +1858,9 @@ private: |
| 1868 | typedef __hash_map_node_destructor<__node_allocator> _Dp; | 1858 | typedef __hash_map_node_destructor<__node_allocator> _Dp; |
| 1869 | typedef unique_ptr<__node, _Dp> __node_holder; | 1859 | typedef unique_ptr<__node, _Dp> __node_holder; |
| 1870 | typedef allocator_traits<allocator_type> __alloc_traits; | 1860 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1871 | static_assert((is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value), | 1861 | static_assert(is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value, |
| 1872 | "Allocator uses different size_type for different types"); | 1862 | "Allocator uses different size_type for different types"); |
| 1873 | 1863 | ||
| 1874 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | ||
| 1875 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 1876 | "original allocator"); | ||
| 1877 | |||
| 1878 | public: | 1864 | public: |
| 1879 | typedef typename __alloc_traits::pointer pointer; | 1865 | typedef typename __alloc_traits::pointer pointer; |
| 1880 | typedef typename __alloc_traits::const_pointer const_pointer; | 1866 | typedef typename __alloc_traits::const_pointer const_pointer; |
| ... | @@ -2015,7 +2001,7 @@ public: | ... | @@ -2015,7 +2001,7 @@ public: |
| 2015 | return allocator_type(__table_.__node_alloc()); | 2001 | return allocator_type(__table_.__node_alloc()); |
| 2016 | } | 2002 | } |
| 2017 | 2003 | ||
| 2018 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 2004 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 2019 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 2005 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 2020 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 2006 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 2021 | 2007 | ||
| ... | @@ -2052,12 +2038,12 @@ public: | ... | @@ -2052,12 +2038,12 @@ public: |
| 2052 | return __table_.__insert_multi(__p.__i_, std::move(__x)); | 2038 | return __table_.__insert_multi(__p.__i_, std::move(__x)); |
| 2053 | } | 2039 | } |
| 2054 | 2040 | ||
| 2055 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | 2041 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 2056 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) { | 2042 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) { |
| 2057 | return __table_.__insert_multi(std::forward<_Pp>(__x)); | 2043 | return __table_.__insert_multi(std::forward<_Pp>(__x)); |
| 2058 | } | 2044 | } |
| 2059 | 2045 | ||
| 2060 | template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | 2046 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 2061 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) { | 2047 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) { |
| 2062 | return __table_.__insert_multi(__p.__i_, std::forward<_Pp>(__x)); | 2048 | return __table_.__insert_multi(__p.__i_, std::forward<_Pp>(__x)); |
| 2063 | } | 2049 | } |
| ... | @@ -2125,7 +2111,7 @@ public: | ... | @@ -2125,7 +2111,7 @@ public: |
| 2125 | } | 2111 | } |
| 2126 | #endif | 2112 | #endif |
| 2127 | 2113 | ||
| 2128 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) { | 2114 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 2129 | __table_.swap(__u.__table_); | 2115 | __table_.swap(__u.__table_); |
| 2130 | } | 2116 | } |
| 2131 | 2117 | ||
| ... | @@ -2135,13 +2121,11 @@ public: | ... | @@ -2135,13 +2121,11 @@ public: |
| 2135 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 2121 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 2136 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 2122 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 2137 | #if _LIBCPP_STD_VER >= 20 | 2123 | #if _LIBCPP_STD_VER >= 20 |
| 2138 | template <class _K2, | 2124 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2139 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 2140 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 2125 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 2141 | return __table_.find(__k); | 2126 | return __table_.find(__k); |
| 2142 | } | 2127 | } |
| 2143 | template <class _K2, | 2128 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2144 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 2145 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 2129 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 2146 | return __table_.find(__k); | 2130 | return __table_.find(__k); |
| 2147 | } | 2131 | } |
| ... | @@ -2149,8 +2133,7 @@ public: | ... | @@ -2149,8 +2133,7 @@ public: |
| 2149 | 2133 | ||
| 2150 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } | 2134 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } |
| 2151 | #if _LIBCPP_STD_VER >= 20 | 2135 | #if _LIBCPP_STD_VER >= 20 |
| 2152 | template <class _K2, | 2136 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2153 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 2154 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 2137 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 2155 | return __table_.__count_multi(__k); | 2138 | return __table_.__count_multi(__k); |
| 2156 | } | 2139 | } |
| ... | @@ -2159,8 +2142,7 @@ public: | ... | @@ -2159,8 +2142,7 @@ public: |
| 2159 | #if _LIBCPP_STD_VER >= 20 | 2142 | #if _LIBCPP_STD_VER >= 20 |
| 2160 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 2143 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 2161 | 2144 | ||
| 2162 | template <class _K2, | 2145 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2163 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 2164 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 2146 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 2165 | return find(__k) != end(); | 2147 | return find(__k) != end(); |
| 2166 | } | 2148 | } |
| ... | @@ -2173,13 +2155,11 @@ public: | ... | @@ -2173,13 +2155,11 @@ public: |
| 2173 | return __table_.__equal_range_multi(__k); | 2155 | return __table_.__equal_range_multi(__k); |
| 2174 | } | 2156 | } |
| 2175 | #if _LIBCPP_STD_VER >= 20 | 2157 | #if _LIBCPP_STD_VER >= 20 |
| 2176 | template <class _K2, | 2158 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2177 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 2178 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 2159 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 2179 | return __table_.__equal_range_multi(__k); | 2160 | return __table_.__equal_range_multi(__k); |
| 2180 | } | 2161 | } |
| 2181 | template <class _K2, | 2162 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2182 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 2183 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 2163 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 2184 | return __table_.__equal_range_multi(__k); | 2164 | return __table_.__equal_range_multi(__k); |
| 2185 | } | 2165 | } |
| ... | @@ -2254,12 +2234,12 @@ template <class _Key, | ... | @@ -2254,12 +2234,12 @@ template <class _Key, |
| 2254 | class = enable_if_t<!is_integral<_Hash>::value>, | 2234 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2255 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 2235 | class = enable_if_t<!__is_allocator<_Pred>::value>, |
| 2256 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2236 | class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 2257 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, | 2237 | unordered_multimap( |
| 2258 | typename allocator_traits<_Allocator>::size_type = 0, | 2238 | initializer_list<pair<_Key, _Tp>>, |
| 2259 | _Hash = _Hash(), | 2239 | typename allocator_traits<_Allocator>::size_type = 0, |
| 2260 | _Pred = _Pred(), | 2240 | _Hash = _Hash(), |
| 2261 | _Allocator = _Allocator()) | 2241 | _Pred = _Pred(), |
| 2262 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; | 2242 | _Allocator = _Allocator()) -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; |
| 2263 | 2243 | ||
| 2264 | template <class _InputIterator, | 2244 | template <class _InputIterator, |
| 2265 | class _Allocator, | 2245 | class _Allocator, |
lib/libcxx/include/unordered_set+27-43| ... | @@ -532,8 +532,7 @@ template <class Value, class Hash, class Pred, class Alloc> | ... | @@ -532,8 +532,7 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 532 | // clang-format on | 532 | // clang-format on |
| 533 | 533 | ||
| 534 | #include <__algorithm/is_permutation.h> | 534 | #include <__algorithm/is_permutation.h> |
| 535 | #include <__assert> // all public C++ headers provide the assertion handler | 535 | #include <__assert> |
| 536 | #include <__availability> | ||
| 537 | #include <__config> | 536 | #include <__config> |
| 538 | #include <__functional/is_transparent.h> | 537 | #include <__functional/is_transparent.h> |
| 539 | #include <__functional/operations.h> | 538 | #include <__functional/operations.h> |
| ... | @@ -589,13 +588,10 @@ public: | ... | @@ -589,13 +588,10 @@ public: |
| 589 | typedef __type_identity_t<_Alloc> allocator_type; | 588 | typedef __type_identity_t<_Alloc> allocator_type; |
| 590 | typedef value_type& reference; | 589 | typedef value_type& reference; |
| 591 | typedef const value_type& const_reference; | 590 | typedef const value_type& const_reference; |
| 592 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), | 591 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 592 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, | ||
| 593 | "Allocator::value_type must be same type as value_type"); | 593 | "Allocator::value_type must be same type as value_type"); |
| 594 | 594 | ||
| 595 | static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value, | ||
| 596 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 597 | "original allocator"); | ||
| 598 | |||
| 599 | private: | 595 | private: |
| 600 | typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table; | 596 | typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table; |
| 601 | 597 | ||
| ... | @@ -735,7 +731,7 @@ public: | ... | @@ -735,7 +731,7 @@ public: |
| 735 | return allocator_type(__table_.__node_alloc()); | 731 | return allocator_type(__table_.__node_alloc()); |
| 736 | } | 732 | } |
| 737 | 733 | ||
| 738 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 734 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 739 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 735 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 740 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 736 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 741 | 737 | ||
| ... | @@ -829,7 +825,7 @@ public: | ... | @@ -829,7 +825,7 @@ public: |
| 829 | } | 825 | } |
| 830 | #endif | 826 | #endif |
| 831 | 827 | ||
| 832 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) { | 828 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 833 | __table_.swap(__u.__table_); | 829 | __table_.swap(__u.__table_); |
| 834 | } | 830 | } |
| 835 | 831 | ||
| ... | @@ -839,13 +835,11 @@ public: | ... | @@ -839,13 +835,11 @@ public: |
| 839 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 835 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 840 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 836 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 841 | #if _LIBCPP_STD_VER >= 20 | 837 | #if _LIBCPP_STD_VER >= 20 |
| 842 | template <class _K2, | 838 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 843 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 844 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 839 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 845 | return __table_.find(__k); | 840 | return __table_.find(__k); |
| 846 | } | 841 | } |
| 847 | template <class _K2, | 842 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 848 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 849 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 843 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 850 | return __table_.find(__k); | 844 | return __table_.find(__k); |
| 851 | } | 845 | } |
| ... | @@ -853,8 +847,7 @@ public: | ... | @@ -853,8 +847,7 @@ public: |
| 853 | 847 | ||
| 854 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } | 848 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } |
| 855 | #if _LIBCPP_STD_VER >= 20 | 849 | #if _LIBCPP_STD_VER >= 20 |
| 856 | template <class _K2, | 850 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 857 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 858 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 851 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 859 | return __table_.__count_unique(__k); | 852 | return __table_.__count_unique(__k); |
| 860 | } | 853 | } |
| ... | @@ -863,8 +856,7 @@ public: | ... | @@ -863,8 +856,7 @@ public: |
| 863 | #if _LIBCPP_STD_VER >= 20 | 856 | #if _LIBCPP_STD_VER >= 20 |
| 864 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 857 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 865 | 858 | ||
| 866 | template <class _K2, | 859 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 867 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 868 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 860 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 869 | return find(__k) != end(); | 861 | return find(__k) != end(); |
| 870 | } | 862 | } |
| ... | @@ -877,13 +869,11 @@ public: | ... | @@ -877,13 +869,11 @@ public: |
| 877 | return __table_.__equal_range_unique(__k); | 869 | return __table_.__equal_range_unique(__k); |
| 878 | } | 870 | } |
| 879 | #if _LIBCPP_STD_VER >= 20 | 871 | #if _LIBCPP_STD_VER >= 20 |
| 880 | template <class _K2, | 872 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 881 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 882 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 873 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 883 | return __table_.__equal_range_unique(__k); | 874 | return __table_.__equal_range_unique(__k); |
| 884 | } | 875 | } |
| 885 | template <class _K2, | 876 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 886 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 887 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 877 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 888 | return __table_.__equal_range_unique(__k); | 878 | return __table_.__equal_range_unique(__k); |
| 889 | } | 879 | } |
| ... | @@ -935,13 +925,13 @@ template <ranges::input_range _Range, | ... | @@ -935,13 +925,13 @@ template <ranges::input_range _Range, |
| 935 | class = enable_if_t<!is_integral<_Hash>::value>, | 925 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 936 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 926 | class = enable_if_t<!__is_allocator<_Pred>::value>, |
| 937 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 927 | class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 938 | unordered_set(from_range_t, | 928 | unordered_set( |
| 939 | _Range&&, | 929 | from_range_t, |
| 940 | typename allocator_traits<_Allocator>::size_type = 0, | 930 | _Range&&, |
| 941 | _Hash = _Hash(), | 931 | typename allocator_traits<_Allocator>::size_type = 0, |
| 942 | _Pred = _Pred(), | 932 | _Hash = _Hash(), |
| 943 | _Allocator = _Allocator()) | 933 | _Pred = _Pred(), |
| 944 | -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 | 934 | _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 |
| 945 | # endif | 935 | # endif |
| 946 | 936 | ||
| 947 | template <class _Tp, | 937 | template <class _Tp, |
| ... | @@ -1193,7 +1183,7 @@ public: | ... | @@ -1193,7 +1183,7 @@ public: |
| 1193 | typedef __type_identity_t<_Alloc> allocator_type; | 1183 | typedef __type_identity_t<_Alloc> allocator_type; |
| 1194 | typedef value_type& reference; | 1184 | typedef value_type& reference; |
| 1195 | typedef const value_type& const_reference; | 1185 | typedef const value_type& const_reference; |
| 1196 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), | 1186 | static_assert(is_same<value_type, typename allocator_type::value_type>::value, |
| 1197 | "Allocator::value_type must be same type as value_type"); | 1187 | "Allocator::value_type must be same type as value_type"); |
| 1198 | 1188 | ||
| 1199 | private: | 1189 | private: |
| ... | @@ -1335,7 +1325,7 @@ public: | ... | @@ -1335,7 +1325,7 @@ public: |
| 1335 | return allocator_type(__table_.__node_alloc()); | 1325 | return allocator_type(__table_.__node_alloc()); |
| 1336 | } | 1326 | } |
| 1337 | 1327 | ||
| 1338 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 1328 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 1339 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 1329 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1340 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 1330 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1341 | 1331 | ||
| ... | @@ -1432,7 +1422,7 @@ public: | ... | @@ -1432,7 +1422,7 @@ public: |
| 1432 | } | 1422 | } |
| 1433 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } | 1423 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } |
| 1434 | 1424 | ||
| 1435 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_multiset& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) { | 1425 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_multiset& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 1436 | __table_.swap(__u.__table_); | 1426 | __table_.swap(__u.__table_); |
| 1437 | } | 1427 | } |
| 1438 | 1428 | ||
| ... | @@ -1442,13 +1432,11 @@ public: | ... | @@ -1442,13 +1432,11 @@ public: |
| 1442 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 1432 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 1443 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 1433 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 1444 | #if _LIBCPP_STD_VER >= 20 | 1434 | #if _LIBCPP_STD_VER >= 20 |
| 1445 | template <class _K2, | 1435 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1446 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1447 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1436 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1448 | return __table_.find(__k); | 1437 | return __table_.find(__k); |
| 1449 | } | 1438 | } |
| 1450 | template <class _K2, | 1439 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1451 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1452 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1440 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1453 | return __table_.find(__k); | 1441 | return __table_.find(__k); |
| 1454 | } | 1442 | } |
| ... | @@ -1456,8 +1444,7 @@ public: | ... | @@ -1456,8 +1444,7 @@ public: |
| 1456 | 1444 | ||
| 1457 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } | 1445 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } |
| 1458 | #if _LIBCPP_STD_VER >= 20 | 1446 | #if _LIBCPP_STD_VER >= 20 |
| 1459 | template <class _K2, | 1447 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1460 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1461 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1448 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1462 | return __table_.__count_multi(__k); | 1449 | return __table_.__count_multi(__k); |
| 1463 | } | 1450 | } |
| ... | @@ -1466,8 +1453,7 @@ public: | ... | @@ -1466,8 +1453,7 @@ public: |
| 1466 | #if _LIBCPP_STD_VER >= 20 | 1453 | #if _LIBCPP_STD_VER >= 20 |
| 1467 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1454 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1468 | 1455 | ||
| 1469 | template <class _K2, | 1456 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1470 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1471 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1457 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1472 | return find(__k) != end(); | 1458 | return find(__k) != end(); |
| 1473 | } | 1459 | } |
| ... | @@ -1480,13 +1466,11 @@ public: | ... | @@ -1480,13 +1466,11 @@ public: |
| 1480 | return __table_.__equal_range_multi(__k); | 1466 | return __table_.__equal_range_multi(__k); |
| 1481 | } | 1467 | } |
| 1482 | #if _LIBCPP_STD_VER >= 20 | 1468 | #if _LIBCPP_STD_VER >= 20 |
| 1483 | template <class _K2, | 1469 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1484 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1485 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1470 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1486 | return __table_.__equal_range_multi(__k); | 1471 | return __table_.__equal_range_multi(__k); |
| 1487 | } | 1472 | } |
| 1488 | template <class _K2, | 1473 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1489 | enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | ||
| 1490 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1474 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1491 | return __table_.__equal_range_multi(__k); | 1475 | return __table_.__equal_range_multi(__k); |
| 1492 | } | 1476 | } |
lib/libcxx/include/utility+30-13| ... | @@ -246,27 +246,36 @@ template <class T> | ... | @@ -246,27 +246,36 @@ template <class T> |
| 246 | 246 | ||
| 247 | */ | 247 | */ |
| 248 | 248 | ||
| 249 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 250 | #include <__config> | 249 | #include <__config> |
| 251 | #include <__utility/as_const.h> | 250 | |
| 252 | #include <__utility/as_lvalue.h> | ||
| 253 | #include <__utility/auto_cast.h> | ||
| 254 | #include <__utility/cmp.h> | ||
| 255 | #include <__utility/declval.h> | 251 | #include <__utility/declval.h> |
| 256 | #include <__utility/exception_guard.h> | ||
| 257 | #include <__utility/exchange.h> | ||
| 258 | #include <__utility/forward.h> | 252 | #include <__utility/forward.h> |
| 259 | #include <__utility/forward_like.h> | ||
| 260 | #include <__utility/in_place.h> | ||
| 261 | #include <__utility/integer_sequence.h> | ||
| 262 | #include <__utility/move.h> | 253 | #include <__utility/move.h> |
| 263 | #include <__utility/pair.h> | 254 | #include <__utility/pair.h> |
| 264 | #include <__utility/piecewise_construct.h> | 255 | #include <__utility/piecewise_construct.h> |
| 265 | #include <__utility/priority_tag.h> | ||
| 266 | #include <__utility/rel_ops.h> | 256 | #include <__utility/rel_ops.h> |
| 267 | #include <__utility/swap.h> | 257 | #include <__utility/swap.h> |
| 268 | #include <__utility/to_underlying.h> | 258 | |
| 269 | #include <__utility/unreachable.h> | 259 | #if _LIBCPP_STD_VER >= 14 |
| 260 | # include <__utility/exchange.h> | ||
| 261 | # include <__utility/integer_sequence.h> | ||
| 262 | #endif | ||
| 263 | |||
| 264 | #if _LIBCPP_STD_VER >= 17 | ||
| 265 | # include <__utility/as_const.h> | ||
| 266 | # include <__utility/in_place.h> | ||
| 267 | #endif | ||
| 268 | |||
| 269 | #if _LIBCPP_STD_VER >= 20 | ||
| 270 | # include <__utility/cmp.h> | ||
| 271 | #endif | ||
| 272 | |||
| 273 | #if _LIBCPP_STD_VER >= 23 | ||
| 274 | # include <__utility/forward_like.h> | ||
| 275 | # include <__utility/to_underlying.h> | ||
| 276 | # include <__utility/unreachable.h> | ||
| 277 | #endif | ||
| 278 | |||
| 270 | #include <version> | 279 | #include <version> |
| 271 | 280 | ||
| 272 | // standard-mandated includes | 281 | // standard-mandated includes |
| ... | @@ -275,6 +284,10 @@ template <class T> | ... | @@ -275,6 +284,10 @@ template <class T> |
| 275 | #include <compare> | 284 | #include <compare> |
| 276 | #include <initializer_list> | 285 | #include <initializer_list> |
| 277 | 286 | ||
| 287 | // [tuple.creation] | ||
| 288 | |||
| 289 | #include <__tuple/ignore.h> | ||
| 290 | |||
| 278 | // [tuple.helper] | 291 | // [tuple.helper] |
| 279 | #include <__tuple/tuple_element.h> | 292 | #include <__tuple/tuple_element.h> |
| 280 | #include <__tuple/tuple_size.h> | 293 | #include <__tuple/tuple_size.h> |
| ... | @@ -283,6 +296,10 @@ template <class T> | ... | @@ -283,6 +296,10 @@ template <class T> |
| 283 | # pragma GCC system_header | 296 | # pragma GCC system_header |
| 284 | #endif | 297 | #endif |
| 285 | 298 | ||
| 299 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | ||
| 300 | # include <limits> | ||
| 301 | #endif | ||
| 302 | |||
| 286 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 303 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 287 | # include <cstdlib> | 304 | # include <cstdlib> |
| 288 | # include <iosfwd> | 305 | # include <iosfwd> |
lib/libcxx/include/valarray+169-89| ... | @@ -350,7 +350,7 @@ template <class T> unspecified2 end(const valarray<T>& v); | ... | @@ -350,7 +350,7 @@ template <class T> unspecified2 end(const valarray<T>& v); |
| 350 | #include <__algorithm/min.h> | 350 | #include <__algorithm/min.h> |
| 351 | #include <__algorithm/min_element.h> | 351 | #include <__algorithm/min_element.h> |
| 352 | #include <__algorithm/unwrap_iter.h> | 352 | #include <__algorithm/unwrap_iter.h> |
| 353 | #include <__assert> // all public C++ headers provide the assertion handler | 353 | #include <__assert> |
| 354 | #include <__config> | 354 | #include <__config> |
| 355 | #include <__functional/operations.h> | 355 | #include <__functional/operations.h> |
| 356 | #include <__memory/addressof.h> | 356 | #include <__memory/addressof.h> |
| ... | @@ -733,6 +733,50 @@ struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; | ... | @@ -733,6 +733,50 @@ struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; |
| 733 | template <class _Tp> | 733 | template <class _Tp> |
| 734 | struct __is_val_expr<valarray<_Tp> > : true_type {}; | 734 | struct __is_val_expr<valarray<_Tp> > : true_type {}; |
| 735 | 735 | ||
| 736 | template <class _Tp> | ||
| 737 | struct __is_val_expr<slice_array<_Tp> > : true_type {}; | ||
| 738 | |||
| 739 | template <class _Tp> | ||
| 740 | struct __is_val_expr<gslice_array<_Tp> > : true_type {}; | ||
| 741 | |||
| 742 | template <class _Tp> | ||
| 743 | struct __is_val_expr<mask_array<_Tp> > : true_type {}; | ||
| 744 | |||
| 745 | template <class _Tp> | ||
| 746 | struct __is_val_expr<indirect_array<_Tp> > : true_type {}; | ||
| 747 | |||
| 748 | // The functions using a __val_expr access the elements by their index. | ||
| 749 | // valarray and the libc++ lazy proxies have an operator[]. The | ||
| 750 | // Standard proxy array's don't have this operator, instead they have a | ||
| 751 | // implementation specific accessor | ||
| 752 | // __get(size_t) | ||
| 753 | // | ||
| 754 | // The functions use the non-member function | ||
| 755 | // __get(__val_expr, size_t) | ||
| 756 | // | ||
| 757 | // If the __val_expr is a specialization of __val_expr_use_member_functions it | ||
| 758 | // uses the __val_expr's member function | ||
| 759 | // __get(size_t) | ||
| 760 | // else it uses the __val_expr's member function | ||
| 761 | // operator[](size_t) | ||
| 762 | template <class _ValExpr> | ||
| 763 | struct __val_expr_use_member_functions; | ||
| 764 | |||
| 765 | template <class> | ||
| 766 | struct __val_expr_use_member_functions : false_type {}; | ||
| 767 | |||
| 768 | template <class _Tp> | ||
| 769 | struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {}; | ||
| 770 | |||
| 771 | template <class _Tp> | ||
| 772 | struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {}; | ||
| 773 | |||
| 774 | template <class _Tp> | ||
| 775 | struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {}; | ||
| 776 | |||
| 777 | template <class _Tp> | ||
| 778 | struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {}; | ||
| 779 | |||
| 736 | template <class _Tp> | 780 | template <class _Tp> |
| 737 | class _LIBCPP_TEMPLATE_VIS valarray { | 781 | class _LIBCPP_TEMPLATE_VIS valarray { |
| 738 | public: | 782 | public: |
| ... | @@ -903,6 +947,18 @@ template <class _Tp, size_t _Size> | ... | @@ -903,6 +947,18 @@ template <class _Tp, size_t _Size> |
| 903 | valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>; | 947 | valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>; |
| 904 | #endif | 948 | #endif |
| 905 | 949 | ||
| 950 | template <class _Expr, | ||
| 951 | __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0> | ||
| 952 | _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) { | ||
| 953 | return __v.__get(__i); | ||
| 954 | } | ||
| 955 | |||
| 956 | template <class _Expr, | ||
| 957 | __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0> | ||
| 958 | _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) { | ||
| 959 | return __v[__i]; | ||
| 960 | } | ||
| 961 | |||
| 906 | extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t); | 962 | extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t); |
| 907 | 963 | ||
| 908 | template <class _Op, class _Tp> | 964 | template <class _Op, class _Tp> |
| ... | @@ -1025,6 +1081,12 @@ public: | ... | @@ -1025,6 +1081,12 @@ public: |
| 1025 | 1081 | ||
| 1026 | _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const; | 1082 | _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const; |
| 1027 | 1083 | ||
| 1084 | // Behaves like __val_expr::operator[], which returns by value. | ||
| 1085 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { | ||
| 1086 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds"); | ||
| 1087 | return __vp_[__i * __stride_]; | ||
| 1088 | } | ||
| 1089 | |||
| 1028 | private: | 1090 | private: |
| 1029 | _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v) | 1091 | _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v) |
| 1030 | : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {} | 1092 | : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {} |
| ... | @@ -1246,6 +1308,12 @@ public: | ... | @@ -1246,6 +1308,12 @@ public: |
| 1246 | 1308 | ||
| 1247 | gslice_array(const gslice_array&) = default; | 1309 | gslice_array(const gslice_array&) = default; |
| 1248 | 1310 | ||
| 1311 | // Behaves like __val_expr::operator[], which returns by value. | ||
| 1312 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { | ||
| 1313 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds"); | ||
| 1314 | return __vp_[__1d_[__i]]; | ||
| 1315 | } | ||
| 1316 | |||
| 1249 | private: | 1317 | private: |
| 1250 | gslice_array(const gslice& __gs, const valarray<value_type>& __v) | 1318 | gslice_array(const gslice& __gs, const valarray<value_type>& __v) |
| 1251 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {} | 1319 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {} |
| ... | @@ -1425,6 +1493,12 @@ public: | ... | @@ -1425,6 +1493,12 @@ public: |
| 1425 | 1493 | ||
| 1426 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; | 1494 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
| 1427 | 1495 | ||
| 1496 | // Behaves like __val_expr::operator[], which returns by value. | ||
| 1497 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { | ||
| 1498 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds"); | ||
| 1499 | return __vp_[__1d_[__i]]; | ||
| 1500 | } | ||
| 1501 | |||
| 1428 | private: | 1502 | private: |
| 1429 | _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) | 1503 | _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) |
| 1430 | : __vp_(const_cast<value_type*>(__v.__begin_)), | 1504 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| ... | @@ -1624,6 +1698,12 @@ public: | ... | @@ -1624,6 +1698,12 @@ public: |
| 1624 | 1698 | ||
| 1625 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; | 1699 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
| 1626 | 1700 | ||
| 1701 | // Behaves like __val_expr::operator[], which returns by value. | ||
| 1702 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { | ||
| 1703 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds"); | ||
| 1704 | return __vp_[__1d_[__i]]; | ||
| 1705 | } | ||
| 1706 | |||
| 1627 | private: | 1707 | private: |
| 1628 | _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) | 1708 | _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) |
| 1629 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {} | 1709 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {} |
| ... | @@ -2355,7 +2435,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2355,7 +2435,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2355 | inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) { | 2435 | inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) { |
| 2356 | size_t __i = 0; | 2436 | size_t __i = 0; |
| 2357 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2437 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2358 | *__t *= __v[__i]; | 2438 | *__t *= std::__get(__v, __i); |
| 2359 | return *this; | 2439 | return *this; |
| 2360 | } | 2440 | } |
| 2361 | 2441 | ||
| ... | @@ -2364,7 +2444,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2364,7 +2444,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2364 | inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) { | 2444 | inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) { |
| 2365 | size_t __i = 0; | 2445 | size_t __i = 0; |
| 2366 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2446 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2367 | *__t /= __v[__i]; | 2447 | *__t /= std::__get(__v, __i); |
| 2368 | return *this; | 2448 | return *this; |
| 2369 | } | 2449 | } |
| 2370 | 2450 | ||
| ... | @@ -2373,7 +2453,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2373,7 +2453,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2373 | inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) { | 2453 | inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) { |
| 2374 | size_t __i = 0; | 2454 | size_t __i = 0; |
| 2375 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2455 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2376 | *__t %= __v[__i]; | 2456 | *__t %= std::__get(__v, __i); |
| 2377 | return *this; | 2457 | return *this; |
| 2378 | } | 2458 | } |
| 2379 | 2459 | ||
| ... | @@ -2382,7 +2462,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2382,7 +2462,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2382 | inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) { | 2462 | inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) { |
| 2383 | size_t __i = 0; | 2463 | size_t __i = 0; |
| 2384 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2464 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2385 | *__t += __v[__i]; | 2465 | *__t += std::__get(__v, __i); |
| 2386 | return *this; | 2466 | return *this; |
| 2387 | } | 2467 | } |
| 2388 | 2468 | ||
| ... | @@ -2391,7 +2471,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2391,7 +2471,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2391 | inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) { | 2471 | inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) { |
| 2392 | size_t __i = 0; | 2472 | size_t __i = 0; |
| 2393 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2473 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2394 | *__t -= __v[__i]; | 2474 | *__t -= std::__get(__v, __i); |
| 2395 | return *this; | 2475 | return *this; |
| 2396 | } | 2476 | } |
| 2397 | 2477 | ||
| ... | @@ -2400,7 +2480,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2400,7 +2480,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2400 | inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) { | 2480 | inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) { |
| 2401 | size_t __i = 0; | 2481 | size_t __i = 0; |
| 2402 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2482 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2403 | *__t ^= __v[__i]; | 2483 | *__t ^= std::__get(__v, __i); |
| 2404 | return *this; | 2484 | return *this; |
| 2405 | } | 2485 | } |
| 2406 | 2486 | ||
| ... | @@ -2409,7 +2489,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2409,7 +2489,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2409 | inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) { | 2489 | inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) { |
| 2410 | size_t __i = 0; | 2490 | size_t __i = 0; |
| 2411 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2491 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2412 | *__t |= __v[__i]; | 2492 | *__t |= std::__get(__v, __i); |
| 2413 | return *this; | 2493 | return *this; |
| 2414 | } | 2494 | } |
| 2415 | 2495 | ||
| ... | @@ -2418,7 +2498,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2418,7 +2498,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2418 | inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) { | 2498 | inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) { |
| 2419 | size_t __i = 0; | 2499 | size_t __i = 0; |
| 2420 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2500 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2421 | *__t &= __v[__i]; | 2501 | *__t &= std::__get(__v, __i); |
| 2422 | return *this; | 2502 | return *this; |
| 2423 | } | 2503 | } |
| 2424 | 2504 | ||
| ... | @@ -2427,7 +2507,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2427,7 +2507,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2427 | inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) { | 2507 | inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) { |
| 2428 | size_t __i = 0; | 2508 | size_t __i = 0; |
| 2429 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2509 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2430 | *__t <<= __v[__i]; | 2510 | *__t <<= std::__get(__v, __i); |
| 2431 | return *this; | 2511 | return *this; |
| 2432 | } | 2512 | } |
| 2433 | 2513 | ||
| ... | @@ -2436,7 +2516,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > | ... | @@ -2436,7 +2516,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2436 | inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) { | 2516 | inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) { |
| 2437 | size_t __i = 0; | 2517 | size_t __i = 0; |
| 2438 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) | 2518 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2439 | *__t >>= __v[__i]; | 2519 | *__t >>= std::__get(__v, __i); |
| 2440 | return *this; | 2520 | return *this; |
| 2441 | } | 2521 | } |
| 2442 | 2522 | ||
| ... | @@ -2587,8 +2667,8 @@ operator*(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2587,8 +2667,8 @@ operator*(const _Expr1& __x, const _Expr2& __y) { |
| 2587 | 2667 | ||
| 2588 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2668 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2589 | inline _LIBCPP_HIDE_FROM_ABI | 2669 | inline _LIBCPP_HIDE_FROM_ABI |
| 2590 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2670 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2591 | operator*(const _Expr& __x, const typename _Expr::value_type& __y) { | 2671 | operator*(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2592 | typedef typename _Expr::value_type value_type; | 2672 | typedef typename _Expr::value_type value_type; |
| 2593 | typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2673 | typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2594 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2674 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2596,8 +2676,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2596,8 +2676,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2596 | 2676 | ||
| 2597 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2677 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2598 | inline _LIBCPP_HIDE_FROM_ABI | 2678 | inline _LIBCPP_HIDE_FROM_ABI |
| 2599 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2679 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2600 | operator*(const typename _Expr::value_type& __x, const _Expr& __y) { | 2680 | operator*(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2601 | typedef typename _Expr::value_type value_type; | 2681 | typedef typename _Expr::value_type value_type; |
| 2602 | typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2682 | typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2603 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2683 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2615,8 +2695,8 @@ operator/(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2615,8 +2695,8 @@ operator/(const _Expr1& __x, const _Expr2& __y) { |
| 2615 | 2695 | ||
| 2616 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2696 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2617 | inline _LIBCPP_HIDE_FROM_ABI | 2697 | inline _LIBCPP_HIDE_FROM_ABI |
| 2618 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2698 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2619 | operator/(const _Expr& __x, const typename _Expr::value_type& __y) { | 2699 | operator/(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2620 | typedef typename _Expr::value_type value_type; | 2700 | typedef typename _Expr::value_type value_type; |
| 2621 | typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2701 | typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2622 | return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2702 | return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2624,8 +2704,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2624,8 +2704,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2624 | 2704 | ||
| 2625 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2705 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2626 | inline _LIBCPP_HIDE_FROM_ABI | 2706 | inline _LIBCPP_HIDE_FROM_ABI |
| 2627 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2707 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2628 | operator/(const typename _Expr::value_type& __x, const _Expr& __y) { | 2708 | operator/(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2629 | typedef typename _Expr::value_type value_type; | 2709 | typedef typename _Expr::value_type value_type; |
| 2630 | typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2710 | typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2631 | return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2711 | return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2643,8 +2723,8 @@ operator%(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2643,8 +2723,8 @@ operator%(const _Expr1& __x, const _Expr2& __y) { |
| 2643 | 2723 | ||
| 2644 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2724 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2645 | inline _LIBCPP_HIDE_FROM_ABI | 2725 | inline _LIBCPP_HIDE_FROM_ABI |
| 2646 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2726 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2647 | operator%(const _Expr& __x, const typename _Expr::value_type& __y) { | 2727 | operator%(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2648 | typedef typename _Expr::value_type value_type; | 2728 | typedef typename _Expr::value_type value_type; |
| 2649 | typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2729 | typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2650 | return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2730 | return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2652,8 +2732,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2652,8 +2732,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2652 | 2732 | ||
| 2653 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2733 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2654 | inline _LIBCPP_HIDE_FROM_ABI | 2734 | inline _LIBCPP_HIDE_FROM_ABI |
| 2655 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2735 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2656 | operator%(const typename _Expr::value_type& __x, const _Expr& __y) { | 2736 | operator%(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2657 | typedef typename _Expr::value_type value_type; | 2737 | typedef typename _Expr::value_type value_type; |
| 2658 | typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2738 | typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2659 | return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2739 | return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2671,8 +2751,8 @@ operator+(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2671,8 +2751,8 @@ operator+(const _Expr1& __x, const _Expr2& __y) { |
| 2671 | 2751 | ||
| 2672 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2752 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2673 | inline _LIBCPP_HIDE_FROM_ABI | 2753 | inline _LIBCPP_HIDE_FROM_ABI |
| 2674 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2754 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2675 | operator+(const _Expr& __x, const typename _Expr::value_type& __y) { | 2755 | operator+(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2676 | typedef typename _Expr::value_type value_type; | 2756 | typedef typename _Expr::value_type value_type; |
| 2677 | typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2757 | typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2678 | return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2758 | return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2680,8 +2760,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2680,8 +2760,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2680 | 2760 | ||
| 2681 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2761 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2682 | inline _LIBCPP_HIDE_FROM_ABI | 2762 | inline _LIBCPP_HIDE_FROM_ABI |
| 2683 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2763 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2684 | operator+(const typename _Expr::value_type& __x, const _Expr& __y) { | 2764 | operator+(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2685 | typedef typename _Expr::value_type value_type; | 2765 | typedef typename _Expr::value_type value_type; |
| 2686 | typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2766 | typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2687 | return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2767 | return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2699,8 +2779,8 @@ operator-(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2699,8 +2779,8 @@ operator-(const _Expr1& __x, const _Expr2& __y) { |
| 2699 | 2779 | ||
| 2700 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2780 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2701 | inline _LIBCPP_HIDE_FROM_ABI | 2781 | inline _LIBCPP_HIDE_FROM_ABI |
| 2702 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2782 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2703 | operator-(const _Expr& __x, const typename _Expr::value_type& __y) { | 2783 | operator-(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2704 | typedef typename _Expr::value_type value_type; | 2784 | typedef typename _Expr::value_type value_type; |
| 2705 | typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2785 | typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2706 | return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2786 | return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2708,8 +2788,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2708,8 +2788,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2708 | 2788 | ||
| 2709 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2789 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2710 | inline _LIBCPP_HIDE_FROM_ABI | 2790 | inline _LIBCPP_HIDE_FROM_ABI |
| 2711 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2791 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2712 | operator-(const typename _Expr::value_type& __x, const _Expr& __y) { | 2792 | operator-(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2713 | typedef typename _Expr::value_type value_type; | 2793 | typedef typename _Expr::value_type value_type; |
| 2714 | typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2794 | typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2715 | return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2795 | return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2727,8 +2807,8 @@ operator^(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2727,8 +2807,8 @@ operator^(const _Expr1& __x, const _Expr2& __y) { |
| 2727 | 2807 | ||
| 2728 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2808 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2729 | inline _LIBCPP_HIDE_FROM_ABI | 2809 | inline _LIBCPP_HIDE_FROM_ABI |
| 2730 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2810 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2731 | operator^(const _Expr& __x, const typename _Expr::value_type& __y) { | 2811 | operator^(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2732 | typedef typename _Expr::value_type value_type; | 2812 | typedef typename _Expr::value_type value_type; |
| 2733 | typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2813 | typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2734 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2814 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2736,8 +2816,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2736,8 +2816,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2736 | 2816 | ||
| 2737 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2817 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2738 | inline _LIBCPP_HIDE_FROM_ABI | 2818 | inline _LIBCPP_HIDE_FROM_ABI |
| 2739 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2819 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2740 | operator^(const typename _Expr::value_type& __x, const _Expr& __y) { | 2820 | operator^(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2741 | typedef typename _Expr::value_type value_type; | 2821 | typedef typename _Expr::value_type value_type; |
| 2742 | typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2822 | typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2743 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2823 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2755,8 +2835,8 @@ operator&(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2755,8 +2835,8 @@ operator&(const _Expr1& __x, const _Expr2& __y) { |
| 2755 | 2835 | ||
| 2756 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2836 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2757 | inline _LIBCPP_HIDE_FROM_ABI | 2837 | inline _LIBCPP_HIDE_FROM_ABI |
| 2758 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2838 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2759 | operator&(const _Expr& __x, const typename _Expr::value_type& __y) { | 2839 | operator&(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2760 | typedef typename _Expr::value_type value_type; | 2840 | typedef typename _Expr::value_type value_type; |
| 2761 | typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2841 | typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2762 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2842 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2764,8 +2844,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2764,8 +2844,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2764 | 2844 | ||
| 2765 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2845 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2766 | inline _LIBCPP_HIDE_FROM_ABI | 2846 | inline _LIBCPP_HIDE_FROM_ABI |
| 2767 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2847 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2768 | operator&(const typename _Expr::value_type& __x, const _Expr& __y) { | 2848 | operator&(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2769 | typedef typename _Expr::value_type value_type; | 2849 | typedef typename _Expr::value_type value_type; |
| 2770 | typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2850 | typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2771 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2851 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2783,8 +2863,8 @@ operator|(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2783,8 +2863,8 @@ operator|(const _Expr1& __x, const _Expr2& __y) { |
| 2783 | 2863 | ||
| 2784 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2864 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2785 | inline _LIBCPP_HIDE_FROM_ABI | 2865 | inline _LIBCPP_HIDE_FROM_ABI |
| 2786 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2866 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2787 | operator|(const _Expr& __x, const typename _Expr::value_type& __y) { | 2867 | operator|(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2788 | typedef typename _Expr::value_type value_type; | 2868 | typedef typename _Expr::value_type value_type; |
| 2789 | typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2869 | typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2790 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2870 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2792,8 +2872,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2792,8 +2872,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2792 | 2872 | ||
| 2793 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2873 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2794 | inline _LIBCPP_HIDE_FROM_ABI | 2874 | inline _LIBCPP_HIDE_FROM_ABI |
| 2795 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2875 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2796 | operator|(const typename _Expr::value_type& __x, const _Expr& __y) { | 2876 | operator|(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2797 | typedef typename _Expr::value_type value_type; | 2877 | typedef typename _Expr::value_type value_type; |
| 2798 | typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2878 | typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2799 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2879 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2810,8 +2890,8 @@ operator<<(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2810,8 +2890,8 @@ operator<<(const _Expr1& __x, const _Expr2& __y) { |
| 2810 | } | 2890 | } |
| 2811 | 2891 | ||
| 2812 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2892 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2813 | inline _LIBCPP_HIDE_FROM_ABI __val_expr< | 2893 | inline _LIBCPP_HIDE_FROM_ABI |
| 2814 | _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2894 | __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2815 | operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { | 2895 | operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2816 | typedef typename _Expr::value_type value_type; | 2896 | typedef typename _Expr::value_type value_type; |
| 2817 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2897 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| ... | @@ -2819,8 +2899,8 @@ operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { | ... | @@ -2819,8 +2899,8 @@ operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2819 | } | 2899 | } |
| 2820 | 2900 | ||
| 2821 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2901 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2822 | inline _LIBCPP_HIDE_FROM_ABI __val_expr< | 2902 | inline _LIBCPP_HIDE_FROM_ABI |
| 2823 | _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2903 | __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2824 | operator<<(const typename _Expr::value_type& __x, const _Expr& __y) { | 2904 | operator<<(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2825 | typedef typename _Expr::value_type value_type; | 2905 | typedef typename _Expr::value_type value_type; |
| 2826 | typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2906 | typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| ... | @@ -2847,8 +2927,8 @@ operator>>(const _Expr& __x, const typename _Expr::value_type& __y) { | ... | @@ -2847,8 +2927,8 @@ operator>>(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2847 | } | 2927 | } |
| 2848 | 2928 | ||
| 2849 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2929 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2850 | inline _LIBCPP_HIDE_FROM_ABI __val_expr< | 2930 | inline _LIBCPP_HIDE_FROM_ABI |
| 2851 | _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2931 | __val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2852 | operator>>(const typename _Expr::value_type& __x, const _Expr& __y) { | 2932 | operator>>(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2853 | typedef typename _Expr::value_type value_type; | 2933 | typedef typename _Expr::value_type value_type; |
| 2854 | typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2934 | typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| ... | @@ -2867,8 +2947,8 @@ operator&&(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2867,8 +2947,8 @@ operator&&(const _Expr1& __x, const _Expr2& __y) { |
| 2867 | 2947 | ||
| 2868 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2948 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2869 | inline _LIBCPP_HIDE_FROM_ABI | 2949 | inline _LIBCPP_HIDE_FROM_ABI |
| 2870 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2950 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2871 | operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { | 2951 | operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2872 | typedef typename _Expr::value_type value_type; | 2952 | typedef typename _Expr::value_type value_type; |
| 2873 | typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2953 | typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2874 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2954 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2876,8 +2956,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2876,8 +2956,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2876 | 2956 | ||
| 2877 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2957 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2878 | inline _LIBCPP_HIDE_FROM_ABI | 2958 | inline _LIBCPP_HIDE_FROM_ABI |
| 2879 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2959 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2880 | operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { | 2960 | operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2881 | typedef typename _Expr::value_type value_type; | 2961 | typedef typename _Expr::value_type value_type; |
| 2882 | typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2962 | typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2883 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2963 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2895,8 +2975,8 @@ operator||(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2895,8 +2975,8 @@ operator||(const _Expr1& __x, const _Expr2& __y) { |
| 2895 | 2975 | ||
| 2896 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2976 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2897 | inline _LIBCPP_HIDE_FROM_ABI | 2977 | inline _LIBCPP_HIDE_FROM_ABI |
| 2898 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 2978 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2899 | operator||(const _Expr& __x, const typename _Expr::value_type& __y) { | 2979 | operator||(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2900 | typedef typename _Expr::value_type value_type; | 2980 | typedef typename _Expr::value_type value_type; |
| 2901 | typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 2981 | typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2902 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 2982 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2904,8 +2984,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2904,8 +2984,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2904 | 2984 | ||
| 2905 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 2985 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2906 | inline _LIBCPP_HIDE_FROM_ABI | 2986 | inline _LIBCPP_HIDE_FROM_ABI |
| 2907 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 2987 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2908 | operator||(const typename _Expr::value_type& __x, const _Expr& __y) { | 2988 | operator||(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2909 | typedef typename _Expr::value_type value_type; | 2989 | typedef typename _Expr::value_type value_type; |
| 2910 | typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 2990 | typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2911 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 2991 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2923,8 +3003,8 @@ operator==(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2923,8 +3003,8 @@ operator==(const _Expr1& __x, const _Expr2& __y) { |
| 2923 | 3003 | ||
| 2924 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3004 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2925 | inline _LIBCPP_HIDE_FROM_ABI | 3005 | inline _LIBCPP_HIDE_FROM_ABI |
| 2926 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3006 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2927 | operator==(const _Expr& __x, const typename _Expr::value_type& __y) { | 3007 | operator==(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2928 | typedef typename _Expr::value_type value_type; | 3008 | typedef typename _Expr::value_type value_type; |
| 2929 | typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3009 | typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2930 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3010 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2932,8 +3012,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2932,8 +3012,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2932 | 3012 | ||
| 2933 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3013 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2934 | inline _LIBCPP_HIDE_FROM_ABI | 3014 | inline _LIBCPP_HIDE_FROM_ABI |
| 2935 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3015 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2936 | operator==(const typename _Expr::value_type& __x, const _Expr& __y) { | 3016 | operator==(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2937 | typedef typename _Expr::value_type value_type; | 3017 | typedef typename _Expr::value_type value_type; |
| 2938 | typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3018 | typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2939 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3019 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2951,8 +3031,8 @@ operator!=(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2951,8 +3031,8 @@ operator!=(const _Expr1& __x, const _Expr2& __y) { |
| 2951 | 3031 | ||
| 2952 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3032 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2953 | inline _LIBCPP_HIDE_FROM_ABI | 3033 | inline _LIBCPP_HIDE_FROM_ABI |
| 2954 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3034 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2955 | operator!=(const _Expr& __x, const typename _Expr::value_type& __y) { | 3035 | operator!=(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2956 | typedef typename _Expr::value_type value_type; | 3036 | typedef typename _Expr::value_type value_type; |
| 2957 | typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3037 | typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2958 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3038 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2960,8 +3040,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2960,8 +3040,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2960 | 3040 | ||
| 2961 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3041 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2962 | inline _LIBCPP_HIDE_FROM_ABI | 3042 | inline _LIBCPP_HIDE_FROM_ABI |
| 2963 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3043 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2964 | operator!=(const typename _Expr::value_type& __x, const _Expr& __y) { | 3044 | operator!=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2965 | typedef typename _Expr::value_type value_type; | 3045 | typedef typename _Expr::value_type value_type; |
| 2966 | typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3046 | typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2967 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3047 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -2979,8 +3059,8 @@ operator<(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -2979,8 +3059,8 @@ operator<(const _Expr1& __x, const _Expr2& __y) { |
| 2979 | 3059 | ||
| 2980 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3060 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2981 | inline _LIBCPP_HIDE_FROM_ABI | 3061 | inline _LIBCPP_HIDE_FROM_ABI |
| 2982 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3062 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2983 | operator<(const _Expr& __x, const typename _Expr::value_type& __y) { | 3063 | operator<(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2984 | typedef typename _Expr::value_type value_type; | 3064 | typedef typename _Expr::value_type value_type; |
| 2985 | typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3065 | typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2986 | return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3066 | return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -2988,8 +3068,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -2988,8 +3068,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 2988 | 3068 | ||
| 2989 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3069 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2990 | inline _LIBCPP_HIDE_FROM_ABI | 3070 | inline _LIBCPP_HIDE_FROM_ABI |
| 2991 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3071 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2992 | operator<(const typename _Expr::value_type& __x, const _Expr& __y) { | 3072 | operator<(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2993 | typedef typename _Expr::value_type value_type; | 3073 | typedef typename _Expr::value_type value_type; |
| 2994 | typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3074 | typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2995 | return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3075 | return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -3007,8 +3087,8 @@ operator>(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -3007,8 +3087,8 @@ operator>(const _Expr1& __x, const _Expr2& __y) { |
| 3007 | 3087 | ||
| 3008 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3088 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3009 | inline _LIBCPP_HIDE_FROM_ABI | 3089 | inline _LIBCPP_HIDE_FROM_ABI |
| 3010 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3090 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3011 | operator>(const _Expr& __x, const typename _Expr::value_type& __y) { | 3091 | operator>(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3012 | typedef typename _Expr::value_type value_type; | 3092 | typedef typename _Expr::value_type value_type; |
| 3013 | typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3093 | typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3014 | return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3094 | return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -3016,8 +3096,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -3016,8 +3096,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 3016 | 3096 | ||
| 3017 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3097 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3018 | inline _LIBCPP_HIDE_FROM_ABI | 3098 | inline _LIBCPP_HIDE_FROM_ABI |
| 3019 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3099 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3020 | operator>(const typename _Expr::value_type& __x, const _Expr& __y) { | 3100 | operator>(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3021 | typedef typename _Expr::value_type value_type; | 3101 | typedef typename _Expr::value_type value_type; |
| 3022 | typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3102 | typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3023 | return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3103 | return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -3035,8 +3115,8 @@ operator<=(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -3035,8 +3115,8 @@ operator<=(const _Expr1& __x, const _Expr2& __y) { |
| 3035 | 3115 | ||
| 3036 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3116 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3037 | inline _LIBCPP_HIDE_FROM_ABI | 3117 | inline _LIBCPP_HIDE_FROM_ABI |
| 3038 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3118 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3039 | operator<=(const _Expr& __x, const typename _Expr::value_type& __y) { | 3119 | operator<=(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3040 | typedef typename _Expr::value_type value_type; | 3120 | typedef typename _Expr::value_type value_type; |
| 3041 | typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3121 | typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3042 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3122 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -3044,8 +3124,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -3044,8 +3124,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 3044 | 3124 | ||
| 3045 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3125 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3046 | inline _LIBCPP_HIDE_FROM_ABI | 3126 | inline _LIBCPP_HIDE_FROM_ABI |
| 3047 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3127 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3048 | operator<=(const typename _Expr::value_type& __x, const _Expr& __y) { | 3128 | operator<=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3049 | typedef typename _Expr::value_type value_type; | 3129 | typedef typename _Expr::value_type value_type; |
| 3050 | typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3130 | typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3051 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3131 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -3063,8 +3143,8 @@ operator>=(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -3063,8 +3143,8 @@ operator>=(const _Expr1& __x, const _Expr2& __y) { |
| 3063 | 3143 | ||
| 3064 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3144 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3065 | inline _LIBCPP_HIDE_FROM_ABI | 3145 | inline _LIBCPP_HIDE_FROM_ABI |
| 3066 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3146 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3067 | operator>=(const _Expr& __x, const typename _Expr::value_type& __y) { | 3147 | operator>=(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3068 | typedef typename _Expr::value_type value_type; | 3148 | typedef typename _Expr::value_type value_type; |
| 3069 | typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3149 | typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3070 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3150 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -3072,8 +3152,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -3072,8 +3152,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 3072 | 3152 | ||
| 3073 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3153 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3074 | inline _LIBCPP_HIDE_FROM_ABI | 3154 | inline _LIBCPP_HIDE_FROM_ABI |
| 3075 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3155 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3076 | operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { | 3156 | operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3077 | typedef typename _Expr::value_type value_type; | 3157 | typedef typename _Expr::value_type value_type; |
| 3078 | typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3158 | typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3079 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3159 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -3123,8 +3203,8 @@ atan2(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -3123,8 +3203,8 @@ atan2(const _Expr1& __x, const _Expr2& __y) { |
| 3123 | 3203 | ||
| 3124 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3204 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3125 | inline _LIBCPP_HIDE_FROM_ABI | 3205 | inline _LIBCPP_HIDE_FROM_ABI |
| 3126 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3206 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3127 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) { | 3207 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3128 | typedef typename _Expr::value_type value_type; | 3208 | typedef typename _Expr::value_type value_type; |
| 3129 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3209 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3130 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3210 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -3132,8 +3212,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -3132,8 +3212,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 3132 | 3212 | ||
| 3133 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3213 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3134 | inline _LIBCPP_HIDE_FROM_ABI | 3214 | inline _LIBCPP_HIDE_FROM_ABI |
| 3135 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3215 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3136 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) { | 3216 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3137 | typedef typename _Expr::value_type value_type; | 3217 | typedef typename _Expr::value_type value_type; |
| 3138 | typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3218 | typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3139 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3219 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| ... | @@ -3191,8 +3271,8 @@ pow(const _Expr1& __x, const _Expr2& __y) { | ... | @@ -3191,8 +3271,8 @@ pow(const _Expr1& __x, const _Expr2& __y) { |
| 3191 | 3271 | ||
| 3192 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3272 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3193 | inline _LIBCPP_HIDE_FROM_ABI | 3273 | inline _LIBCPP_HIDE_FROM_ABI |
| 3194 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3274 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3195 | pow(const _Expr& __x, const typename _Expr::value_type& __y) { | 3275 | pow(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3196 | typedef typename _Expr::value_type value_type; | 3276 | typedef typename _Expr::value_type value_type; |
| 3197 | typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; | 3277 | typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3198 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); | 3278 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| ... | @@ -3200,8 +3280,8 @@ inline _LIBCPP_HIDE_FROM_ABI | ... | @@ -3200,8 +3280,8 @@ inline _LIBCPP_HIDE_FROM_ABI |
| 3200 | 3280 | ||
| 3201 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3281 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3202 | inline _LIBCPP_HIDE_FROM_ABI | 3282 | inline _LIBCPP_HIDE_FROM_ABI |
| 3203 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3283 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3204 | pow(const typename _Expr::value_type& __x, const _Expr& __y) { | 3284 | pow(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3205 | typedef typename _Expr::value_type value_type; | 3285 | typedef typename _Expr::value_type value_type; |
| 3206 | typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; | 3286 | typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3207 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); | 3287 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
lib/libcxx/include/variant+170-154| ... | @@ -42,26 +42,28 @@ namespace std { | ... | @@ -42,26 +42,28 @@ namespace std { |
| 42 | in_place_index_t<I>, initializer_list<U>, Args&&...); | 42 | in_place_index_t<I>, initializer_list<U>, Args&&...); |
| 43 | 43 | ||
| 44 | // 20.7.2.2, destructor | 44 | // 20.7.2.2, destructor |
| 45 | ~variant(); | 45 | constexpr ~variant(); // constexpr since c++20 |
| 46 | 46 | ||
| 47 | // 20.7.2.3, assignment | 47 | // 20.7.2.3, assignment |
| 48 | constexpr variant& operator=(const variant&); | 48 | constexpr variant& operator=(const variant&); |
| 49 | constexpr variant& operator=(variant&&) noexcept(see below); | 49 | constexpr variant& operator=(variant&&) noexcept(see below); |
| 50 | 50 | ||
| 51 | template <class T> variant& operator=(T&&) noexcept(see below); | 51 | template <class T> |
| 52 | constexpr variant& operator=(T&&) noexcept(see below); // constexpr since c++20 | ||
| 52 | 53 | ||
| 53 | // 20.7.2.4, modifiers | 54 | // 20.7.2.4, modifiers |
| 54 | template <class T, class... Args> | 55 | template <class T, class... Args> |
| 55 | T& emplace(Args&&...); | 56 | constexpr T& emplace(Args&&...); // constexpr since c++20 |
| 56 | 57 | ||
| 57 | template <class T, class U, class... Args> | 58 | template <class T, class U, class... Args> |
| 58 | T& emplace(initializer_list<U>, Args&&...); | 59 | constexpr T& emplace(initializer_list<U>, Args&&...); // constexpr since c++20 |
| 59 | 60 | ||
| 60 | template <size_t I, class... Args> | 61 | template <size_t I, class... Args> |
| 61 | variant_alternative_t<I, variant>& emplace(Args&&...); | 62 | constexpr variant_alternative_t<I, variant>& emplace(Args&&...); // constexpr since c++20 |
| 62 | 63 | ||
| 63 | template <size_t I, class U, class... Args> | 64 | template <size_t I, class U, class... Args> |
| 64 | variant_alternative_t<I, variant>& emplace(initializer_list<U>, Args&&...); | 65 | constexpr variant_alternative_t<I, variant>& |
| 66 | emplace(initializer_list<U>, Args&&...); // constexpr since c++20 | ||
| 65 | 67 | ||
| 66 | // 20.7.2.5, value status | 68 | // 20.7.2.5, value status |
| 67 | constexpr bool valueless_by_exception() const noexcept; | 69 | constexpr bool valueless_by_exception() const noexcept; |
| ... | @@ -210,8 +212,6 @@ namespace std { | ... | @@ -210,8 +212,6 @@ namespace std { |
| 210 | 212 | ||
| 211 | */ | 213 | */ |
| 212 | 214 | ||
| 213 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 214 | #include <__availability> | ||
| 215 | #include <__compare/common_comparison_category.h> | 215 | #include <__compare/common_comparison_category.h> |
| 216 | #include <__compare/compare_three_way_result.h> | 216 | #include <__compare/compare_three_way_result.h> |
| 217 | #include <__compare/three_way_comparable.h> | 217 | #include <__compare/three_way_comparable.h> |
| ... | @@ -222,27 +222,36 @@ namespace std { | ... | @@ -222,27 +222,36 @@ namespace std { |
| 222 | #include <__functional/operations.h> | 222 | #include <__functional/operations.h> |
| 223 | #include <__functional/unary_function.h> | 223 | #include <__functional/unary_function.h> |
| 224 | #include <__memory/addressof.h> | 224 | #include <__memory/addressof.h> |
| 225 | #include <__memory/construct_at.h> | ||
| 226 | #include <__tuple/find_index.h> | ||
| 227 | #include <__tuple/sfinae_helpers.h> | ||
| 225 | #include <__type_traits/add_const.h> | 228 | #include <__type_traits/add_const.h> |
| 226 | #include <__type_traits/add_cv.h> | 229 | #include <__type_traits/add_cv.h> |
| 227 | #include <__type_traits/add_pointer.h> | 230 | #include <__type_traits/add_pointer.h> |
| 228 | #include <__type_traits/add_volatile.h> | 231 | #include <__type_traits/add_volatile.h> |
| 232 | #include <__type_traits/common_type.h> | ||
| 233 | #include <__type_traits/conjunction.h> | ||
| 229 | #include <__type_traits/dependent_type.h> | 234 | #include <__type_traits/dependent_type.h> |
| 230 | #include <__type_traits/is_array.h> | 235 | #include <__type_traits/is_array.h> |
| 236 | #include <__type_traits/is_constructible.h> | ||
| 231 | #include <__type_traits/is_destructible.h> | 237 | #include <__type_traits/is_destructible.h> |
| 232 | #include <__type_traits/is_nothrow_move_constructible.h> | 238 | #include <__type_traits/is_nothrow_assignable.h> |
| 233 | #include <__type_traits/is_trivially_copy_assignable.h> | 239 | #include <__type_traits/is_nothrow_constructible.h> |
| 234 | #include <__type_traits/is_trivially_copy_constructible.h> | 240 | #include <__type_traits/is_reference.h> |
| 241 | #include <__type_traits/is_trivially_assignable.h> | ||
| 242 | #include <__type_traits/is_trivially_constructible.h> | ||
| 235 | #include <__type_traits/is_trivially_destructible.h> | 243 | #include <__type_traits/is_trivially_destructible.h> |
| 236 | #include <__type_traits/is_trivially_move_assignable.h> | 244 | #include <__type_traits/is_trivially_relocatable.h> |
| 237 | #include <__type_traits/is_trivially_move_constructible.h> | ||
| 238 | #include <__type_traits/is_void.h> | 245 | #include <__type_traits/is_void.h> |
| 239 | #include <__type_traits/remove_const.h> | 246 | #include <__type_traits/remove_const.h> |
| 247 | #include <__type_traits/remove_cvref.h> | ||
| 240 | #include <__type_traits/type_identity.h> | 248 | #include <__type_traits/type_identity.h> |
| 241 | #include <__type_traits/void_t.h> | 249 | #include <__type_traits/void_t.h> |
| 242 | #include <__utility/declval.h> | 250 | #include <__utility/declval.h> |
| 243 | #include <__utility/forward.h> | 251 | #include <__utility/forward.h> |
| 244 | #include <__utility/forward_like.h> | 252 | #include <__utility/forward_like.h> |
| 245 | #include <__utility/in_place.h> | 253 | #include <__utility/in_place.h> |
| 254 | #include <__utility/integer_sequence.h> | ||
| 246 | #include <__utility/move.h> | 255 | #include <__utility/move.h> |
| 247 | #include <__utility/swap.h> | 256 | #include <__utility/swap.h> |
| 248 | #include <__variant/monostate.h> | 257 | #include <__variant/monostate.h> |
| ... | @@ -250,7 +259,6 @@ namespace std { | ... | @@ -250,7 +259,6 @@ namespace std { |
| 250 | #include <initializer_list> | 259 | #include <initializer_list> |
| 251 | #include <limits> | 260 | #include <limits> |
| 252 | #include <new> | 261 | #include <new> |
| 253 | #include <tuple> | ||
| 254 | #include <version> | 262 | #include <version> |
| 255 | 263 | ||
| 256 | // standard-mandated includes | 264 | // standard-mandated includes |
| ... | @@ -341,21 +349,20 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { | ... | @@ -341,21 +349,20 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { |
| 341 | 349 | ||
| 342 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); | 350 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); |
| 343 | 351 | ||
| 344 | _LIBCPP_HIDE_FROM_ABI constexpr int __choose_index_type(unsigned int __num_elem) { | 352 | template <size_t _NumAlternatives> |
| 345 | if (__num_elem < numeric_limits<unsigned char>::max()) | 353 | _LIBCPP_HIDE_FROM_ABI constexpr auto __choose_index_type() { |
| 346 | return 0; | 354 | # ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION |
| 347 | if (__num_elem < numeric_limits<unsigned short>::max()) | 355 | if constexpr (_NumAlternatives < numeric_limits<unsigned char>::max()) |
| 348 | return 1; | 356 | return static_cast<unsigned char>(0); |
| 349 | return 2; | 357 | else if constexpr (_NumAlternatives < numeric_limits<unsigned short>::max()) |
| 358 | return static_cast<unsigned short>(0); | ||
| 359 | else | ||
| 360 | # endif // _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | ||
| 361 | return static_cast<unsigned int>(0); | ||
| 350 | } | 362 | } |
| 351 | 363 | ||
| 352 | template <size_t _NumAlts> | 364 | template <size_t _NumAlts> |
| 353 | using __variant_index_t = | 365 | using __variant_index_t = decltype(std::__choose_index_type<_NumAlts>()); |
| 354 | # ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | ||
| 355 | unsigned int; | ||
| 356 | # else | ||
| 357 | std::tuple_element_t< __choose_index_type(_NumAlts), std::tuple<unsigned char, unsigned short, unsigned int> >; | ||
| 358 | # endif | ||
| 359 | 366 | ||
| 360 | template <class _IndexType> | 367 | template <class _IndexType> |
| 361 | constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1); | 368 | constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1); |
| ... | @@ -653,9 +660,14 @@ private: | ... | @@ -653,9 +660,14 @@ private: |
| 653 | 660 | ||
| 654 | } // namespace __visitation | 661 | } // namespace __visitation |
| 655 | 662 | ||
| 663 | // Adding semi-colons in macro expansions helps clang-format to do a better job. | ||
| 664 | // This macro is used to avoid compilation errors due to "stray" semi-colons. | ||
| 665 | # define _LIBCPP_EAT_SEMICOLON static_assert(true, "") | ||
| 666 | |||
| 656 | template <size_t _Index, class _Tp> | 667 | template <size_t _Index, class _Tp> |
| 657 | struct _LIBCPP_TEMPLATE_VIS __alt { | 668 | struct _LIBCPP_TEMPLATE_VIS __alt { |
| 658 | using __value_type = _Tp; | 669 | using __value_type = _Tp; |
| 670 | static constexpr size_t __index = _Index; | ||
| 659 | 671 | ||
| 660 | template <class... _Args> | 672 | template <class... _Args> |
| 661 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __alt(in_place_t, _Args&&... __args) | 673 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __alt(in_place_t, _Args&&... __args) |
| ... | @@ -670,7 +682,7 @@ union _LIBCPP_TEMPLATE_VIS __union; | ... | @@ -670,7 +682,7 @@ union _LIBCPP_TEMPLATE_VIS __union; |
| 670 | template <_Trait _DestructibleTrait, size_t _Index> | 682 | template <_Trait _DestructibleTrait, size_t _Index> |
| 671 | union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; | 683 | union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; |
| 672 | 684 | ||
| 673 | # define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \ | 685 | # define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \ |
| 674 | template <size_t _Index, class _Tp, class... _Types> \ | 686 | template <size_t _Index, class _Tp, class... _Types> \ |
| 675 | union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \ | 687 | union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \ |
| 676 | public: \ | 688 | public: \ |
| ... | @@ -684,14 +696,11 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; | ... | @@ -684,14 +696,11 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; |
| 684 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \ | 696 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \ |
| 685 | : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \ | 697 | : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \ |
| 686 | \ | 698 | \ |
| 687 | __union(const __union&) = default; \ | 699 | _LIBCPP_HIDE_FROM_ABI __union(const __union&) = default; \ |
| 688 | __union(__union&&) = default; \ | 700 | _LIBCPP_HIDE_FROM_ABI __union(__union&&) = default; \ |
| 689 | \ | 701 | _LIBCPP_HIDE_FROM_ABI __union& operator=(const __union&) = default; \ |
| 690 | destructor \ | 702 | _LIBCPP_HIDE_FROM_ABI __union& operator=(__union&&) = default; \ |
| 691 | \ | 703 | destructor_definition; \ |
| 692 | __union& \ | ||
| 693 | operator=(const __union&) = default; \ | ||
| 694 | __union& operator=(__union&&) = default; \ | ||
| 695 | \ | 704 | \ |
| 696 | private: \ | 705 | private: \ |
| 697 | char __dummy; \ | 706 | char __dummy; \ |
| ... | @@ -701,9 +710,11 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; | ... | @@ -701,9 +710,11 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; |
| 701 | friend struct __access::__union; \ | 710 | friend struct __access::__union; \ |
| 702 | } | 711 | } |
| 703 | 712 | ||
| 704 | _LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable, ~__union() = default;); | 713 | _LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable, |
| 705 | _LIBCPP_VARIANT_UNION(_Trait::_Available, ~__union(){}); | 714 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = default); |
| 706 | _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, ~__union() = delete;); | 715 | _LIBCPP_VARIANT_UNION( |
| 716 | _Trait::_Available, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() {} _LIBCPP_EAT_SEMICOLON); | ||
| 717 | _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = delete); | ||
| 707 | 718 | ||
| 708 | # undef _LIBCPP_VARIANT_UNION | 719 | # undef _LIBCPP_VARIANT_UNION |
| 709 | 720 | ||
| ... | @@ -746,7 +757,7 @@ protected: | ... | @@ -746,7 +757,7 @@ protected: |
| 746 | template <class _Traits, _Trait = _Traits::__destructible_trait> | 757 | template <class _Traits, _Trait = _Traits::__destructible_trait> |
| 747 | class _LIBCPP_TEMPLATE_VIS __dtor; | 758 | class _LIBCPP_TEMPLATE_VIS __dtor; |
| 748 | 759 | ||
| 749 | # define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \ | 760 | # define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \ |
| 750 | template <class... _Types> \ | 761 | template <class... _Types> \ |
| 751 | class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \ | 762 | class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \ |
| 752 | : public __base<destructible_trait, _Types...> { \ | 763 | : public __base<destructible_trait, _Types...> { \ |
| ... | @@ -756,24 +767,27 @@ class _LIBCPP_TEMPLATE_VIS __dtor; | ... | @@ -756,24 +767,27 @@ class _LIBCPP_TEMPLATE_VIS __dtor; |
| 756 | public: \ | 767 | public: \ |
| 757 | using __base_type::__base_type; \ | 768 | using __base_type::__base_type; \ |
| 758 | using __base_type::operator=; \ | 769 | using __base_type::operator=; \ |
| 759 | \ | 770 | _LIBCPP_HIDE_FROM_ABI __dtor(const __dtor&) = default; \ |
| 760 | __dtor(const __dtor&) = default; \ | 771 | _LIBCPP_HIDE_FROM_ABI __dtor(__dtor&&) = default; \ |
| 761 | __dtor(__dtor&&) = default; \ | 772 | _LIBCPP_HIDE_FROM_ABI __dtor& operator=(const __dtor&) = default; \ |
| 762 | destructor __dtor& operator=(const __dtor&) = default; \ | 773 | _LIBCPP_HIDE_FROM_ABI __dtor& operator=(__dtor&&) = default; \ |
| 763 | __dtor& operator=(__dtor&&) = default; \ | 774 | destructor_definition; \ |
| 764 | \ | 775 | \ |
| 765 | protected: \ | 776 | protected: \ |
| 766 | inline _LIBCPP_HIDE_FROM_ABI destroy \ | 777 | destroy; \ |
| 767 | } | 778 | } |
| 768 | 779 | ||
| 769 | _LIBCPP_VARIANT_DESTRUCTOR( | 780 | _LIBCPP_VARIANT_DESTRUCTOR( |
| 770 | _Trait::_TriviallyAvailable, ~__dtor() = default; | 781 | _Trait::_TriviallyAvailable, |
| 771 | , void __destroy() noexcept { this->__index = __variant_npos<__index_t>; }); | 782 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = default, |
| 783 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept { | ||
| 784 | this->__index = __variant_npos<__index_t>; | ||
| 785 | } _LIBCPP_EAT_SEMICOLON); | ||
| 772 | 786 | ||
| 773 | _LIBCPP_VARIANT_DESTRUCTOR( | 787 | _LIBCPP_VARIANT_DESTRUCTOR( |
| 774 | _Trait::_Available, | 788 | _Trait::_Available, |
| 775 | ~__dtor() { __destroy(); }, | 789 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() { __destroy(); } _LIBCPP_EAT_SEMICOLON, |
| 776 | void __destroy() noexcept { | 790 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept { |
| 777 | if (!this->valueless_by_exception()) { | 791 | if (!this->valueless_by_exception()) { |
| 778 | __visitation::__base::__visit_alt( | 792 | __visitation::__base::__visit_alt( |
| 779 | [](auto& __alt) noexcept { | 793 | [](auto& __alt) noexcept { |
| ... | @@ -783,9 +797,11 @@ _LIBCPP_VARIANT_DESTRUCTOR( | ... | @@ -783,9 +797,11 @@ _LIBCPP_VARIANT_DESTRUCTOR( |
| 783 | *this); | 797 | *this); |
| 784 | } | 798 | } |
| 785 | this->__index = __variant_npos<__index_t>; | 799 | this->__index = __variant_npos<__index_t>; |
| 786 | }); | 800 | } _LIBCPP_EAT_SEMICOLON); |
| 787 | 801 | ||
| 788 | _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable, ~__dtor() = delete;, void __destroy() noexcept = delete;); | 802 | _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable, |
| 803 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = delete, | ||
| 804 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept = delete); | ||
| 789 | 805 | ||
| 790 | # undef _LIBCPP_VARIANT_DESTRUCTOR | 806 | # undef _LIBCPP_VARIANT_DESTRUCTOR |
| 791 | 807 | ||
| ... | @@ -798,23 +814,18 @@ public: | ... | @@ -798,23 +814,18 @@ public: |
| 798 | using __base_type::operator=; | 814 | using __base_type::operator=; |
| 799 | 815 | ||
| 800 | protected: | 816 | protected: |
| 801 | template <size_t _Ip, class _Tp, class... _Args> | ||
| 802 | _LIBCPP_HIDE_FROM_ABI static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) { | ||
| 803 | ::new ((void*)std::addressof(__a)) __alt<_Ip, _Tp>(in_place, std::forward<_Args>(__args)...); | ||
| 804 | return __a.__value; | ||
| 805 | } | ||
| 806 | |||
| 807 | template <class _Rhs> | 817 | template <class _Rhs> |
| 808 | _LIBCPP_HIDE_FROM_ABI static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) { | 818 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) { |
| 809 | __lhs.__destroy(); | 819 | __lhs.__destroy(); |
| 810 | if (!__rhs.valueless_by_exception()) { | 820 | if (!__rhs.valueless_by_exception()) { |
| 811 | auto __rhs_index = __rhs.index(); | 821 | auto __rhs_index = __rhs.index(); |
| 812 | __visitation::__base::__visit_alt_at( | 822 | __visitation::__base::__visit_alt_at( |
| 813 | __rhs_index, | 823 | __rhs_index, |
| 814 | [](auto& __lhs_alt, auto&& __rhs_alt) { | 824 | [&__lhs](auto&& __rhs_alt) { |
| 815 | __construct_alt(__lhs_alt, std::forward<decltype(__rhs_alt)>(__rhs_alt).__value); | 825 | std::__construct_at(std::addressof(__lhs.__data), |
| 826 | in_place_index<__decay_t<decltype(__rhs_alt)>::__index>, | ||
| 827 | std::forward<decltype(__rhs_alt)>(__rhs_alt).__value); | ||
| 816 | }, | 828 | }, |
| 817 | __lhs, | ||
| 818 | std::forward<_Rhs>(__rhs)); | 829 | std::forward<_Rhs>(__rhs)); |
| 819 | __lhs.__index = __rhs_index; | 830 | __lhs.__index = __rhs_index; |
| 820 | } | 831 | } |
| ... | @@ -824,7 +835,7 @@ protected: | ... | @@ -824,7 +835,7 @@ protected: |
| 824 | template <class _Traits, _Trait = _Traits::__move_constructible_trait> | 835 | template <class _Traits, _Trait = _Traits::__move_constructible_trait> |
| 825 | class _LIBCPP_TEMPLATE_VIS __move_constructor; | 836 | class _LIBCPP_TEMPLATE_VIS __move_constructor; |
| 826 | 837 | ||
| 827 | # define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor) \ | 838 | # define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \ |
| 828 | template <class... _Types> \ | 839 | template <class... _Types> \ |
| 829 | class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \ | 840 | class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \ |
| 830 | : public __ctor<__traits<_Types...>> { \ | 841 | : public __ctor<__traits<_Types...>> { \ |
| ... | @@ -834,28 +845,35 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor; | ... | @@ -834,28 +845,35 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor; |
| 834 | using __base_type::__base_type; \ | 845 | using __base_type::__base_type; \ |
| 835 | using __base_type::operator=; \ | 846 | using __base_type::operator=; \ |
| 836 | \ | 847 | \ |
| 837 | __move_constructor(const __move_constructor&) = default; \ | 848 | _LIBCPP_HIDE_FROM_ABI __move_constructor(const __move_constructor&) = default; \ |
| 838 | move_constructor ~__move_constructor() = default; \ | 849 | _LIBCPP_HIDE_FROM_ABI ~__move_constructor() = default; \ |
| 839 | __move_constructor& operator=(const __move_constructor&) = default; \ | 850 | _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(const __move_constructor&) = default; \ |
| 840 | __move_constructor& operator=(__move_constructor&&) = default; \ | 851 | _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(__move_constructor&&) = default; \ |
| 852 | move_constructor_definition; \ | ||
| 841 | } | 853 | } |
| 842 | 854 | ||
| 843 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(_Trait::_TriviallyAvailable, | 855 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 844 | __move_constructor(__move_constructor&& __that) = default;); | 856 | _Trait::_TriviallyAvailable, |
| 857 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) = default); | ||
| 845 | 858 | ||
| 846 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( | 859 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 847 | _Trait::_Available, | 860 | _Trait::_Available, |
| 848 | __move_constructor(__move_constructor&& __that) noexcept(__all<is_nothrow_move_constructible_v<_Types>...>::value) | 861 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept( |
| 849 | : __move_constructor(__valueless_t{}) { this->__generic_construct(*this, std::move(__that)); }); | 862 | __all<is_nothrow_move_constructible_v<_Types>...>::value) |
| 863 | : __move_constructor(__valueless_t{}) { | ||
| 864 | this->__generic_construct(*this, std::move(__that)); | ||
| 865 | } _LIBCPP_EAT_SEMICOLON); | ||
| 850 | 866 | ||
| 851 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(_Trait::_Unavailable, __move_constructor(__move_constructor&&) = delete;); | 867 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 868 | _Trait::_Unavailable, | ||
| 869 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&&) = delete); | ||
| 852 | 870 | ||
| 853 | # undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR | 871 | # undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR |
| 854 | 872 | ||
| 855 | template <class _Traits, _Trait = _Traits::__copy_constructible_trait> | 873 | template <class _Traits, _Trait = _Traits::__copy_constructible_trait> |
| 856 | class _LIBCPP_TEMPLATE_VIS __copy_constructor; | 874 | class _LIBCPP_TEMPLATE_VIS __copy_constructor; |
| 857 | 875 | ||
| 858 | # define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor) \ | 876 | # define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \ |
| 859 | template <class... _Types> \ | 877 | template <class... _Types> \ |
| 860 | class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \ | 878 | class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \ |
| 861 | : public __move_constructor<__traits<_Types...>> { \ | 879 | : public __move_constructor<__traits<_Types...>> { \ |
| ... | @@ -865,20 +883,25 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor; | ... | @@ -865,20 +883,25 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor; |
| 865 | using __base_type::__base_type; \ | 883 | using __base_type::__base_type; \ |
| 866 | using __base_type::operator=; \ | 884 | using __base_type::operator=; \ |
| 867 | \ | 885 | \ |
| 868 | copy_constructor __copy_constructor(__copy_constructor&&) = default; \ | 886 | _LIBCPP_HIDE_FROM_ABI __copy_constructor(__copy_constructor&&) = default; \ |
| 869 | ~__copy_constructor() = default; \ | 887 | _LIBCPP_HIDE_FROM_ABI ~__copy_constructor() = default; \ |
| 870 | __copy_constructor& operator=(const __copy_constructor&) = default; \ | 888 | _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(const __copy_constructor&) = default; \ |
| 871 | __copy_constructor& operator=(__copy_constructor&&) = default; \ | 889 | _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(__copy_constructor&&) = default; \ |
| 890 | copy_constructor_definition; \ | ||
| 872 | } | 891 | } |
| 873 | 892 | ||
| 874 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR(_Trait::_TriviallyAvailable, | 893 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 875 | __copy_constructor(const __copy_constructor& __that) = default;); | 894 | _Trait::_TriviallyAvailable, |
| 895 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) = default); | ||
| 876 | 896 | ||
| 877 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( | 897 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 878 | _Trait::_Available, __copy_constructor(const __copy_constructor& __that) | 898 | _Trait::_Available, |
| 879 | : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); }); | 899 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) |
| 900 | : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON); | ||
| 880 | 901 | ||
| 881 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR(_Trait::_Unavailable, __copy_constructor(const __copy_constructor&) = delete;); | 902 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 903 | _Trait::_Unavailable, | ||
| 904 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor&) = delete); | ||
| 882 | 905 | ||
| 883 | # undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR | 906 | # undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR |
| 884 | 907 | ||
| ... | @@ -891,22 +914,24 @@ public: | ... | @@ -891,22 +914,24 @@ public: |
| 891 | using __base_type::operator=; | 914 | using __base_type::operator=; |
| 892 | 915 | ||
| 893 | template <size_t _Ip, class... _Args> | 916 | template <size_t _Ip, class... _Args> |
| 894 | _LIBCPP_HIDE_FROM_ABI auto& __emplace(_Args&&... __args) { | 917 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto& __emplace(_Args&&... __args) { |
| 895 | this->__destroy(); | 918 | this->__destroy(); |
| 896 | auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this), std::forward<_Args>(__args)...); | 919 | std::__construct_at(std::addressof(this->__data), in_place_index<_Ip>, std::forward<_Args>(__args)...); |
| 897 | this->__index = _Ip; | 920 | this->__index = _Ip; |
| 898 | return __res; | 921 | return __access::__base::__get_alt<_Ip>(*this).__value; |
| 899 | } | 922 | } |
| 900 | 923 | ||
| 901 | protected: | 924 | protected: |
| 902 | template <size_t _Ip, class _Tp, class _Arg> | 925 | template <size_t _Ip, class _Tp, class _Arg> |
| 903 | _LIBCPP_HIDE_FROM_ABI void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) { | 926 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) { |
| 904 | if (this->index() == _Ip) { | 927 | if (this->index() == _Ip) { |
| 905 | __a.__value = std::forward<_Arg>(__arg); | 928 | __a.__value = std::forward<_Arg>(__arg); |
| 906 | } else { | 929 | } else { |
| 907 | struct { | 930 | struct { |
| 908 | _LIBCPP_HIDE_FROM_ABI void operator()(true_type) const { __this->__emplace<_Ip>(std::forward<_Arg>(__arg)); } | 931 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()(true_type) const { |
| 909 | _LIBCPP_HIDE_FROM_ABI void operator()(false_type) const { | 932 | __this->__emplace<_Ip>(std::forward<_Arg>(__arg)); |
| 933 | } | ||
| 934 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()(false_type) const { | ||
| 910 | __this->__emplace<_Ip>(_Tp(std::forward<_Arg>(__arg))); | 935 | __this->__emplace<_Ip>(_Tp(std::forward<_Arg>(__arg))); |
| 911 | } | 936 | } |
| 912 | __assignment* __this; | 937 | __assignment* __this; |
| ... | @@ -917,7 +942,7 @@ protected: | ... | @@ -917,7 +942,7 @@ protected: |
| 917 | } | 942 | } |
| 918 | 943 | ||
| 919 | template <class _That> | 944 | template <class _That> |
| 920 | _LIBCPP_HIDE_FROM_ABI void __generic_assign(_That&& __that) { | 945 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __generic_assign(_That&& __that) { |
| 921 | if (this->valueless_by_exception() && __that.valueless_by_exception()) { | 946 | if (this->valueless_by_exception() && __that.valueless_by_exception()) { |
| 922 | // do nothing. | 947 | // do nothing. |
| 923 | } else if (__that.valueless_by_exception()) { | 948 | } else if (__that.valueless_by_exception()) { |
| ... | @@ -937,7 +962,7 @@ protected: | ... | @@ -937,7 +962,7 @@ protected: |
| 937 | template <class _Traits, _Trait = _Traits::__move_assignable_trait> | 962 | template <class _Traits, _Trait = _Traits::__move_assignable_trait> |
| 938 | class _LIBCPP_TEMPLATE_VIS __move_assignment; | 963 | class _LIBCPP_TEMPLATE_VIS __move_assignment; |
| 939 | 964 | ||
| 940 | # define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment) \ | 965 | # define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \ |
| 941 | template <class... _Types> \ | 966 | template <class... _Types> \ |
| 942 | class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \ | 967 | class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \ |
| 943 | : public __assignment<__traits<_Types...>> { \ | 968 | : public __assignment<__traits<_Types...>> { \ |
| ... | @@ -947,33 +972,36 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment; | ... | @@ -947,33 +972,36 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment; |
| 947 | using __base_type::__base_type; \ | 972 | using __base_type::__base_type; \ |
| 948 | using __base_type::operator=; \ | 973 | using __base_type::operator=; \ |
| 949 | \ | 974 | \ |
| 950 | __move_assignment(const __move_assignment&) = default; \ | 975 | _LIBCPP_HIDE_FROM_ABI __move_assignment(const __move_assignment&) = default; \ |
| 951 | __move_assignment(__move_assignment&&) = default; \ | 976 | _LIBCPP_HIDE_FROM_ABI __move_assignment(__move_assignment&&) = default; \ |
| 952 | ~__move_assignment() = default; \ | 977 | _LIBCPP_HIDE_FROM_ABI ~__move_assignment() = default; \ |
| 953 | __move_assignment& operator=(const __move_assignment&) = default; \ | 978 | _LIBCPP_HIDE_FROM_ABI __move_assignment& operator=(const __move_assignment&) = default; \ |
| 954 | move_assignment \ | 979 | move_assignment_definition; \ |
| 955 | } | 980 | } |
| 956 | 981 | ||
| 957 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_TriviallyAvailable, | 982 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_TriviallyAvailable, |
| 958 | __move_assignment& operator=(__move_assignment&& __that) = default;); | 983 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=( |
| 984 | __move_assignment&& __that) = default); | ||
| 959 | 985 | ||
| 960 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT( | 986 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT( |
| 961 | _Trait::_Available, | 987 | _Trait::_Available, |
| 962 | __move_assignment& | 988 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& |
| 963 | operator=(__move_assignment&& __that) noexcept( | 989 | operator=(__move_assignment&& __that) noexcept( |
| 964 | __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_move_assignable_v<_Types>)...>::value) { | 990 | __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_move_assignable_v<_Types>)...>::value) { |
| 965 | this->__generic_assign(std::move(__that)); | 991 | this->__generic_assign(std::move(__that)); |
| 966 | return *this; | 992 | return *this; |
| 967 | }); | 993 | } _LIBCPP_EAT_SEMICOLON); |
| 968 | 994 | ||
| 969 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_Unavailable, __move_assignment& operator=(__move_assignment&&) = delete;); | 995 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT( |
| 996 | _Trait::_Unavailable, | ||
| 997 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(__move_assignment&&) = delete); | ||
| 970 | 998 | ||
| 971 | # undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT | 999 | # undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT |
| 972 | 1000 | ||
| 973 | template <class _Traits, _Trait = _Traits::__copy_assignable_trait> | 1001 | template <class _Traits, _Trait = _Traits::__copy_assignable_trait> |
| 974 | class _LIBCPP_TEMPLATE_VIS __copy_assignment; | 1002 | class _LIBCPP_TEMPLATE_VIS __copy_assignment; |
| 975 | 1003 | ||
| 976 | # define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment) \ | 1004 | # define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \ |
| 977 | template <class... _Types> \ | 1005 | template <class... _Types> \ |
| 978 | class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \ | 1006 | class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \ |
| 979 | : public __move_assignment<__traits<_Types...>> { \ | 1007 | : public __move_assignment<__traits<_Types...>> { \ |
| ... | @@ -983,22 +1011,28 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment; | ... | @@ -983,22 +1011,28 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment; |
| 983 | using __base_type::__base_type; \ | 1011 | using __base_type::__base_type; \ |
| 984 | using __base_type::operator=; \ | 1012 | using __base_type::operator=; \ |
| 985 | \ | 1013 | \ |
| 986 | __copy_assignment(const __copy_assignment&) = default; \ | 1014 | _LIBCPP_HIDE_FROM_ABI __copy_assignment(const __copy_assignment&) = default; \ |
| 987 | __copy_assignment(__copy_assignment&&) = default; \ | 1015 | _LIBCPP_HIDE_FROM_ABI __copy_assignment(__copy_assignment&&) = default; \ |
| 988 | ~__copy_assignment() = default; \ | 1016 | _LIBCPP_HIDE_FROM_ABI ~__copy_assignment() = default; \ |
| 989 | copy_assignment __copy_assignment& operator=(__copy_assignment&&) = default; \ | 1017 | _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator=(__copy_assignment&&) = default; \ |
| 1018 | copy_assignment_definition; \ | ||
| 990 | } | 1019 | } |
| 991 | 1020 | ||
| 992 | _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_TriviallyAvailable, | 1021 | _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_TriviallyAvailable, |
| 993 | __copy_assignment& operator=(const __copy_assignment& __that) = default;); | 1022 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=( |
| 1023 | const __copy_assignment& __that) = default); | ||
| 994 | 1024 | ||
| 995 | _LIBCPP_VARIANT_COPY_ASSIGNMENT( | 1025 | _LIBCPP_VARIANT_COPY_ASSIGNMENT( |
| 996 | _Trait::_Available, __copy_assignment& operator=(const __copy_assignment& __that) { | 1026 | _Trait::_Available, |
| 1027 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& | ||
| 1028 | operator=(const __copy_assignment& __that) { | ||
| 997 | this->__generic_assign(__that); | 1029 | this->__generic_assign(__that); |
| 998 | return *this; | 1030 | return *this; |
| 999 | }); | 1031 | } _LIBCPP_EAT_SEMICOLON); |
| 1000 | 1032 | ||
| 1001 | _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable, __copy_assignment& operator=(const __copy_assignment&) = delete;); | 1033 | _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable, |
| 1034 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=( | ||
| 1035 | const __copy_assignment&) = delete); | ||
| 1002 | 1036 | ||
| 1003 | # undef _LIBCPP_VARIANT_COPY_ASSIGNMENT | 1037 | # undef _LIBCPP_VARIANT_COPY_ASSIGNMENT |
| 1004 | 1038 | ||
| ... | @@ -1014,11 +1048,11 @@ public: | ... | @@ -1014,11 +1048,11 @@ public: |
| 1014 | _LIBCPP_HIDE_FROM_ABI __impl& operator=(__impl&&) = default; | 1048 | _LIBCPP_HIDE_FROM_ABI __impl& operator=(__impl&&) = default; |
| 1015 | 1049 | ||
| 1016 | template <size_t _Ip, class _Arg> | 1050 | template <size_t _Ip, class _Arg> |
| 1017 | _LIBCPP_HIDE_FROM_ABI void __assign(_Arg&& __arg) { | 1051 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign(_Arg&& __arg) { |
| 1018 | this->__assign_alt(__access::__base::__get_alt<_Ip>(*this), std::forward<_Arg>(__arg)); | 1052 | this->__assign_alt(__access::__base::__get_alt<_Ip>(*this), std::forward<_Arg>(__arg)); |
| 1019 | } | 1053 | } |
| 1020 | 1054 | ||
| 1021 | inline _LIBCPP_HIDE_FROM_ABI void __swap(__impl& __that) { | 1055 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __swap(__impl& __that) { |
| 1022 | if (this->valueless_by_exception() && __that.valueless_by_exception()) { | 1056 | if (this->valueless_by_exception() && __that.valueless_by_exception()) { |
| 1023 | // do nothing. | 1057 | // do nothing. |
| 1024 | } else if (this->index() == __that.index()) { | 1058 | } else if (this->index() == __that.index()) { |
| ... | @@ -1063,7 +1097,7 @@ public: | ... | @@ -1063,7 +1097,7 @@ public: |
| 1063 | } | 1097 | } |
| 1064 | 1098 | ||
| 1065 | private: | 1099 | private: |
| 1066 | inline _LIBCPP_HIDE_FROM_ABI bool __move_nothrow() const { | 1100 | constexpr inline _LIBCPP_HIDE_FROM_ABI bool __move_nothrow() const { |
| 1067 | constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...}; | 1101 | constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...}; |
| 1068 | return this->valueless_by_exception() || __results[this->index()]; | 1102 | return this->valueless_by_exception() || __results[this->index()]; |
| 1069 | } | 1103 | } |
| ... | @@ -1082,13 +1116,9 @@ struct __narrowing_check { | ... | @@ -1082,13 +1116,9 @@ struct __narrowing_check { |
| 1082 | }; | 1116 | }; |
| 1083 | 1117 | ||
| 1084 | template <class _Dest, class _Source> | 1118 | template <class _Dest, class _Source> |
| 1085 | using __check_for_narrowing _LIBCPP_NODEBUG = typename _If< | 1119 | using __check_for_narrowing _LIBCPP_NODEBUG = |
| 1086 | # ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT | 1120 | typename _If< is_arithmetic<_Dest>::value, __narrowing_check, __no_narrowing_check >::template _Apply<_Dest, |
| 1087 | false && | 1121 | _Source>; |
| 1088 | # endif | ||
| 1089 | is_arithmetic<_Dest>::value, | ||
| 1090 | __narrowing_check, | ||
| 1091 | __no_narrowing_check >::template _Apply<_Dest, _Source>; | ||
| 1092 | 1122 | ||
| 1093 | template <class _Tp, size_t _Idx> | 1123 | template <class _Tp, size_t _Idx> |
| 1094 | struct __overload { | 1124 | struct __overload { |
| ... | @@ -1096,24 +1126,6 @@ struct __overload { | ... | @@ -1096,24 +1126,6 @@ struct __overload { |
| 1096 | auto operator()(_Tp, _Up&&) const -> __check_for_narrowing<_Tp, _Up>; | 1126 | auto operator()(_Tp, _Up&&) const -> __check_for_narrowing<_Tp, _Up>; |
| 1097 | }; | 1127 | }; |
| 1098 | 1128 | ||
| 1099 | // TODO(LLVM-19): Remove all occurrences of this macro. | ||
| 1100 | # ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT | ||
| 1101 | template <class _Tp, size_t> | ||
| 1102 | struct __overload_bool { | ||
| 1103 | template <class _Up, class _Ap = __remove_cvref_t<_Up>> | ||
| 1104 | auto operator()(bool, _Up&&) const -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>; | ||
| 1105 | }; | ||
| 1106 | |||
| 1107 | template <size_t _Idx> | ||
| 1108 | struct __overload<bool, _Idx> : __overload_bool<bool, _Idx> {}; | ||
| 1109 | template <size_t _Idx> | ||
| 1110 | struct __overload<bool const, _Idx> : __overload_bool<bool const, _Idx> {}; | ||
| 1111 | template <size_t _Idx> | ||
| 1112 | struct __overload<bool volatile, _Idx> : __overload_bool<bool volatile, _Idx> {}; | ||
| 1113 | template <size_t _Idx> | ||
| 1114 | struct __overload<bool const volatile, _Idx> : __overload_bool<bool const volatile, _Idx> {}; | ||
| 1115 | # endif | ||
| 1116 | |||
| 1117 | template <class... _Bases> | 1129 | template <class... _Bases> |
| 1118 | struct __all_overloads : _Bases... { | 1130 | struct __all_overloads : _Bases... { |
| 1119 | void operator()() const; | 1131 | void operator()() const; |
| ... | @@ -1169,6 +1181,9 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant | ... | @@ -1169,6 +1181,9 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant |
| 1169 | using __first_type = variant_alternative_t<0, variant>; | 1181 | using __first_type = variant_alternative_t<0, variant>; |
| 1170 | 1182 | ||
| 1171 | public: | 1183 | public: |
| 1184 | using __trivially_relocatable = | ||
| 1185 | conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>; | ||
| 1186 | |||
| 1172 | template <bool _Dummy = true, | 1187 | template <bool _Dummy = true, |
| 1173 | enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0> | 1188 | enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0> |
| 1174 | _LIBCPP_HIDE_FROM_ABI constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>) | 1189 | _LIBCPP_HIDE_FROM_ABI constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>) |
| ... | @@ -1227,7 +1242,7 @@ public: | ... | @@ -1227,7 +1242,7 @@ public: |
| 1227 | _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>) | 1242 | _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>) |
| 1228 | : __impl_(in_place_index<_Ip>, __il, std::forward<_Args>(__args)...) {} | 1243 | : __impl_(in_place_index<_Ip>, __il, std::forward<_Args>(__args)...) {} |
| 1229 | 1244 | ||
| 1230 | _LIBCPP_HIDE_FROM_ABI ~variant() = default; | 1245 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~variant() = default; |
| 1231 | 1246 | ||
| 1232 | _LIBCPP_HIDE_FROM_ABI constexpr variant& operator=(const variant&) = default; | 1247 | _LIBCPP_HIDE_FROM_ABI constexpr variant& operator=(const variant&) = default; |
| 1233 | _LIBCPP_HIDE_FROM_ABI constexpr variant& operator=(variant&&) = default; | 1248 | _LIBCPP_HIDE_FROM_ABI constexpr variant& operator=(variant&&) = default; |
| ... | @@ -1237,7 +1252,7 @@ public: | ... | @@ -1237,7 +1252,7 @@ public: |
| 1237 | class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>, | 1252 | class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>, |
| 1238 | size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, | 1253 | size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, |
| 1239 | enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>, int> = 0> | 1254 | enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>, int> = 0> |
| 1240 | _LIBCPP_HIDE_FROM_ABI variant& | 1255 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 variant& |
| 1241 | operator=(_Arg&& __arg) noexcept(is_nothrow_assignable_v<_Tp&, _Arg> && is_nothrow_constructible_v<_Tp, _Arg>) { | 1256 | operator=(_Arg&& __arg) noexcept(is_nothrow_assignable_v<_Tp&, _Arg> && is_nothrow_constructible_v<_Tp, _Arg>) { |
| 1242 | __impl_.template __assign<_Ip>(std::forward<_Arg>(__arg)); | 1257 | __impl_.template __assign<_Ip>(std::forward<_Arg>(__arg)); |
| 1243 | return *this; | 1258 | return *this; |
| ... | @@ -1248,7 +1263,7 @@ public: | ... | @@ -1248,7 +1263,7 @@ public: |
| 1248 | enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, | 1263 | enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, |
| 1249 | class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, | 1264 | class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, |
| 1250 | enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0> | 1265 | enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0> |
| 1251 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(_Args&&... __args) { | 1266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) { |
| 1252 | return __impl_.template __emplace<_Ip>(std::forward<_Args>(__args)...); | 1267 | return __impl_.template __emplace<_Ip>(std::forward<_Args>(__args)...); |
| 1253 | } | 1268 | } |
| 1254 | 1269 | ||
| ... | @@ -1258,7 +1273,7 @@ public: | ... | @@ -1258,7 +1273,7 @@ public: |
| 1258 | enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, | 1273 | enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, |
| 1259 | class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, | 1274 | class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, |
| 1260 | enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0> | 1275 | enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0> |
| 1261 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { | 1276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { |
| 1262 | return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...); | 1277 | return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...); |
| 1263 | } | 1278 | } |
| 1264 | 1279 | ||
| ... | @@ -1266,7 +1281,7 @@ public: | ... | @@ -1266,7 +1281,7 @@ public: |
| 1266 | class... _Args, | 1281 | class... _Args, |
| 1267 | size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, | 1282 | size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, |
| 1268 | enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0> | 1283 | enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0> |
| 1269 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(_Args&&... __args) { | 1284 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) { |
| 1270 | return __impl_.template __emplace<_Ip>(std::forward<_Args>(__args)...); | 1285 | return __impl_.template __emplace<_Ip>(std::forward<_Args>(__args)...); |
| 1271 | } | 1286 | } |
| 1272 | 1287 | ||
| ... | @@ -1275,7 +1290,7 @@ public: | ... | @@ -1275,7 +1290,7 @@ public: |
| 1275 | class... _Args, | 1290 | class... _Args, |
| 1276 | size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, | 1291 | size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, |
| 1277 | enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0> | 1292 | enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0> |
| 1278 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { | 1293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { |
| 1279 | return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...); | 1294 | return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...); |
| 1280 | } | 1295 | } |
| 1281 | 1296 | ||
| ... | @@ -1289,7 +1304,7 @@ public: | ... | @@ -1289,7 +1304,7 @@ public: |
| 1289 | enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value && | 1304 | enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value && |
| 1290 | __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value, | 1305 | __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value, |
| 1291 | int> = 0> | 1306 | int> = 0> |
| 1292 | _LIBCPP_HIDE_FROM_ABI void swap(variant& __that) noexcept( | 1307 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(variant& __that) noexcept( |
| 1293 | __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_swappable_v<_Types>)...>::value) { | 1308 | __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_swappable_v<_Types>)...>::value) { |
| 1294 | __impl_.__swap(__that.__impl_); | 1309 | __impl_.__swap(__that.__impl_); |
| 1295 | } | 1310 | } |
| ... | @@ -1343,8 +1358,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr au | ... | @@ -1343,8 +1358,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr au |
| 1343 | 1358 | ||
| 1344 | template <size_t _Ip, class... _Types> | 1359 | template <size_t _Ip, class... _Types> |
| 1345 | _LIBCPP_HIDE_FROM_ABI | 1360 | _LIBCPP_HIDE_FROM_ABI |
| 1346 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>& | 1361 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>& |
| 1347 | get(variant<_Types...>& __v) { | 1362 | get(variant<_Types...>& __v) { |
| 1348 | static_assert(_Ip < sizeof...(_Types)); | 1363 | static_assert(_Ip < sizeof...(_Types)); |
| 1349 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1364 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1350 | return std::__generic_get<_Ip>(__v); | 1365 | return std::__generic_get<_Ip>(__v); |
| ... | @@ -1352,8 +1367,8 @@ _LIBCPP_HIDE_FROM_ABI | ... | @@ -1352,8 +1367,8 @@ _LIBCPP_HIDE_FROM_ABI |
| 1352 | 1367 | ||
| 1353 | template <size_t _Ip, class... _Types> | 1368 | template <size_t _Ip, class... _Types> |
| 1354 | _LIBCPP_HIDE_FROM_ABI | 1369 | _LIBCPP_HIDE_FROM_ABI |
| 1355 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&& | 1370 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&& |
| 1356 | get(variant<_Types...>&& __v) { | 1371 | get(variant<_Types...>&& __v) { |
| 1357 | static_assert(_Ip < sizeof...(_Types)); | 1372 | static_assert(_Ip < sizeof...(_Types)); |
| 1358 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1373 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1359 | return std::__generic_get<_Ip>(std::move(__v)); | 1374 | return std::__generic_get<_Ip>(std::move(__v)); |
| ... | @@ -1361,8 +1376,8 @@ _LIBCPP_HIDE_FROM_ABI | ... | @@ -1361,8 +1376,8 @@ _LIBCPP_HIDE_FROM_ABI |
| 1361 | 1376 | ||
| 1362 | template <size_t _Ip, class... _Types> | 1377 | template <size_t _Ip, class... _Types> |
| 1363 | _LIBCPP_HIDE_FROM_ABI | 1378 | _LIBCPP_HIDE_FROM_ABI |
| 1364 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>& | 1379 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>& |
| 1365 | get(const variant<_Types...>& __v) { | 1380 | get(const variant<_Types...>& __v) { |
| 1366 | static_assert(_Ip < sizeof...(_Types)); | 1381 | static_assert(_Ip < sizeof...(_Types)); |
| 1367 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1382 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1368 | return std::__generic_get<_Ip>(__v); | 1383 | return std::__generic_get<_Ip>(__v); |
| ... | @@ -1370,8 +1385,8 @@ _LIBCPP_HIDE_FROM_ABI | ... | @@ -1370,8 +1385,8 @@ _LIBCPP_HIDE_FROM_ABI |
| 1370 | 1385 | ||
| 1371 | template <size_t _Ip, class... _Types> | 1386 | template <size_t _Ip, class... _Types> |
| 1372 | _LIBCPP_HIDE_FROM_ABI | 1387 | _LIBCPP_HIDE_FROM_ABI |
| 1373 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& | 1388 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& |
| 1374 | get(const variant<_Types...>&& __v) { | 1389 | get(const variant<_Types...>&& __v) { |
| 1375 | static_assert(_Ip < sizeof...(_Types)); | 1390 | static_assert(_Ip < sizeof...(_Types)); |
| 1376 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1391 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1377 | return std::__generic_get<_Ip>(std::move(__v)); | 1392 | return std::__generic_get<_Ip>(std::move(__v)); |
| ... | @@ -1572,9 +1587,9 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { | ... | @@ -1572,9 +1587,9 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1572 | # endif | 1587 | # endif |
| 1573 | 1588 | ||
| 1574 | template <class... _Types> | 1589 | template <class... _Types> |
| 1575 | _LIBCPP_HIDE_FROM_ABI auto | 1590 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto |
| 1576 | swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) | 1591 | swap(variant<_Types...>& __lhs, |
| 1577 | -> decltype(__lhs.swap(__rhs)) { | 1592 | variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) -> decltype(__lhs.swap(__rhs)) { |
| 1578 | return __lhs.swap(__rhs); | 1593 | return __lhs.swap(__rhs); |
| 1579 | } | 1594 | } |
| 1580 | 1595 | ||
| ... | @@ -1626,6 +1641,7 @@ _LIBCPP_POP_MACROS | ... | @@ -1626,6 +1641,7 @@ _LIBCPP_POP_MACROS |
| 1626 | 1641 | ||
| 1627 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 1642 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 1628 | # include <exception> | 1643 | # include <exception> |
| 1644 | # include <tuple> | ||
| 1629 | # include <type_traits> | 1645 | # include <type_traits> |
| 1630 | # include <typeinfo> | 1646 | # include <typeinfo> |
| 1631 | # include <utility> | 1647 | # include <utility> |
lib/libcxx/include/vector+140-89| ... | @@ -315,17 +315,19 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ | ... | @@ -315,17 +315,19 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ |
| 315 | #include <__algorithm/remove_if.h> | 315 | #include <__algorithm/remove_if.h> |
| 316 | #include <__algorithm/rotate.h> | 316 | #include <__algorithm/rotate.h> |
| 317 | #include <__algorithm/unwrap_iter.h> | 317 | #include <__algorithm/unwrap_iter.h> |
| 318 | #include <__assert> // all public C++ headers provide the assertion handler | 318 | #include <__assert> |
| 319 | #include <__availability> | ||
| 320 | #include <__bit_reference> | 319 | #include <__bit_reference> |
| 321 | #include <__concepts/same_as.h> | 320 | #include <__concepts/same_as.h> |
| 322 | #include <__config> | 321 | #include <__config> |
| 322 | #include <__debug_utils/sanitizers.h> | ||
| 323 | #include <__format/enable_insertable.h> | 323 | #include <__format/enable_insertable.h> |
| 324 | #include <__format/formatter.h> | 324 | #include <__format/formatter.h> |
| 325 | #include <__format/formatter_bool.h> | 325 | #include <__format/formatter_bool.h> |
| 326 | #include <__functional/hash.h> | 326 | #include <__functional/hash.h> |
| 327 | #include <__functional/unary_function.h> | 327 | #include <__functional/unary_function.h> |
| 328 | #include <__fwd/vector.h> | ||
| 328 | #include <__iterator/advance.h> | 329 | #include <__iterator/advance.h> |
| 330 | #include <__iterator/bounded_iter.h> | ||
| 329 | #include <__iterator/distance.h> | 331 | #include <__iterator/distance.h> |
| 330 | #include <__iterator/iterator_traits.h> | 332 | #include <__iterator/iterator_traits.h> |
| 331 | #include <__iterator/reverse_iterator.h> | 333 | #include <__iterator/reverse_iterator.h> |
| ... | @@ -346,17 +348,17 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ | ... | @@ -346,17 +348,17 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ |
| 346 | #include <__split_buffer> | 348 | #include <__split_buffer> |
| 347 | #include <__type_traits/is_allocator.h> | 349 | #include <__type_traits/is_allocator.h> |
| 348 | #include <__type_traits/is_constructible.h> | 350 | #include <__type_traits/is_constructible.h> |
| 349 | #include <__type_traits/is_nothrow_move_assignable.h> | 351 | #include <__type_traits/is_nothrow_assignable.h> |
| 350 | #include <__type_traits/noexcept_move_assign_container.h> | 352 | #include <__type_traits/noexcept_move_assign_container.h> |
| 351 | #include <__type_traits/type_identity.h> | 353 | #include <__type_traits/type_identity.h> |
| 352 | #include <__utility/exception_guard.h> | 354 | #include <__utility/exception_guard.h> |
| 353 | #include <__utility/forward.h> | 355 | #include <__utility/forward.h> |
| 356 | #include <__utility/is_pointer_in_range.h> | ||
| 354 | #include <__utility/move.h> | 357 | #include <__utility/move.h> |
| 355 | #include <__utility/pair.h> | 358 | #include <__utility/pair.h> |
| 356 | #include <__utility/swap.h> | 359 | #include <__utility/swap.h> |
| 357 | #include <climits> | 360 | #include <climits> |
| 358 | #include <cstring> | 361 | #include <cstring> |
| 359 | #include <iosfwd> // for forward declaration of vector | ||
| 360 | #include <limits> | 362 | #include <limits> |
| 361 | #include <stdexcept> | 363 | #include <stdexcept> |
| 362 | #include <version> | 364 | #include <version> |
| ... | @@ -399,19 +401,32 @@ public: | ... | @@ -399,19 +401,32 @@ public: |
| 399 | typedef typename __alloc_traits::difference_type difference_type; | 401 | typedef typename __alloc_traits::difference_type difference_type; |
| 400 | typedef typename __alloc_traits::pointer pointer; | 402 | typedef typename __alloc_traits::pointer pointer; |
| 401 | typedef typename __alloc_traits::const_pointer const_pointer; | 403 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 402 | // TODO: Implement iterator bounds checking without requiring the global database. | 404 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR |
| 405 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's | ||
| 406 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is | ||
| 407 | // considered contiguous. | ||
| 408 | typedef __bounded_iter<__wrap_iter<pointer>> iterator; | ||
| 409 | typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator; | ||
| 410 | #else | ||
| 403 | typedef __wrap_iter<pointer> iterator; | 411 | typedef __wrap_iter<pointer> iterator; |
| 404 | typedef __wrap_iter<const_pointer> const_iterator; | 412 | typedef __wrap_iter<const_pointer> const_iterator; |
| 413 | #endif | ||
| 405 | typedef std::reverse_iterator<iterator> reverse_iterator; | 414 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 406 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 415 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 407 | 416 | ||
| 408 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 417 | // A vector containers the following members which may be trivially relocatable: |
| 418 | // - pointer: may be trivially relocatable, so it's checked | ||
| 419 | // - allocator_type: may be trivially relocatable, so it's checked | ||
| 420 | // vector doesn't contain any self-references, so it's trivially relocatable if its members are. | ||
| 421 | using __trivially_relocatable = __conditional_t< | ||
| 422 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | ||
| 423 | vector, | ||
| 424 | void>; | ||
| 425 | |||
| 426 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | ||
| 427 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | ||
| 409 | "Allocator::value_type must be same type as value_type"); | 428 | "Allocator::value_type must be same type as value_type"); |
| 410 | 429 | ||
| 411 | static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, | ||
| 412 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | ||
| 413 | "original allocator"); | ||
| 414 | |||
| 415 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector() | 430 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector() |
| 416 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {} | 431 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {} |
| 417 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a) | 432 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a) |
| ... | @@ -422,13 +437,38 @@ public: | ... | @@ -422,13 +437,38 @@ public: |
| 422 | #endif | 437 | #endif |
| 423 | : __end_cap_(nullptr, __a) { | 438 | : __end_cap_(nullptr, __a) { |
| 424 | } | 439 | } |
| 425 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n); | 440 | |
| 441 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) { | ||
| 442 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | ||
| 443 | if (__n > 0) { | ||
| 444 | __vallocate(__n); | ||
| 445 | __construct_at_end(__n); | ||
| 446 | } | ||
| 447 | __guard.__complete(); | ||
| 448 | } | ||
| 449 | |||
| 426 | #if _LIBCPP_STD_VER >= 14 | 450 | #if _LIBCPP_STD_VER >= 14 |
| 427 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a); | 451 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a) |
| 452 | : __end_cap_(nullptr, __a) { | ||
| 453 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | ||
| 454 | if (__n > 0) { | ||
| 455 | __vallocate(__n); | ||
| 456 | __construct_at_end(__n); | ||
| 457 | } | ||
| 458 | __guard.__complete(); | ||
| 459 | } | ||
| 428 | #endif | 460 | #endif |
| 429 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x); | ||
| 430 | 461 | ||
| 431 | template <class = __enable_if_t<__is_allocator<_Allocator>::value> > | 462 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) { |
| 463 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | ||
| 464 | if (__n > 0) { | ||
| 465 | __vallocate(__n); | ||
| 466 | __construct_at_end(__n, __x); | ||
| 467 | } | ||
| 468 | __guard.__complete(); | ||
| 469 | } | ||
| 470 | |||
| 471 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | ||
| 432 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | 472 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
| 433 | vector(size_type __n, const value_type& __x, const allocator_type& __a) | 473 | vector(size_type __n, const value_type& __x, const allocator_type& __a) |
| 434 | : __end_cap_(nullptr, __a) { | 474 | : __end_cap_(nullptr, __a) { |
| ... | @@ -527,7 +567,7 @@ public: | ... | @@ -527,7 +567,7 @@ public: |
| 527 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | 567 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
| 528 | vector(vector&& __x, const __type_identity_t<allocator_type>& __a); | 568 | vector(vector&& __x, const __type_identity_t<allocator_type>& __a); |
| 529 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x) | 569 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x) |
| 530 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 570 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value); |
| 531 | 571 | ||
| 532 | template <class _InputIterator, | 572 | template <class _InputIterator, |
| 533 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | 573 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && |
| ... | @@ -597,7 +637,7 @@ public: | ... | @@ -597,7 +637,7 @@ public: |
| 597 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { | 637 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { |
| 598 | return static_cast<size_type>(__end_cap() - this->__begin_); | 638 | return static_cast<size_type>(__end_cap() - this->__begin_); |
| 599 | } | 639 | } |
| 600 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | 640 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 601 | return this->__begin_ == this->__end_; | 641 | return this->__begin_ == this->__end_; |
| 602 | } | 642 | } |
| 603 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT; | 643 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT; |
| ... | @@ -641,11 +681,11 @@ public: | ... | @@ -641,11 +681,11 @@ public: |
| 641 | template <class... _Args> | 681 | template <class... _Args> |
| 642 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | 682 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
| 643 | #if _LIBCPP_STD_VER >= 17 | 683 | #if _LIBCPP_STD_VER >= 17 |
| 644 | reference | 684 | reference |
| 645 | emplace_back(_Args&&... __args); | 685 | emplace_back(_Args&&... __args); |
| 646 | #else | 686 | #else |
| 647 | void | 687 | void |
| 648 | emplace_back(_Args&&... __args); | 688 | emplace_back(_Args&&... __args); |
| 649 | #endif | 689 | #endif |
| 650 | 690 | ||
| 651 | #if _LIBCPP_STD_VER >= 23 | 691 | #if _LIBCPP_STD_VER >= 23 |
| ... | @@ -717,7 +757,7 @@ public: | ... | @@ -717,7 +757,7 @@ public: |
| 717 | #if _LIBCPP_STD_VER >= 14 | 757 | #if _LIBCPP_STD_VER >= 14 |
| 718 | _NOEXCEPT; | 758 | _NOEXCEPT; |
| 719 | #else | 759 | #else |
| 720 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value); | 760 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 721 | #endif | 761 | #endif |
| 722 | 762 | ||
| 723 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | 763 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; |
| ... | @@ -795,12 +835,39 @@ private: | ... | @@ -795,12 +835,39 @@ private: |
| 795 | 835 | ||
| 796 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); | 836 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); |
| 797 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); | 837 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); |
| 838 | |||
| 798 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { | 839 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { |
| 840 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | ||
| 841 | // Bound the iterator according to the capacity, rather than the size. | ||
| 842 | // | ||
| 843 | // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted | ||
| 844 | // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed | ||
| 845 | // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch | ||
| 846 | // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the | ||
| 847 | // current implementation, there is no connection between a bounded iterator and its associated container, so we | ||
| 848 | // don't have a way to update existing valid iterators when the container is resized and thus have to go with | ||
| 849 | // a laxer approach. | ||
| 850 | return std::__make_bounded_iter( | ||
| 851 | std::__wrap_iter<pointer>(__p), | ||
| 852 | std::__wrap_iter<pointer>(this->__begin_), | ||
| 853 | std::__wrap_iter<pointer>(this->__end_cap())); | ||
| 854 | #else | ||
| 799 | return iterator(__p); | 855 | return iterator(__p); |
| 856 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | ||
| 800 | } | 857 | } |
| 858 | |||
| 801 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { | 859 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { |
| 860 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | ||
| 861 | // Bound the iterator according to the capacity, rather than the size. | ||
| 862 | return std::__make_bounded_iter( | ||
| 863 | std::__wrap_iter<const_pointer>(__p), | ||
| 864 | std::__wrap_iter<const_pointer>(this->__begin_), | ||
| 865 | std::__wrap_iter<const_pointer>(this->__end_cap())); | ||
| 866 | #else | ||
| 802 | return const_iterator(__p); | 867 | return const_iterator(__p); |
| 868 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | ||
| 803 | } | 869 | } |
| 870 | |||
| 804 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 871 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 805 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | 872 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); |
| 806 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer | 873 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer |
| ... | @@ -831,17 +898,9 @@ private: | ... | @@ -831,17 +898,9 @@ private: |
| 831 | // For more details, see the "Using libc++" documentation page or | 898 | // For more details, see the "Using libc++" documentation page or |
| 832 | // the documentation for __sanitizer_annotate_contiguous_container. | 899 | // the documentation for __sanitizer_annotate_contiguous_container. |
| 833 | 900 | ||
| 834 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_contiguous_container( | 901 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 835 | const void* __old_mid, const void* __new_mid) const { | 902 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { |
| 836 | (void)__old_mid; | 903 | std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid); |
| 837 | (void)__new_mid; | ||
| 838 | #ifndef _LIBCPP_HAS_NO_ASAN | ||
| 839 | const void* __beg = data(); | ||
| 840 | const void* __end = data() + capacity(); | ||
| 841 | if (!__libcpp_is_constant_evaluated() && __beg != nullptr && | ||
| 842 | __asan_annotate_container_with_allocator<_Allocator>::value) | ||
| 843 | __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); | ||
| 844 | #endif | ||
| 845 | } | 904 | } |
| 846 | 905 | ||
| 847 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { | 906 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| ... | @@ -878,6 +937,7 @@ private: | ... | @@ -878,6 +937,7 @@ private: |
| 878 | __v_.__annotate_increase(__n); | 937 | __v_.__annotate_increase(__n); |
| 879 | #endif | 938 | #endif |
| 880 | } | 939 | } |
| 940 | |||
| 881 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { | 941 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { |
| 882 | __v_.__end_ = __pos_; | 942 | __v_.__end_ = __pos_; |
| 883 | #ifndef _LIBCPP_HAS_NO_ASAN | 943 | #ifndef _LIBCPP_HAS_NO_ASAN |
| ... | @@ -891,7 +951,6 @@ private: | ... | @@ -891,7 +951,6 @@ private: |
| 891 | pointer __pos_; | 951 | pointer __pos_; |
| 892 | const_pointer const __new_end_; | 952 | const_pointer const __new_end_; |
| 893 | 953 | ||
| 894 | private: | ||
| 895 | _ConstructTransaction(_ConstructTransaction const&) = delete; | 954 | _ConstructTransaction(_ConstructTransaction const&) = delete; |
| 896 | _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; | 955 | _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; |
| 897 | }; | 956 | }; |
| ... | @@ -982,14 +1041,18 @@ template <ranges::input_range _Range, | ... | @@ -982,14 +1041,18 @@ template <ranges::input_range _Range, |
| 982 | vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>; | 1041 | vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>; |
| 983 | #endif | 1042 | #endif |
| 984 | 1043 | ||
| 1044 | // __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of | ||
| 1045 | // *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This | ||
| 1046 | // function has a strong exception guarantee. | ||
| 985 | template <class _Tp, class _Allocator> | 1047 | template <class _Tp, class _Allocator> |
| 986 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 1048 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 987 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) { | 1049 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) { |
| 988 | __annotate_delete(); | 1050 | __annotate_delete(); |
| 989 | using _RevIter = std::reverse_iterator<pointer>; | 1051 | auto __new_begin = __v.__begin_ - (__end_ - __begin_); |
| 990 | __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( | 1052 | std::__uninitialized_allocator_relocate( |
| 991 | __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_)) | 1053 | __alloc(), std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin)); |
| 992 | .base(); | 1054 | __v.__begin_ = __new_begin; |
| 1055 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | ||
| 993 | std::swap(this->__begin_, __v.__begin_); | 1056 | std::swap(this->__begin_, __v.__begin_); |
| 994 | std::swap(this->__end_, __v.__end_); | 1057 | std::swap(this->__end_, __v.__end_); |
| 995 | std::swap(this->__end_cap(), __v.__end_cap()); | 1058 | std::swap(this->__end_cap(), __v.__end_cap()); |
| ... | @@ -997,22 +1060,35 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a | ... | @@ -997,22 +1060,35 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a |
| 997 | __annotate_new(size()); | 1060 | __annotate_new(size()); |
| 998 | } | 1061 | } |
| 999 | 1062 | ||
| 1063 | // __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in | ||
| 1064 | // [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for | ||
| 1065 | // exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This | ||
| 1066 | // function has a strong exception guarantee if __begin_ == __p || __end_ == __p. | ||
| 1000 | template <class _Tp, class _Allocator> | 1067 | template <class _Tp, class _Allocator> |
| 1001 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | 1068 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer |
| 1002 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) { | 1069 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) { |
| 1003 | __annotate_delete(); | 1070 | __annotate_delete(); |
| 1004 | pointer __r = __v.__begin_; | 1071 | pointer __ret = __v.__begin_; |
| 1005 | using _RevIter = std::reverse_iterator<pointer>; | 1072 | |
| 1006 | __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( | 1073 | // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_) |
| 1007 | __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_)) | 1074 | // in case something in [__begin_, __p) throws. |
| 1008 | .base(); | 1075 | std::__uninitialized_allocator_relocate( |
| 1009 | __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_); | 1076 | __alloc(), std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_)); |
| 1077 | __v.__end_ += (__end_ - __p); | ||
| 1078 | __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them. | ||
| 1079 | auto __new_begin = __v.__begin_ - (__p - __begin_); | ||
| 1080 | |||
| 1081 | std::__uninitialized_allocator_relocate( | ||
| 1082 | __alloc(), std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin)); | ||
| 1083 | __v.__begin_ = __new_begin; | ||
| 1084 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | ||
| 1085 | |||
| 1010 | std::swap(this->__begin_, __v.__begin_); | 1086 | std::swap(this->__begin_, __v.__begin_); |
| 1011 | std::swap(this->__end_, __v.__end_); | 1087 | std::swap(this->__end_, __v.__end_); |
| 1012 | std::swap(this->__end_cap(), __v.__end_cap()); | 1088 | std::swap(this->__end_cap(), __v.__end_cap()); |
| 1013 | __v.__first_ = __v.__begin_; | 1089 | __v.__first_ = __v.__begin_; |
| 1014 | __annotate_new(size()); | 1090 | __annotate_new(size()); |
| 1015 | return __r; | 1091 | return __ret; |
| 1016 | } | 1092 | } |
| 1017 | 1093 | ||
| 1018 | template <class _Tp, class _Allocator> | 1094 | template <class _Tp, class _Allocator> |
| ... | @@ -1114,39 +1190,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type _ | ... | @@ -1114,39 +1190,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type _ |
| 1114 | } | 1190 | } |
| 1115 | } | 1191 | } |
| 1116 | 1192 | ||
| 1117 | template <class _Tp, class _Allocator> | ||
| 1118 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(size_type __n) { | ||
| 1119 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | ||
| 1120 | if (__n > 0) { | ||
| 1121 | __vallocate(__n); | ||
| 1122 | __construct_at_end(__n); | ||
| 1123 | } | ||
| 1124 | __guard.__complete(); | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | #if _LIBCPP_STD_VER >= 14 | ||
| 1128 | template <class _Tp, class _Allocator> | ||
| 1129 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) | ||
| 1130 | : __end_cap_(nullptr, __a) { | ||
| 1131 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | ||
| 1132 | if (__n > 0) { | ||
| 1133 | __vallocate(__n); | ||
| 1134 | __construct_at_end(__n); | ||
| 1135 | } | ||
| 1136 | __guard.__complete(); | ||
| 1137 | } | ||
| 1138 | #endif | ||
| 1139 | |||
| 1140 | template <class _Tp, class _Allocator> | ||
| 1141 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) { | ||
| 1142 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | ||
| 1143 | if (__n > 0) { | ||
| 1144 | __vallocate(__n); | ||
| 1145 | __construct_at_end(__n, __x); | ||
| 1146 | } | ||
| 1147 | __guard.__complete(); | ||
| 1148 | } | ||
| 1149 | |||
| 1150 | template <class _Tp, class _Allocator> | 1193 | template <class _Tp, class _Allocator> |
| 1151 | template <class _InputIterator, | 1194 | template <class _InputIterator, |
| 1152 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | 1195 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && |
| ... | @@ -1263,7 +1306,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat | ... | @@ -1263,7 +1306,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat |
| 1263 | template <class _Tp, class _Allocator> | 1306 | template <class _Tp, class _Allocator> |
| 1264 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>& | 1307 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>& |
| 1265 | vector<_Tp, _Allocator>::operator=(vector&& __x) | 1308 | vector<_Tp, _Allocator>::operator=(vector&& __x) |
| 1266 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { | 1309 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { |
| 1267 | __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | 1310 | __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 1268 | return *this; | 1311 | return *this; |
| 1269 | } | 1312 | } |
| ... | @@ -1435,7 +1478,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE | ... | @@ -1435,7 +1478,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE |
| 1435 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | 1478 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1436 | allocator_type& __a = this->__alloc(); | 1479 | allocator_type& __a = this->__alloc(); |
| 1437 | __split_buffer<value_type, allocator_type&> __v(size(), size(), __a); | 1480 | __split_buffer<value_type, allocator_type&> __v(size(), size(), __a); |
| 1438 | __swap_out_circular_buffer(__v); | 1481 | // The Standard mandates shrink_to_fit() does not increase the capacity. |
| 1482 | // With equal capacity keep the existing buffer. This avoids extra work | ||
| 1483 | // due to swapping the elements. | ||
| 1484 | if (__v.capacity() < capacity()) | ||
| 1485 | __swap_out_circular_buffer(__v); | ||
| 1439 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | 1486 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1440 | } catch (...) { | 1487 | } catch (...) { |
| 1441 | } | 1488 | } |
| ... | @@ -1563,14 +1610,13 @@ template <class _Tp, class _Allocator> | ... | @@ -1563,14 +1610,13 @@ template <class _Tp, class _Allocator> |
| 1563 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | 1610 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator |
| 1564 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { | 1611 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { |
| 1565 | pointer __p = this->__begin_ + (__position - begin()); | 1612 | pointer __p = this->__begin_ + (__position - begin()); |
| 1566 | // We can't compare unrelated pointers inside constant expressions | 1613 | if (this->__end_ < this->__end_cap()) { |
| 1567 | if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap()) { | ||
| 1568 | if (__p == this->__end_) { | 1614 | if (__p == this->__end_) { |
| 1569 | __construct_one_at_end(__x); | 1615 | __construct_one_at_end(__x); |
| 1570 | } else { | 1616 | } else { |
| 1571 | __move_range(__p, this->__end_, __p + 1); | 1617 | __move_range(__p, this->__end_, __p + 1); |
| 1572 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | 1618 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); |
| 1573 | if (__p <= __xr && __xr < this->__end_) | 1619 | if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x))) |
| 1574 | ++__xr; | 1620 | ++__xr; |
| 1575 | *__p = *__xr; | 1621 | *__p = *__xr; |
| 1576 | } | 1622 | } |
| ... | @@ -1766,7 +1812,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x) | ... | @@ -1766,7 +1812,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x) |
| 1766 | #if _LIBCPP_STD_VER >= 14 | 1812 | #if _LIBCPP_STD_VER >= 14 |
| 1767 | _NOEXCEPT | 1813 | _NOEXCEPT |
| 1768 | #else | 1814 | #else |
| 1769 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) | 1815 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 1770 | #endif | 1816 | #endif |
| 1771 | { | 1817 | { |
| 1772 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( | 1818 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( |
| ... | @@ -1952,7 +1998,7 @@ public: | ... | @@ -1952,7 +1998,7 @@ public: |
| 1952 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1998 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1953 | vector(vector&& __v, const __type_identity_t<allocator_type>& __a); | 1999 | vector(vector&& __v, const __type_identity_t<allocator_type>& __a); |
| 1954 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v) | 2000 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v) |
| 1955 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 2001 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value); |
| 1956 | 2002 | ||
| 1957 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | 2003 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1958 | void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last); | 2004 | void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last); |
| ... | @@ -1989,7 +2035,7 @@ public: | ... | @@ -1989,7 +2035,7 @@ public: |
| 1989 | return __internal_cap_to_external(__cap()); | 2035 | return __internal_cap_to_external(__cap()); |
| 1990 | } | 2036 | } |
| 1991 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; } | 2037 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; } |
| 1992 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | 2038 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { |
| 1993 | return __size_ == 0; | 2039 | return __size_ == 0; |
| 1994 | } | 2040 | } |
| 1995 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); | 2041 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); |
| ... | @@ -2107,7 +2153,7 @@ public: | ... | @@ -2107,7 +2153,7 @@ public: |
| 2107 | #if _LIBCPP_STD_VER >= 14 | 2153 | #if _LIBCPP_STD_VER >= 14 |
| 2108 | _NOEXCEPT; | 2154 | _NOEXCEPT; |
| 2109 | #else | 2155 | #else |
| 2110 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value); | 2156 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 2111 | #endif | 2157 | #endif |
| 2112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { | 2158 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { |
| 2113 | std::swap(__x, __y); | 2159 | std::swap(__x, __y); |
| ... | @@ -2499,7 +2545,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator | ... | @@ -2499,7 +2545,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator |
| 2499 | template <class _Allocator> | 2545 | template <class _Allocator> |
| 2500 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& | 2546 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& |
| 2501 | vector<bool, _Allocator>::operator=(vector&& __v) | 2547 | vector<bool, _Allocator>::operator=(vector&& __v) |
| 2502 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { | 2548 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { |
| 2503 | __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>()); | 2549 | __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>()); |
| 2504 | return *this; | 2550 | return *this; |
| 2505 | } | 2551 | } |
| ... | @@ -2769,7 +2815,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) | ... | @@ -2769,7 +2815,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) |
| 2769 | #if _LIBCPP_STD_VER >= 14 | 2815 | #if _LIBCPP_STD_VER >= 14 |
| 2770 | _NOEXCEPT | 2816 | _NOEXCEPT |
| 2771 | #else | 2817 | #else |
| 2772 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) | 2818 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 2773 | #endif | 2819 | #endif |
| 2774 | { | 2820 | { |
| 2775 | std::swap(this->__begin_, __x.__begin_); | 2821 | std::swap(this->__begin_, __x.__begin_); |
| ... | @@ -2896,7 +2942,7 @@ template <class _Tp, class _Allocator> | ... | @@ -2896,7 +2942,7 @@ template <class _Tp, class _Allocator> |
| 2896 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> | 2942 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> |
| 2897 | operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | 2943 | operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { |
| 2898 | return std::lexicographical_compare_three_way( | 2944 | return std::lexicographical_compare_three_way( |
| 2899 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>); | 2945 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 2900 | } | 2946 | } |
| 2901 | 2947 | ||
| 2902 | #endif // _LIBCPP_STD_VER <= 17 | 2948 | #endif // _LIBCPP_STD_VER <= 17 |
| ... | @@ -2972,6 +3018,11 @@ _LIBCPP_POP_MACROS | ... | @@ -2972,6 +3018,11 @@ _LIBCPP_POP_MACROS |
| 2972 | # include <atomic> | 3018 | # include <atomic> |
| 2973 | # include <concepts> | 3019 | # include <concepts> |
| 2974 | # include <cstdlib> | 3020 | # include <cstdlib> |
| 3021 | # include <iosfwd> | ||
| 3022 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | ||
| 3023 | # include <locale> | ||
| 3024 | # endif | ||
| 3025 | # include <tuple> | ||
| 2975 | # include <type_traits> | 3026 | # include <type_traits> |
| 2976 | # include <typeinfo> | 3027 | # include <typeinfo> |
| 2977 | # include <utility> | 3028 | # include <utility> |
lib/libcxx/include/version+63-26| ... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +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_allocate_at_least 202106L <memory> | 19 | __cpp_lib_allocate_at_least 202302L <memory> |
| 20 | __cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list> | 20 | __cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list> |
| 21 | <map> <memory> <scoped_allocator> | 21 | <map> <memory> <scoped_allocator> |
| 22 | <set> <string> <unordered_map> | 22 | <set> <string> <unordered_map> |
| ... | @@ -35,13 +35,13 @@ __cpp_lib_atomic_flag_test 201907L <atomic> | ... | @@ -35,13 +35,13 @@ __cpp_lib_atomic_flag_test 201907L <atomic> |
| 35 | __cpp_lib_atomic_float 201711L <atomic> | 35 | __cpp_lib_atomic_float 201711L <atomic> |
| 36 | __cpp_lib_atomic_is_always_lock_free 201603L <atomic> | 36 | __cpp_lib_atomic_is_always_lock_free 201603L <atomic> |
| 37 | __cpp_lib_atomic_lock_free_type_aliases 201907L <atomic> | 37 | __cpp_lib_atomic_lock_free_type_aliases 201907L <atomic> |
| 38 | __cpp_lib_atomic_min_max 202403L <atomic> | ||
| 38 | __cpp_lib_atomic_ref 201806L <atomic> | 39 | __cpp_lib_atomic_ref 201806L <atomic> |
| 39 | __cpp_lib_atomic_shared_ptr 201711L <atomic> | 40 | __cpp_lib_atomic_shared_ptr 201711L <atomic> |
| 40 | __cpp_lib_atomic_value_initialization 201911L <atomic> <memory> | 41 | __cpp_lib_atomic_value_initialization 201911L <atomic> <memory> |
| 41 | __cpp_lib_atomic_wait 201907L <atomic> | 42 | __cpp_lib_atomic_wait 201907L <atomic> |
| 42 | __cpp_lib_barrier 201907L <barrier> | 43 | __cpp_lib_barrier 201907L <barrier> |
| 43 | __cpp_lib_bind_back 202306L <functional> | 44 | __cpp_lib_bind_back 202202L <functional> |
| 44 | 202202L // C++23 | ||
| 45 | __cpp_lib_bind_front 202306L <functional> | 45 | __cpp_lib_bind_front 202306L <functional> |
| 46 | 201907L // C++20 | 46 | 201907L // C++20 |
| 47 | __cpp_lib_bit_cast 201806L <bit> | 47 | __cpp_lib_bit_cast 201806L <bit> |
| ... | @@ -70,6 +70,7 @@ __cpp_lib_constexpr_functional 201907L <functional> | ... | @@ -70,6 +70,7 @@ __cpp_lib_constexpr_functional 201907L <functional> |
| 70 | __cpp_lib_constexpr_iterator 201811L <iterator> | 70 | __cpp_lib_constexpr_iterator 201811L <iterator> |
| 71 | __cpp_lib_constexpr_memory 202202L <memory> | 71 | __cpp_lib_constexpr_memory 202202L <memory> |
| 72 | 201811L // C++20 | 72 | 201811L // C++20 |
| 73 | __cpp_lib_constexpr_new 202406L <new> | ||
| 73 | __cpp_lib_constexpr_numeric 201911L <numeric> | 74 | __cpp_lib_constexpr_numeric 201911L <numeric> |
| 74 | __cpp_lib_constexpr_string 201907L <string> | 75 | __cpp_lib_constexpr_string 201907L <string> |
| 75 | __cpp_lib_constexpr_string_view 201811L <string_view> | 76 | __cpp_lib_constexpr_string_view 201811L <string_view> |
| ... | @@ -77,9 +78,18 @@ __cpp_lib_constexpr_tuple 201811L <tuple> | ... | @@ -77,9 +78,18 @@ __cpp_lib_constexpr_tuple 201811L <tuple> |
| 77 | __cpp_lib_constexpr_typeinfo 202106L <typeinfo> | 78 | __cpp_lib_constexpr_typeinfo 202106L <typeinfo> |
| 78 | __cpp_lib_constexpr_utility 201811L <utility> | 79 | __cpp_lib_constexpr_utility 201811L <utility> |
| 79 | __cpp_lib_constexpr_vector 201907L <vector> | 80 | __cpp_lib_constexpr_vector 201907L <vector> |
| 81 | __cpp_lib_constrained_equality 202403L <optional> <tuple> <utility> | ||
| 82 | <variant> | ||
| 83 | __cpp_lib_containers_ranges 202202L <deque> <forward_list> <list> | ||
| 84 | <map> <queue> <set> | ||
| 85 | <stack> <string> <unordered_map> | ||
| 86 | <unordered_set> <vector> | ||
| 80 | __cpp_lib_copyable_function 202306L <functional> | 87 | __cpp_lib_copyable_function 202306L <functional> |
| 81 | __cpp_lib_coroutine 201902L <coroutine> | 88 | __cpp_lib_coroutine 201902L <coroutine> |
| 82 | __cpp_lib_debugging 202311L <debugging> | 89 | __cpp_lib_debugging 202311L <debugging> |
| 90 | __cpp_lib_default_template_type_for_algorithm_values 202403L <algorithm> <deque> <forward_list> | ||
| 91 | <list> <ranges> <string> | ||
| 92 | <vector> | ||
| 83 | __cpp_lib_destroying_delete 201806L <new> | 93 | __cpp_lib_destroying_delete 201806L <new> |
| 84 | __cpp_lib_enable_shared_from_this 201603L <memory> | 94 | __cpp_lib_enable_shared_from_this 201603L <memory> |
| 85 | __cpp_lib_endian 201907L <bit> | 95 | __cpp_lib_endian 201907L <bit> |
| ... | @@ -91,7 +101,8 @@ __cpp_lib_execution 201902L <execution> | ... | @@ -91,7 +101,8 @@ __cpp_lib_execution 201902L <execution> |
| 91 | 201603L // C++17 | 101 | 201603L // C++17 |
| 92 | __cpp_lib_expected 202211L <expected> | 102 | __cpp_lib_expected 202211L <expected> |
| 93 | __cpp_lib_filesystem 201703L <filesystem> | 103 | __cpp_lib_filesystem 201703L <filesystem> |
| 94 | __cpp_lib_format 202106L <format> | 104 | __cpp_lib_format 202110L <format> |
| 105 | __cpp_lib_format_path 202403L <filesystem> | ||
| 95 | __cpp_lib_format_ranges 202207L <format> | 106 | __cpp_lib_format_ranges 202207L <format> |
| 96 | __cpp_lib_format_uchar 202311L <format> | 107 | __cpp_lib_format_uchar 202311L <format> |
| 97 | __cpp_lib_formatters 202302L <stacktrace> <thread> | 108 | __cpp_lib_formatters 202302L <stacktrace> <thread> |
| ... | @@ -107,6 +118,7 @@ __cpp_lib_freestanding_variant 202311L <variant> | ... | @@ -107,6 +118,7 @@ __cpp_lib_freestanding_variant 202311L <variant> |
| 107 | __cpp_lib_fstream_native_handle 202306L <fstream> | 118 | __cpp_lib_fstream_native_handle 202306L <fstream> |
| 108 | __cpp_lib_function_ref 202306L <functional> | 119 | __cpp_lib_function_ref 202306L <functional> |
| 109 | __cpp_lib_gcd_lcm 201606L <numeric> | 120 | __cpp_lib_gcd_lcm 201606L <numeric> |
| 121 | __cpp_lib_generate_random 202403L <random> | ||
| 110 | __cpp_lib_generic_associative_lookup 201304L <map> <set> | 122 | __cpp_lib_generic_associative_lookup 201304L <map> <set> |
| 111 | __cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set> | 123 | __cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set> |
| 112 | __cpp_lib_hardware_interference_size 201703L <new> | 124 | __cpp_lib_hardware_interference_size 201703L <new> |
| ... | @@ -114,6 +126,7 @@ __cpp_lib_has_unique_object_representations 201606L <type_traits> | ... | @@ -114,6 +126,7 @@ __cpp_lib_has_unique_object_representations 201606L <type_traits> |
| 114 | __cpp_lib_hazard_pointer 202306L <hazard_pointer> | 126 | __cpp_lib_hazard_pointer 202306L <hazard_pointer> |
| 115 | __cpp_lib_hypot 201603L <cmath> | 127 | __cpp_lib_hypot 201603L <cmath> |
| 116 | __cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector> | 128 | __cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector> |
| 129 | __cpp_lib_inplace_vector 202406L <inplace_vector> | ||
| 117 | __cpp_lib_int_pow2 202002L <bit> | 130 | __cpp_lib_int_pow2 202002L <bit> |
| 118 | __cpp_lib_integer_comparison_functions 202002L <utility> | 131 | __cpp_lib_integer_comparison_functions 202002L <utility> |
| 119 | __cpp_lib_integer_sequence 201304L <utility> | 132 | __cpp_lib_integer_sequence 201304L <utility> |
| ... | @@ -132,6 +145,8 @@ __cpp_lib_is_null_pointer 201309L <type_traits> | ... | @@ -132,6 +145,8 @@ __cpp_lib_is_null_pointer 201309L <type_traits> |
| 132 | __cpp_lib_is_pointer_interconvertible 201907L <type_traits> | 145 | __cpp_lib_is_pointer_interconvertible 201907L <type_traits> |
| 133 | __cpp_lib_is_scoped_enum 202011L <type_traits> | 146 | __cpp_lib_is_scoped_enum 202011L <type_traits> |
| 134 | __cpp_lib_is_swappable 201603L <type_traits> | 147 | __cpp_lib_is_swappable 201603L <type_traits> |
| 148 | __cpp_lib_is_virtual_base_of 202406L <type_traits> | ||
| 149 | __cpp_lib_is_within_lifetime 202306L <type_traits> | ||
| 135 | __cpp_lib_jthread 201911L <stop_token> <thread> | 150 | __cpp_lib_jthread 201911L <stop_token> <thread> |
| 136 | __cpp_lib_latch 201907L <latch> | 151 | __cpp_lib_latch 201907L <latch> |
| 137 | __cpp_lib_launder 201606L <new> | 152 | __cpp_lib_launder 201606L <new> |
| ... | @@ -144,7 +159,8 @@ __cpp_lib_make_unique 201304L <memory> | ... | @@ -144,7 +159,8 @@ __cpp_lib_make_unique 201304L <memory> |
| 144 | __cpp_lib_map_try_emplace 201411L <map> | 159 | __cpp_lib_map_try_emplace 201411L <map> |
| 145 | __cpp_lib_math_constants 201907L <numbers> | 160 | __cpp_lib_math_constants 201907L <numbers> |
| 146 | __cpp_lib_math_special_functions 201603L <cmath> | 161 | __cpp_lib_math_special_functions 201603L <cmath> |
| 147 | __cpp_lib_mdspan 202207L <mdspan> | 162 | __cpp_lib_mdspan 202406L <mdspan> |
| 163 | 202207L // C++23 | ||
| 148 | __cpp_lib_memory_resource 201603L <memory_resource> | 164 | __cpp_lib_memory_resource 201603L <memory_resource> |
| 149 | __cpp_lib_move_iterator_concept 202207L <iterator> | 165 | __cpp_lib_move_iterator_concept 202207L <iterator> |
| 150 | __cpp_lib_move_only_function 202110L <functional> | 166 | __cpp_lib_move_only_function 202110L <functional> |
| ... | @@ -158,9 +174,11 @@ __cpp_lib_not_fn 201603L <functional> | ... | @@ -158,9 +174,11 @@ __cpp_lib_not_fn 201603L <functional> |
| 158 | __cpp_lib_null_iterators 201304L <iterator> | 174 | __cpp_lib_null_iterators 201304L <iterator> |
| 159 | __cpp_lib_optional 202110L <optional> | 175 | __cpp_lib_optional 202110L <optional> |
| 160 | 201606L // C++17 | 176 | 201606L // C++17 |
| 177 | __cpp_lib_optional_range_support 202406L <optional> | ||
| 161 | __cpp_lib_out_ptr 202311L <memory> | 178 | __cpp_lib_out_ptr 202311L <memory> |
| 162 | 202106L // C++23 | 179 | 202106L // C++23 |
| 163 | __cpp_lib_parallel_algorithm 201603L <algorithm> <numeric> | 180 | __cpp_lib_parallel_algorithm 201603L <algorithm> <numeric> |
| 181 | __cpp_lib_philox_engine 202406L <random> | ||
| 164 | __cpp_lib_polymorphic_allocator 201902L <memory_resource> | 182 | __cpp_lib_polymorphic_allocator 201902L <memory_resource> |
| 165 | __cpp_lib_print 202207L <ostream> <print> | 183 | __cpp_lib_print 202207L <ostream> <print> |
| 166 | __cpp_lib_quoted_string_io 201304L <iomanip> | 184 | __cpp_lib_quoted_string_io 201304L <iomanip> |
| ... | @@ -170,20 +188,21 @@ __cpp_lib_ranges_as_const 202207L <ranges> | ... | @@ -170,20 +188,21 @@ __cpp_lib_ranges_as_const 202207L <ranges> |
| 170 | __cpp_lib_ranges_as_rvalue 202207L <ranges> | 188 | __cpp_lib_ranges_as_rvalue 202207L <ranges> |
| 171 | __cpp_lib_ranges_chunk 202202L <ranges> | 189 | __cpp_lib_ranges_chunk 202202L <ranges> |
| 172 | __cpp_lib_ranges_chunk_by 202202L <ranges> | 190 | __cpp_lib_ranges_chunk_by 202202L <ranges> |
| 191 | __cpp_lib_ranges_concat 202403L <ranges> | ||
| 192 | __cpp_lib_ranges_contains 202207L <algorithm> | ||
| 193 | __cpp_lib_ranges_find_last 202207L <algorithm> | ||
| 173 | __cpp_lib_ranges_iota 202202L <numeric> | 194 | __cpp_lib_ranges_iota 202202L <numeric> |
| 174 | __cpp_lib_ranges_join_with 202202L <ranges> | 195 | __cpp_lib_ranges_join_with 202202L <ranges> |
| 175 | __cpp_lib_ranges_repeat 202207L <ranges> | 196 | __cpp_lib_ranges_repeat 202207L <ranges> |
| 176 | __cpp_lib_ranges_slide 202202L <ranges> | 197 | __cpp_lib_ranges_slide 202202L <ranges> |
| 177 | __cpp_lib_ranges_starts_ends_with 202106L <algorithm> | 198 | __cpp_lib_ranges_starts_ends_with 202106L <algorithm> |
| 178 | __cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list> | 199 | __cpp_lib_ranges_to_container 202202L <ranges> |
| 179 | <map> <queue> <ranges> | ||
| 180 | <set> <stack> <string> | ||
| 181 | <unordered_map> <unordered_set> <vector> | ||
| 182 | __cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility> | 200 | __cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility> |
| 183 | __cpp_lib_ratio 202306L <ratio> | 201 | __cpp_lib_ratio 202306L <ratio> |
| 184 | __cpp_lib_raw_memory_algorithms 201606L <memory> | 202 | __cpp_lib_raw_memory_algorithms 201606L <memory> |
| 185 | __cpp_lib_rcu 202306L <rcu> | 203 | __cpp_lib_rcu 202306L <rcu> |
| 186 | __cpp_lib_reference_from_temporary 202202L <type_traits> | 204 | __cpp_lib_reference_from_temporary 202202L <type_traits> |
| 205 | __cpp_lib_reference_wrapper 202403L <functional> | ||
| 187 | __cpp_lib_remove_cvref 201711L <type_traits> | 206 | __cpp_lib_remove_cvref 201711L <type_traits> |
| 188 | __cpp_lib_result_of_sfinae 201210L <functional> <type_traits> | 207 | __cpp_lib_result_of_sfinae 201210L <functional> <type_traits> |
| 189 | __cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm> | 208 | __cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm> |
| ... | @@ -191,6 +210,7 @@ __cpp_lib_sample 201603L <algorithm> | ... | @@ -191,6 +210,7 @@ __cpp_lib_sample 201603L <algorithm> |
| 191 | __cpp_lib_saturation_arithmetic 202311L <numeric> | 210 | __cpp_lib_saturation_arithmetic 202311L <numeric> |
| 192 | __cpp_lib_scoped_lock 201703L <mutex> | 211 | __cpp_lib_scoped_lock 201703L <mutex> |
| 193 | __cpp_lib_semaphore 201907L <semaphore> | 212 | __cpp_lib_semaphore 201907L <semaphore> |
| 213 | __cpp_lib_senders 202406L <execution> | ||
| 194 | __cpp_lib_shared_mutex 201505L <shared_mutex> | 214 | __cpp_lib_shared_mutex 201505L <shared_mutex> |
| 195 | __cpp_lib_shared_ptr_arrays 201707L <memory> | 215 | __cpp_lib_shared_ptr_arrays 201707L <memory> |
| 196 | 201611L // C++17 | 216 | 201611L // C++17 |
| ... | @@ -212,7 +232,8 @@ __cpp_lib_stdatomic_h 202011L <stdatomic.h> | ... | @@ -212,7 +232,8 @@ __cpp_lib_stdatomic_h 202011L <stdatomic.h> |
| 212 | __cpp_lib_string_contains 202011L <string> <string_view> | 232 | __cpp_lib_string_contains 202011L <string> <string_view> |
| 213 | __cpp_lib_string_resize_and_overwrite 202110L <string> | 233 | __cpp_lib_string_resize_and_overwrite 202110L <string> |
| 214 | __cpp_lib_string_udls 201304L <string> | 234 | __cpp_lib_string_udls 201304L <string> |
| 215 | __cpp_lib_string_view 201803L <string> <string_view> | 235 | __cpp_lib_string_view 202403L <string> <string_view> |
| 236 | 201803L // C++20 | ||
| 216 | 201606L // C++17 | 237 | 201606L // C++17 |
| 217 | __cpp_lib_submdspan 202306L <mdspan> | 238 | __cpp_lib_submdspan 202306L <mdspan> |
| 218 | __cpp_lib_syncbuf 201803L <syncstream> | 239 | __cpp_lib_syncbuf 201803L <syncstream> |
| ... | @@ -240,12 +261,9 @@ __cpp_lib_unreachable 202202L <utility> | ... | @@ -240,12 +261,9 @@ __cpp_lib_unreachable 202202L <utility> |
| 240 | __cpp_lib_unwrap_ref 201811L <functional> | 261 | __cpp_lib_unwrap_ref 201811L <functional> |
| 241 | __cpp_lib_variant 202102L <variant> | 262 | __cpp_lib_variant 202102L <variant> |
| 242 | __cpp_lib_void_t 201411L <type_traits> | 263 | __cpp_lib_void_t 201411L <type_traits> |
| 243 | __cpp_lib_within_lifetime 202306L <type_traits> | ||
| 244 | 264 | ||
| 245 | */ | 265 | */ |
| 246 | 266 | ||
| 247 | #include <__assert> // all public C++ headers provide the assertion handler | ||
| 248 | #include <__availability> | ||
| 249 | #include <__config> | 267 | #include <__config> |
| 250 | 268 | ||
| 251 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 269 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -351,7 +369,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -351,7 +369,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 351 | # define __cpp_lib_atomic_flag_test 201907L | 369 | # define __cpp_lib_atomic_flag_test 201907L |
| 352 | // # define __cpp_lib_atomic_float 201711L | 370 | // # define __cpp_lib_atomic_float 201711L |
| 353 | # define __cpp_lib_atomic_lock_free_type_aliases 201907L | 371 | # define __cpp_lib_atomic_lock_free_type_aliases 201907L |
| 354 | // # define __cpp_lib_atomic_ref 201806L | 372 | # define __cpp_lib_atomic_ref 201806L |
| 355 | // # define __cpp_lib_atomic_shared_ptr 201711L | 373 | // # define __cpp_lib_atomic_shared_ptr 201711L |
| 356 | # define __cpp_lib_atomic_value_initialization 201911L | 374 | # define __cpp_lib_atomic_value_initialization 201911L |
| 357 | # if _LIBCPP_AVAILABILITY_HAS_SYNC | 375 | # if _LIBCPP_AVAILABILITY_HAS_SYNC |
| ... | @@ -388,7 +406,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -388,7 +406,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 388 | # define __cpp_lib_erase_if 202002L | 406 | # define __cpp_lib_erase_if 202002L |
| 389 | # undef __cpp_lib_execution | 407 | # undef __cpp_lib_execution |
| 390 | // # define __cpp_lib_execution 201902L | 408 | // # define __cpp_lib_execution 201902L |
| 391 | // # define __cpp_lib_format 202106L | 409 | # define __cpp_lib_format 202110L |
| 392 | # define __cpp_lib_format_uchar 202311L | 410 | # define __cpp_lib_format_uchar 202311L |
| 393 | # define __cpp_lib_generic_unordered_lookup 201811L | 411 | # define __cpp_lib_generic_unordered_lookup 201811L |
| 394 | # define __cpp_lib_int_pow2 202002L | 412 | # define __cpp_lib_int_pow2 202002L |
| ... | @@ -428,7 +446,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -428,7 +446,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 428 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) | 446 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) |
| 429 | # define __cpp_lib_syncbuf 201803L | 447 | # define __cpp_lib_syncbuf 201803L |
| 430 | # endif | 448 | # endif |
| 431 | // # define __cpp_lib_three_way_comparison 201907L | 449 | # define __cpp_lib_three_way_comparison 201907L |
| 432 | # define __cpp_lib_to_address 201711L | 450 | # define __cpp_lib_to_address 201711L |
| 433 | # define __cpp_lib_to_array 201907L | 451 | # define __cpp_lib_to_array 201907L |
| 434 | # define __cpp_lib_type_identity 201806L | 452 | # define __cpp_lib_type_identity 201806L |
| ... | @@ -437,9 +455,9 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -437,9 +455,9 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 437 | 455 | ||
| 438 | #if _LIBCPP_STD_VER >= 23 | 456 | #if _LIBCPP_STD_VER >= 23 |
| 439 | # define __cpp_lib_adaptor_iterator_pair_constructor 202106L | 457 | # define __cpp_lib_adaptor_iterator_pair_constructor 202106L |
| 440 | # define __cpp_lib_allocate_at_least 202106L | 458 | # define __cpp_lib_allocate_at_least 202302L |
| 441 | // # define __cpp_lib_associative_heterogeneous_erasure 202110L | 459 | // # define __cpp_lib_associative_heterogeneous_erasure 202110L |
| 442 | // # define __cpp_lib_bind_back 202202L | 460 | # define __cpp_lib_bind_back 202202L |
| 443 | # define __cpp_lib_byteswap 202110L | 461 | # define __cpp_lib_byteswap 202110L |
| 444 | # define __cpp_lib_constexpr_bitset 202207L | 462 | # define __cpp_lib_constexpr_bitset 202207L |
| 445 | # define __cpp_lib_constexpr_charconv 202207L | 463 | # define __cpp_lib_constexpr_charconv 202207L |
| ... | @@ -447,6 +465,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -447,6 +465,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 447 | # undef __cpp_lib_constexpr_memory | 465 | # undef __cpp_lib_constexpr_memory |
| 448 | # define __cpp_lib_constexpr_memory 202202L | 466 | # define __cpp_lib_constexpr_memory 202202L |
| 449 | # define __cpp_lib_constexpr_typeinfo 202106L | 467 | # define __cpp_lib_constexpr_typeinfo 202106L |
| 468 | # define __cpp_lib_containers_ranges 202202L | ||
| 450 | # define __cpp_lib_expected 202211L | 469 | # define __cpp_lib_expected 202211L |
| 451 | # define __cpp_lib_format_ranges 202207L | 470 | # define __cpp_lib_format_ranges 202207L |
| 452 | // # define __cpp_lib_formatters 202302L | 471 | // # define __cpp_lib_formatters 202302L |
| ... | @@ -455,20 +474,23 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -455,20 +474,23 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 455 | # define __cpp_lib_ios_noreplace 202207L | 474 | # define __cpp_lib_ios_noreplace 202207L |
| 456 | # define __cpp_lib_is_scoped_enum 202011L | 475 | # define __cpp_lib_is_scoped_enum 202011L |
| 457 | # define __cpp_lib_mdspan 202207L | 476 | # define __cpp_lib_mdspan 202207L |
| 477 | # define __cpp_lib_modules 202207L | ||
| 458 | // # define __cpp_lib_move_only_function 202110L | 478 | // # define __cpp_lib_move_only_function 202110L |
| 459 | # undef __cpp_lib_optional | 479 | # undef __cpp_lib_optional |
| 460 | # define __cpp_lib_optional 202110L | 480 | # define __cpp_lib_optional 202110L |
| 461 | // # define __cpp_lib_out_ptr 202106L | 481 | # define __cpp_lib_out_ptr 202106L |
| 462 | # define __cpp_lib_print 202207L | 482 | # define __cpp_lib_print 202207L |
| 463 | // # define __cpp_lib_ranges_as_const 202207L | 483 | // # define __cpp_lib_ranges_as_const 202207L |
| 464 | # define __cpp_lib_ranges_as_rvalue 202207L | 484 | # define __cpp_lib_ranges_as_rvalue 202207L |
| 465 | // # define __cpp_lib_ranges_chunk 202202L | 485 | // # define __cpp_lib_ranges_chunk 202202L |
| 466 | # define __cpp_lib_ranges_chunk_by 202202L | 486 | # define __cpp_lib_ranges_chunk_by 202202L |
| 487 | # define __cpp_lib_ranges_contains 202207L | ||
| 488 | # define __cpp_lib_ranges_find_last 202207L | ||
| 467 | // # define __cpp_lib_ranges_iota 202202L | 489 | // # define __cpp_lib_ranges_iota 202202L |
| 468 | // # define __cpp_lib_ranges_join_with 202202L | 490 | // # define __cpp_lib_ranges_join_with 202202L |
| 469 | # define __cpp_lib_ranges_repeat 202207L | 491 | # define __cpp_lib_ranges_repeat 202207L |
| 470 | // # define __cpp_lib_ranges_slide 202202L | 492 | // # define __cpp_lib_ranges_slide 202202L |
| 471 | // # define __cpp_lib_ranges_starts_ends_with 202106L | 493 | # define __cpp_lib_ranges_starts_ends_with 202106L |
| 472 | # define __cpp_lib_ranges_to_container 202202L | 494 | # define __cpp_lib_ranges_to_container 202202L |
| 473 | // # define __cpp_lib_ranges_zip 202110L | 495 | // # define __cpp_lib_ranges_zip 202110L |
| 474 | // # define __cpp_lib_reference_from_temporary 202202L | 496 | // # define __cpp_lib_reference_from_temporary 202202L |
| ... | @@ -477,7 +499,6 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -477,7 +499,6 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 477 | # define __cpp_lib_stdatomic_h 202011L | 499 | # define __cpp_lib_stdatomic_h 202011L |
| 478 | # define __cpp_lib_string_contains 202011L | 500 | # define __cpp_lib_string_contains 202011L |
| 479 | # define __cpp_lib_string_resize_and_overwrite 202110L | 501 | # define __cpp_lib_string_resize_and_overwrite 202110L |
| 480 | // # define __cpp_lib_to_string 202306L | ||
| 481 | # define __cpp_lib_to_underlying 202102L | 502 | # define __cpp_lib_to_underlying 202102L |
| 482 | // # define __cpp_lib_tuple_like 202207L | 503 | // # define __cpp_lib_tuple_like 202207L |
| 483 | # define __cpp_lib_unreachable 202202L | 504 | # define __cpp_lib_unreachable 202202L |
| ... | @@ -485,13 +506,16 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -485,13 +506,16 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 485 | 506 | ||
| 486 | #if _LIBCPP_STD_VER >= 26 | 507 | #if _LIBCPP_STD_VER >= 26 |
| 487 | // # define __cpp_lib_associative_heterogeneous_insertion 202306L | 508 | // # define __cpp_lib_associative_heterogeneous_insertion 202306L |
| 488 | # undef __cpp_lib_bind_back | 509 | // # define __cpp_lib_atomic_min_max 202403L |
| 489 | // # define __cpp_lib_bind_back 202306L | ||
| 490 | # undef __cpp_lib_bind_front | 510 | # undef __cpp_lib_bind_front |
| 491 | # define __cpp_lib_bind_front 202306L | 511 | # define __cpp_lib_bind_front 202306L |
| 492 | # define __cpp_lib_bitset 202306L | 512 | # define __cpp_lib_bitset 202306L |
| 513 | // # define __cpp_lib_constexpr_new 202406L | ||
| 514 | // # define __cpp_lib_constrained_equality 202403L | ||
| 493 | // # define __cpp_lib_copyable_function 202306L | 515 | // # define __cpp_lib_copyable_function 202306L |
| 494 | // # define __cpp_lib_debugging 202311L | 516 | // # define __cpp_lib_debugging 202311L |
| 517 | // # define __cpp_lib_default_template_type_for_algorithm_values 202403L | ||
| 518 | // # define __cpp_lib_format_path 202403L | ||
| 495 | // # define __cpp_lib_freestanding_algorithm 202311L | 519 | // # define __cpp_lib_freestanding_algorithm 202311L |
| 496 | // # define __cpp_lib_freestanding_array 202311L | 520 | // # define __cpp_lib_freestanding_array 202311L |
| 497 | // # define __cpp_lib_freestanding_cstring 202306L | 521 | // # define __cpp_lib_freestanding_cstring 202306L |
| ... | @@ -504,24 +528,37 @@ __cpp_lib_within_lifetime 202306L <type_traits> | ... | @@ -504,24 +528,37 @@ __cpp_lib_within_lifetime 202306L <type_traits> |
| 504 | # define __cpp_lib_fstream_native_handle 202306L | 528 | # define __cpp_lib_fstream_native_handle 202306L |
| 505 | # endif | 529 | # endif |
| 506 | // # define __cpp_lib_function_ref 202306L | 530 | // # define __cpp_lib_function_ref 202306L |
| 531 | // # define __cpp_lib_generate_random 202403L | ||
| 507 | // # define __cpp_lib_hazard_pointer 202306L | 532 | // # define __cpp_lib_hazard_pointer 202306L |
| 533 | // # define __cpp_lib_inplace_vector 202406L | ||
| 534 | // # define __cpp_lib_is_virtual_base_of 202406L | ||
| 535 | // # define __cpp_lib_is_within_lifetime 202306L | ||
| 508 | // # define __cpp_lib_linalg 202311L | 536 | // # define __cpp_lib_linalg 202311L |
| 537 | # undef __cpp_lib_mdspan | ||
| 538 | # define __cpp_lib_mdspan 202406L | ||
| 539 | // # define __cpp_lib_optional_range_support 202406L | ||
| 509 | # undef __cpp_lib_out_ptr | 540 | # undef __cpp_lib_out_ptr |
| 510 | // # define __cpp_lib_out_ptr 202311L | 541 | # define __cpp_lib_out_ptr 202311L |
| 542 | // # define __cpp_lib_philox_engine 202406L | ||
| 543 | // # define __cpp_lib_ranges_concat 202403L | ||
| 511 | # define __cpp_lib_ratio 202306L | 544 | # define __cpp_lib_ratio 202306L |
| 512 | // # define __cpp_lib_rcu 202306L | 545 | // # define __cpp_lib_rcu 202306L |
| 546 | # define __cpp_lib_reference_wrapper 202403L | ||
| 513 | # define __cpp_lib_saturation_arithmetic 202311L | 547 | # define __cpp_lib_saturation_arithmetic 202311L |
| 548 | // # define __cpp_lib_senders 202406L | ||
| 514 | // # define __cpp_lib_smart_ptr_owner_equality 202306L | 549 | // # define __cpp_lib_smart_ptr_owner_equality 202306L |
| 515 | # define __cpp_lib_span_at 202311L | 550 | # define __cpp_lib_span_at 202311L |
| 516 | # define __cpp_lib_span_initializer_list 202311L | 551 | # define __cpp_lib_span_initializer_list 202311L |
| 517 | // # define __cpp_lib_sstream_from_string_view 202306L | 552 | # define __cpp_lib_sstream_from_string_view 202306L |
| 553 | # undef __cpp_lib_string_view | ||
| 554 | # define __cpp_lib_string_view 202403L | ||
| 518 | // # define __cpp_lib_submdspan 202306L | 555 | // # define __cpp_lib_submdspan 202306L |
| 519 | // # define __cpp_lib_text_encoding 202306L | 556 | // # define __cpp_lib_text_encoding 202306L |
| 520 | # undef __cpp_lib_to_chars | 557 | # undef __cpp_lib_to_chars |
| 521 | // # define __cpp_lib_to_chars 202306L | 558 | // # define __cpp_lib_to_chars 202306L |
| 559 | // # define __cpp_lib_to_string 202306L | ||
| 522 | # undef __cpp_lib_tuple_like | 560 | # undef __cpp_lib_tuple_like |
| 523 | // # define __cpp_lib_tuple_like 202311L | 561 | // # define __cpp_lib_tuple_like 202311L |
| 524 | // # define __cpp_lib_within_lifetime 202306L | ||
| 525 | #endif | 562 | #endif |
| 526 | 563 | ||
| 527 | // clang-format on | 564 | // clang-format on |
lib/libcxx/src/atomic.cpp+16-11| ... | @@ -69,17 +69,20 @@ extern "C" int __ulock_wait( | ... | @@ -69,17 +69,20 @@ extern "C" int __ulock_wait( |
| 69 | uint32_t operation, void* addr, uint64_t value, uint32_t timeout); /* timeout is specified in microseconds */ | 69 | uint32_t operation, void* addr, uint64_t value, uint32_t timeout); /* timeout is specified in microseconds */ |
| 70 | extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value); | 70 | extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value); |
| 71 | 71 | ||
| 72 | # define UL_COMPARE_AND_WAIT 1 | 72 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ulock.h#L82 |
| 73 | # define UL_COMPARE_AND_WAIT64 5 | ||
| 73 | # define ULF_WAKE_ALL 0x00000100 | 74 | # define ULF_WAKE_ALL 0x00000100 |
| 74 | 75 | ||
| 75 | static void | 76 | static void |
| 76 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { | 77 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { |
| 77 | __ulock_wait(UL_COMPARE_AND_WAIT, const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0); | 78 | static_assert(sizeof(__cxx_atomic_contention_t) == 8, "Waiting on 8 bytes value"); |
| 79 | __ulock_wait(UL_COMPARE_AND_WAIT64, const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0); | ||
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { | 82 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { |
| 83 | static_assert(sizeof(__cxx_atomic_contention_t) == 8, "Waking up on 8 bytes value"); | ||
| 81 | __ulock_wake( | 84 | __ulock_wake( |
| 82 | UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<__cxx_atomic_contention_t*>(__ptr), 0); | 85 | UL_COMPARE_AND_WAIT64 | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<__cxx_atomic_contention_t*>(__ptr), 0); |
| 83 | } | 86 | } |
| 84 | 87 | ||
| 85 | #elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8 | 88 | #elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8 |
| ... | @@ -166,17 +169,18 @@ static void __libcpp_atomic_notify(void const volatile* __location) { | ... | @@ -166,17 +169,18 @@ static void __libcpp_atomic_notify(void const volatile* __location) { |
| 166 | &__entry->__platform_state, | 169 | &__entry->__platform_state, |
| 167 | false /* when laundering, we can't handle notify_one */); | 170 | false /* when laundering, we can't handle notify_one */); |
| 168 | } | 171 | } |
| 169 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) { | 172 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) noexcept { |
| 170 | __libcpp_atomic_notify(__location); | 173 | __libcpp_atomic_notify(__location); |
| 171 | } | 174 | } |
| 172 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) { | 175 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) noexcept { |
| 173 | __libcpp_atomic_notify(__location); | 176 | __libcpp_atomic_notify(__location); |
| 174 | } | 177 | } |
| 175 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) { | 178 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) noexcept { |
| 176 | auto const __entry = __libcpp_contention_state(__location); | 179 | auto const __entry = __libcpp_contention_state(__location); |
| 177 | return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state); | 180 | return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state); |
| 178 | } | 181 | } |
| 179 | _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) { | 182 | _LIBCPP_EXPORTED_FROM_ABI void |
| 183 | __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) noexcept { | ||
| 180 | auto const __entry = __libcpp_contention_state(__location); | 184 | auto const __entry = __libcpp_contention_state(__location); |
| 181 | __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value); | 185 | __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value); |
| 182 | } | 186 | } |
| ... | @@ -184,18 +188,19 @@ _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __locat | ... | @@ -184,18 +188,19 @@ _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __locat |
| 184 | /* When the incoming atomic happens to be the platform wait size, we still need to use the | 188 | /* When the incoming atomic happens to be the platform wait size, we still need to use the |
| 185 | table for the contention detection, but we can use the atomic directly for the wait. */ | 189 | table for the contention detection, but we can use the atomic directly for the wait. */ |
| 186 | 190 | ||
| 187 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) { | 191 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) noexcept { |
| 188 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true); | 192 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true); |
| 189 | } | 193 | } |
| 190 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) { | 194 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) noexcept { |
| 191 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false); | 195 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false); |
| 192 | } | 196 | } |
| 197 | // This function is never used, but still exported for ABI compatibility. | ||
| 193 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | 198 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t |
| 194 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) { | 199 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) noexcept { |
| 195 | return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location); | 200 | return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location); |
| 196 | } | 201 | } |
| 197 | _LIBCPP_EXPORTED_FROM_ABI void | 202 | _LIBCPP_EXPORTED_FROM_ABI void |
| 198 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) { | 203 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) noexcept { |
| 199 | __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value); | 204 | __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value); |
| 200 | } | 205 | } |
| 201 | 206 |
lib/libcxx/src/barrier.cpp+11-11| ... | @@ -21,17 +21,17 @@ public: | ... | @@ -21,17 +21,17 @@ public: |
| 21 | } __tickets[64]; | 21 | } __tickets[64]; |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | ptrdiff_t& __expected; | 24 | ptrdiff_t& __expected_; |
| 25 | unique_ptr<__state_t[]> __state; | 25 | unique_ptr<__state_t[]> __state_; |
| 26 | 26 | ||
| 27 | _LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected(__expected) { | 27 | _LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected_(__expected) { |
| 28 | size_t const __count = (__expected + 1) >> 1; | 28 | size_t const __count = (__expected + 1) >> 1; |
| 29 | __state = unique_ptr<__state_t[]>(new __state_t[__count]); | 29 | __state_ = unique_ptr<__state_t[]>(new __state_t[__count]); |
| 30 | } | 30 | } |
| 31 | _LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) { | 31 | _LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) { |
| 32 | __barrier_phase_t const __half_step = __old_phase + 1, __full_step = __old_phase + 2; | 32 | __barrier_phase_t const __half_step = __old_phase + 1, __full_step = __old_phase + 2; |
| 33 | size_t __current_expected = __expected, | 33 | size_t __current_expected = __expected_, |
| 34 | __current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1); | 34 | __current = hash<thread::id>()(this_thread::get_id()) % ((__expected_ + 1) >> 1); |
| 35 | for (int __round = 0;; ++__round) { | 35 | for (int __round = 0;; ++__round) { |
| 36 | if (__current_expected <= 1) | 36 | if (__current_expected <= 1) |
| 37 | return true; | 37 | return true; |
| ... | @@ -41,14 +41,14 @@ public: | ... | @@ -41,14 +41,14 @@ public: |
| 41 | __current = 0; | 41 | __current = 0; |
| 42 | __barrier_phase_t expect = __old_phase; | 42 | __barrier_phase_t expect = __old_phase; |
| 43 | if (__current == __last_node && (__current_expected & 1)) { | 43 | if (__current == __last_node && (__current_expected & 1)) { |
| 44 | if (__state[__current].__tickets[__round].__phase.compare_exchange_strong( | 44 | if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong( |
| 45 | expect, __full_step, memory_order_acq_rel)) | 45 | expect, __full_step, memory_order_acq_rel)) |
| 46 | break; // I'm 1 in 1, go to next __round | 46 | break; // I'm 1 in 1, go to next __round |
| 47 | } else if (__state[__current].__tickets[__round].__phase.compare_exchange_strong( | 47 | } else if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong( |
| 48 | expect, __half_step, memory_order_acq_rel)) { | 48 | expect, __half_step, memory_order_acq_rel)) { |
| 49 | return false; // I'm 1 in 2, done with arrival | 49 | return false; // I'm 1 in 2, done with arrival |
| 50 | } else if (expect == __half_step) { | 50 | } else if (expect == __half_step) { |
| 51 | if (__state[__current].__tickets[__round].__phase.compare_exchange_strong( | 51 | if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong( |
| 52 | expect, __full_step, memory_order_acq_rel)) | 52 | expect, __full_step, memory_order_acq_rel)) |
| 53 | break; // I'm 2 in 2, go to next __round | 53 | break; // I'm 2 in 2, go to next __round |
| 54 | } | 54 | } |
| ... | @@ -63,10 +63,10 @@ _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorith | ... | @@ -63,10 +63,10 @@ _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorith |
| 63 | return new __barrier_algorithm_base(__expected); | 63 | return new __barrier_algorithm_base(__expected); |
| 64 | } | 64 | } |
| 65 | _LIBCPP_EXPORTED_FROM_ABI bool | 65 | _LIBCPP_EXPORTED_FROM_ABI bool |
| 66 | __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) { | 66 | __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept { |
| 67 | return __barrier->__arrive(__old_phase); | 67 | return __barrier->__arrive(__old_phase); |
| 68 | } | 68 | } |
| 69 | _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) { | 69 | _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept { |
| 70 | delete __barrier; | 70 | delete __barrier; |
| 71 | } | 71 | } |
| 72 | 72 |
lib/libcxx/src/call_once.cpp+1-1| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | #include <__utility/exception_guard.h> | 10 | #include <__utility/exception_guard.h> |
| 11 | 11 | ||
| 12 | #ifndef _LIBCPP_HAS_NO_THREADS | 12 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 13 | # include <__threading_support> | 13 | # include <__thread/support.h> |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | #include "include/atomic_support.h" | 16 | #include "include/atomic_support.h" |
lib/libcxx/src/chrono.cpp+2-2| ... | @@ -77,8 +77,8 @@ typedef void(WINAPI* GetSystemTimeAsFileTimePtr)(LPFILETIME); | ... | @@ -77,8 +77,8 @@ typedef void(WINAPI* GetSystemTimeAsFileTimePtr)(LPFILETIME); |
| 77 | class GetSystemTimeInit { | 77 | class GetSystemTimeInit { |
| 78 | public: | 78 | public: |
| 79 | GetSystemTimeInit() { | 79 | GetSystemTimeInit() { |
| 80 | fp = | 80 | fp = (GetSystemTimeAsFileTimePtr)(void*)GetProcAddress( |
| 81 | (GetSystemTimeAsFileTimePtr)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime"); | 81 | GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime"); |
| 82 | if (fp == nullptr) | 82 | if (fp == nullptr) |
| 83 | fp = GetSystemTimeAsFileTime; | 83 | fp = GetSystemTimeAsFileTime; |
| 84 | } | 84 | } |
lib/libcxx/src/condition_variable_destructor.cpp+1-1| ... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
| 12 | // definition is only provided for ABI compatibility. | 12 | // definition is only provided for ABI compatibility. |
| 13 | 13 | ||
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__threading_support> | 15 | #include <__thread/support.h> |
| 16 | 16 | ||
| 17 | #if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION) | 17 | #if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION) |
| 18 | # define NEEDS_CONDVAR_DESTRUCTOR | 18 | # define NEEDS_CONDVAR_DESTRUCTOR |
lib/libcxx/src/expected.cpp created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #include <expected> | ||
| 10 | |||
| 11 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 12 | const char* bad_expected_access<void>::what() const noexcept { return "bad access to std::expected"; } | ||
| 13 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/experimental/chrono_exception.cpp created+22| ... | @@ -0,0 +1,22 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #include <chrono> | ||
| 10 | |||
| 11 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 12 | |||
| 13 | namespace chrono { | ||
| 14 | |||
| 15 | _LIBCPP_AVAILABILITY_TZDB | ||
| 16 | _LIBCPP_EXPORTED_FROM_ABI nonexistent_local_time::~nonexistent_local_time() = default; // key function | ||
| 17 | _LIBCPP_AVAILABILITY_TZDB | ||
| 18 | _LIBCPP_EXPORTED_FROM_ABI ambiguous_local_time::~ambiguous_local_time() = default; // key function | ||
| 19 | |||
| 20 | } // namespace chrono | ||
| 21 | |||
| 22 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/experimental/include/tzdb/time_zone_private.h created+57| ... | @@ -0,0 +1,57 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H | ||
| 13 | #define _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H | ||
| 14 | |||
| 15 | #include <chrono> | ||
| 16 | #include <string> | ||
| 17 | #include <vector> | ||
| 18 | |||
| 19 | #include "types_private.h" | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | namespace chrono { | ||
| 24 | |||
| 25 | class time_zone::__impl { | ||
| 26 | public: | ||
| 27 | explicit _LIBCPP_HIDE_FROM_ABI __impl(string&& __name, const __tz::__rules_storage_type& __rules_db) | ||
| 28 | : __name_(std::move(__name)), __rules_db_(__rules_db) {} | ||
| 29 | |||
| 30 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view __name() const noexcept { return __name_; } | ||
| 31 | |||
| 32 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI vector<__tz::__continuation>& __continuations() { return __continuations_; } | ||
| 33 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const vector<__tz::__continuation>& __continuations() const { | ||
| 34 | return __continuations_; | ||
| 35 | } | ||
| 36 | |||
| 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __tz::__rules_storage_type& __rules_db() const { return __rules_db_; } | ||
| 38 | |||
| 39 | private: | ||
| 40 | string __name_; | ||
| 41 | // Note the first line has a name + __continuation, the other lines | ||
| 42 | // are just __continuations. So there is always at least one item in | ||
| 43 | // the vector. | ||
| 44 | vector<__tz::__continuation> __continuations_; | ||
| 45 | |||
| 46 | // Continuations often depend on a set of rules. The rules are stored in | ||
| 47 | // parallel data structurs in tzdb_list. From the time_zone it's not possible | ||
| 48 | // to find its associated tzdb entry and thus not possible to find its | ||
| 49 | // associated rules. Therefore a link to the rules in stored in this class. | ||
| 50 | const __tz::__rules_storage_type& __rules_db_; | ||
| 51 | }; | ||
| 52 | |||
| 53 | } // namespace chrono | ||
| 54 | |||
| 55 | _LIBCPP_END_NAMESPACE_STD | ||
| 56 | |||
| 57 | #endif // _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H | ||
lib/libcxx/src/experimental/include/tzdb/types_private.h created+117| ... | @@ -0,0 +1,117 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 11 | |||
| 12 | #ifndef __LIBCPP_SRC_INCLUDE_TZDB_TYPES_PRIVATE_H | ||
| 13 | #define __LIBCPP_SRC_INCLUDE_TZDB_TYPES_PRIVATE_H | ||
| 14 | |||
| 15 | #include <chrono> | ||
| 16 | #include <string> | ||
| 17 | #include <utility> | ||
| 18 | #include <variant> | ||
| 19 | #include <vector> | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | // TODO TZDB | ||
| 24 | // The helper classes in this header have no constructor but are loaded with | ||
| 25 | // dedicated parse functions. In the original design this header was public and | ||
| 26 | // the parsing was done in the dylib. In that design having constructors would | ||
| 27 | // expand the ABI interface. Since this header is now in the dylib that design | ||
| 28 | // should be reconsidered. (For now the design is kept as is, in case this | ||
| 29 | // header needs to be public for unforseen reasons.) | ||
| 30 | |||
| 31 | namespace chrono::__tz { | ||
| 32 | |||
| 33 | // Sun>=8 first Sunday on or after the eighth | ||
| 34 | // Sun<=25 last Sunday on or before the 25th | ||
| 35 | struct __constrained_weekday { | ||
| 36 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI year_month_day operator()(year __year, month __month) const { | ||
| 37 | auto __result = static_cast<sys_days>(year_month_day{__year, __month, __day}); | ||
| 38 | weekday __wd{static_cast<sys_days>(__result)}; | ||
| 39 | |||
| 40 | if (__comparison == __le) | ||
| 41 | __result -= __wd - __weekday; | ||
| 42 | else | ||
| 43 | __result += __weekday - __wd; | ||
| 44 | |||
| 45 | return __result; | ||
| 46 | } | ||
| 47 | |||
| 48 | weekday __weekday; | ||
| 49 | enum __comparison_t { __le, __ge } __comparison; | ||
| 50 | day __day; | ||
| 51 | }; | ||
| 52 | |||
| 53 | // The on field has a few alternative presentations | ||
| 54 | // 5 the fifth of the month | ||
| 55 | // lastSun the last Sunday in the month | ||
| 56 | // lastMon the last Monday in the month | ||
| 57 | // Sun>=8 first Sunday on or after the eighth | ||
| 58 | // Sun<=25 last Sunday on or before the 25th | ||
| 59 | using __on = variant<day, weekday_last, __constrained_weekday>; | ||
| 60 | |||
| 61 | enum class __clock { __local, __standard, __universal }; | ||
| 62 | |||
| 63 | struct __at { | ||
| 64 | seconds __time{0}; | ||
| 65 | __tz::__clock __clock{__tz::__clock::__local}; | ||
| 66 | }; | ||
| 67 | |||
| 68 | struct __save { | ||
| 69 | seconds __time; | ||
| 70 | bool __is_dst; | ||
| 71 | }; | ||
| 72 | |||
| 73 | // The names of the fields match the fields of a Rule. | ||
| 74 | struct __rule { | ||
| 75 | year __from; | ||
| 76 | year __to; | ||
| 77 | month __in; | ||
| 78 | __tz::__on __on; | ||
| 79 | __tz::__at __at; | ||
| 80 | __tz::__save __save; | ||
| 81 | string __letters; | ||
| 82 | }; | ||
| 83 | |||
| 84 | using __rules_storage_type = std::vector<std::pair<string, vector<__tz::__rule>>>; // TODO TZDB use flat_map; | ||
| 85 | |||
| 86 | struct __continuation { | ||
| 87 | // Non-owning link to the RULE entries. | ||
| 88 | __tz::__rules_storage_type* __rule_database_; | ||
| 89 | |||
| 90 | seconds __stdoff; | ||
| 91 | |||
| 92 | // The RULES is either a SAVE or a NAME. | ||
| 93 | // The size_t is used as cache. After loading the rules they are | ||
| 94 | // sorted and remain stable, then an index in the vector can be | ||
| 95 | // used. | ||
| 96 | // If this field contains - then standard time always | ||
| 97 | // applies. This is indicated by the monostate. | ||
| 98 | // TODO TZDB Investigate implantation the size_t based caching. | ||
| 99 | using __rules_t = variant<monostate, __tz::__save, string /*, size_t*/>; | ||
| 100 | |||
| 101 | __rules_t __rules; | ||
| 102 | |||
| 103 | string __format; | ||
| 104 | // TODO TZDB the until field can contain more than just a year. | ||
| 105 | // Parts of the UNTIL, the optional parts are default initialized | ||
| 106 | // optional<year> __until_; | ||
| 107 | year __year = chrono::year::min(); | ||
| 108 | month __in{January}; | ||
| 109 | __tz::__on __on{chrono::day{1}}; | ||
| 110 | __tz::__at __at{chrono::seconds{0}, __tz::__clock::__local}; | ||
| 111 | }; | ||
| 112 | |||
| 113 | } // namespace chrono::__tz | ||
| 114 | |||
| 115 | _LIBCPP_END_NAMESPACE_STD | ||
| 116 | |||
| 117 | #endif // __LIBCPP_SRC_INCLUDE_TZDB_TYPES_PRIVATE_H | ||
lib/libcxx/src/experimental/include/tzdb/tzdb_list_private.h created+104| ... | @@ -0,0 +1,104 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | #ifndef _LIBCPP_SRC_INCLUDE_TZDB_TZDB_LIST_PRIVATE_H | ||
| 12 | #define _LIBCPP_SRC_INCLUDE_TZDB_TZDB_LIST_PRIVATE_H | ||
| 13 | |||
| 14 | #include <__mutex/unique_lock.h> | ||
| 15 | #include <forward_list> | ||
| 16 | |||
| 17 | // When threads are not available the locking is not required. | ||
| 18 | // When threads are available, we use std::mutex over std::shared_mutex | ||
| 19 | // due to the increased overhead of std::shared_mutex. | ||
| 20 | // See shared_mutex_vs_mutex.bench.cpp | ||
| 21 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 22 | # include <mutex> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #include "types_private.h" | ||
| 26 | #include "tzdb_private.h" | ||
| 27 | |||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 29 | |||
| 30 | namespace chrono { | ||
| 31 | |||
| 32 | //===----------------------------------------------------------------------===// | ||
| 33 | // Private API | ||
| 34 | //===----------------------------------------------------------------------===// | ||
| 35 | |||
| 36 | // The tzdb_list stores a list of "tzdb" entries. | ||
| 37 | // | ||
| 38 | // The public tzdb database does not store the RULE entries of the IANA | ||
| 39 | // database. These entries are considered an implementation detail. Since most | ||
| 40 | // of the tzdb_list interface is exposed as "a list of tzdb entries" it's not | ||
| 41 | // possible to use a helper struct that stores a tzdb and the RULE database. | ||
| 42 | // Instead this class stores these in parallel forward lists. | ||
| 43 | // | ||
| 44 | // Since the nodes of a forward_list are stable it's possible to store pointers | ||
| 45 | // and references to these nodes. | ||
| 46 | class tzdb_list::__impl { | ||
| 47 | public: | ||
| 48 | __impl() { __load_no_lock(); } | ||
| 49 | |||
| 50 | [[nodiscard]] const tzdb& __load() { | ||
| 51 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 52 | unique_lock __lock{__mutex_}; | ||
| 53 | #endif | ||
| 54 | __load_no_lock(); | ||
| 55 | return __tzdb_.front(); | ||
| 56 | } | ||
| 57 | |||
| 58 | using const_iterator = tzdb_list::const_iterator; | ||
| 59 | |||
| 60 | const tzdb& __front() const noexcept { | ||
| 61 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 62 | unique_lock __lock{__mutex_}; | ||
| 63 | #endif | ||
| 64 | return __tzdb_.front(); | ||
| 65 | } | ||
| 66 | |||
| 67 | const_iterator __erase_after(const_iterator __p) { | ||
| 68 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 69 | unique_lock __lock{__mutex_}; | ||
| 70 | #endif | ||
| 71 | |||
| 72 | __rules_.erase_after(std::next(__rules_.cbegin(), std::distance(__tzdb_.cbegin(), __p))); | ||
| 73 | return __tzdb_.erase_after(__p); | ||
| 74 | } | ||
| 75 | |||
| 76 | const_iterator __begin() const noexcept { | ||
| 77 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 78 | unique_lock __lock{__mutex_}; | ||
| 79 | #endif | ||
| 80 | return __tzdb_.begin(); | ||
| 81 | } | ||
| 82 | const_iterator __end() const noexcept { | ||
| 83 | // forward_list<T>::end does not access the list, so no need to take a lock. | ||
| 84 | return __tzdb_.end(); | ||
| 85 | } | ||
| 86 | |||
| 87 | private: | ||
| 88 | // Loads the tzdbs | ||
| 89 | // pre: The caller ensures the locking, if needed, is done. | ||
| 90 | void __load_no_lock() { chrono::__init_tzdb(__tzdb_.emplace_front(), __rules_.emplace_front()); } | ||
| 91 | |||
| 92 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 93 | mutable mutex __mutex_; | ||
| 94 | #endif | ||
| 95 | forward_list<tzdb> __tzdb_; | ||
| 96 | |||
| 97 | forward_list<__tz::__rules_storage_type> __rules_; | ||
| 98 | }; | ||
| 99 | |||
| 100 | } // namespace chrono | ||
| 101 | |||
| 102 | _LIBCPP_END_NAMESPACE_STD | ||
| 103 | |||
| 104 | #endif // _LIBCPP_SRC_INCLUDE_TZDB_TZDB_LIST_PRIVATE_H | ||
lib/libcxx/src/experimental/include/tzdb/tzdb_private.h created+28| ... | @@ -0,0 +1,28 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | #ifndef _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H | ||
| 12 | #define _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H | ||
| 13 | |||
| 14 | #include <chrono> | ||
| 15 | |||
| 16 | #include "types_private.h" | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | namespace chrono { | ||
| 21 | |||
| 22 | void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules); | ||
| 23 | |||
| 24 | } // namespace chrono | ||
| 25 | |||
| 26 | _LIBCPP_END_NAMESPACE_STD | ||
| 27 | |||
| 28 | #endif // _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H | ||
lib/libcxx/src/experimental/time_zone.cpp created+1055| ... | @@ -0,0 +1,1055 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | // TODO TZDB look at optimizations | ||
| 12 | // | ||
| 13 | // The current algorithm is correct but not efficient. For example, in a named | ||
| 14 | // rule based continuation finding the next rule does quite a bit of work, | ||
| 15 | // returns the next rule and "forgets" its state. This could be better. | ||
| 16 | // | ||
| 17 | // It would be possible to cache lookups. If a time for a zone is calculated its | ||
| 18 | // sys_info could be kept and the next lookup could test whether the time is in | ||
| 19 | // a "known" sys_info. The wording in the Standard hints at this slowness by | ||
| 20 | // "suggesting" this could be implemented on the user's side. | ||
| 21 | |||
| 22 | // TODO TZDB look at removing quirks | ||
| 23 | // | ||
| 24 | // The code has some special rules to adjust the timing at the continuation | ||
| 25 | // switches. This works correctly, but some of the places feel odd. It would be | ||
| 26 | // good to investigate this further and see whether all quirks are needed or | ||
| 27 | // that there are better fixes. | ||
| 28 | // | ||
| 29 | // These quirks often use a 12h interval; this is the scan interval of zdump, | ||
| 30 | // which implies there are no sys_info objects with a duration of less than 12h. | ||
| 31 | |||
| 32 | #include <algorithm> | ||
| 33 | #include <cctype> | ||
| 34 | #include <chrono> | ||
| 35 | #include <expected> | ||
| 36 | #include <map> | ||
| 37 | #include <numeric> | ||
| 38 | #include <ranges> | ||
| 39 | |||
| 40 | #include "include/tzdb/time_zone_private.h" | ||
| 41 | #include "include/tzdb/tzdb_list_private.h" | ||
| 42 | |||
| 43 | // TODO TZDB remove debug printing | ||
| 44 | #ifdef PRINT | ||
| 45 | # include <print> | ||
| 46 | #endif | ||
| 47 | |||
| 48 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 49 | |||
| 50 | #ifdef PRINT | ||
| 51 | template <> | ||
| 52 | struct formatter<chrono::sys_info, char> { | ||
| 53 | template <class ParseContext> | ||
| 54 | constexpr typename ParseContext::iterator parse(ParseContext& ctx) { | ||
| 55 | return ctx.begin(); | ||
| 56 | } | ||
| 57 | |||
| 58 | template <class FormatContext> | ||
| 59 | typename FormatContext::iterator format(const chrono::sys_info& info, FormatContext& ctx) const { | ||
| 60 | return std::format_to( | ||
| 61 | ctx.out(), "[{}, {}) {:%Q%q} {:%Q%q} {}", info.begin, info.end, info.offset, info.save, info.abbrev); | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | #endif | ||
| 65 | |||
| 66 | namespace chrono { | ||
| 67 | |||
| 68 | //===----------------------------------------------------------------------===// | ||
| 69 | // Details | ||
| 70 | //===----------------------------------------------------------------------===// | ||
| 71 | |||
| 72 | struct __sys_info { | ||
| 73 | sys_info __info; | ||
| 74 | bool __can_merge; // Can the returned sys_info object be merged with | ||
| 75 | }; | ||
| 76 | |||
| 77 | // Return type for helper function to get a sys_info. | ||
| 78 | // - The expected result returns the "best" sys_info object. This object can be | ||
| 79 | // before the requested time. Sometimes sys_info objects from different | ||
| 80 | // continuations share their offset, save, and abbrev and these objects are | ||
| 81 | // merged to one sys_info object. The __can_merge flag determines whether the | ||
| 82 | // current result can be merged with the next result. | ||
| 83 | // - The unexpected result means no sys_info object was found and the time is | ||
| 84 | // the time to be used for the next search iteration. | ||
| 85 | using __sys_info_result = expected<__sys_info, sys_seconds>; | ||
| 86 | |||
| 87 | template <ranges::forward_range _Range, | ||
| 88 | class _Type, | ||
| 89 | class _Proj = identity, | ||
| 90 | indirect_strict_weak_order<const _Type*, projected<ranges::iterator_t<_Range>, _Proj>> _Comp = ranges::less> | ||
| 91 | [[nodiscard]] static ranges::borrowed_iterator_t<_Range> | ||
| 92 | __binary_find(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) { | ||
| 93 | auto __end = ranges::end(__r); | ||
| 94 | auto __ret = ranges::lower_bound(ranges::begin(__r), __end, __value, __comp, __proj); | ||
| 95 | if (__ret == __end) | ||
| 96 | return __end; | ||
| 97 | |||
| 98 | // When the value does not match the predicate it's equal and a valid result | ||
| 99 | // was found. | ||
| 100 | return !std::invoke(__comp, __value, std::invoke(__proj, *__ret)) ? __ret : __end; | ||
| 101 | } | ||
| 102 | |||
| 103 | // Format based on https://data.iana.org/time-zones/tz-how-to.html | ||
| 104 | // | ||
| 105 | // 1 a time zone abbreviation that is a string of three or more characters that | ||
| 106 | // are either ASCII alphanumerics, "+", or "-" | ||
| 107 | // 2 the string "%z", in which case the "%z" will be replaced by a numeric time | ||
| 108 | // zone abbreviation | ||
| 109 | // 3 a pair of time zone abbreviations separated by a slash ('/'), in which | ||
| 110 | // case the first string is the abbreviation for the standard time name and | ||
| 111 | // the second string is the abbreviation for the daylight saving time name | ||
| 112 | // 4 a string containing "%s", in which case the "%s" will be replaced by the | ||
| 113 | // text in the appropriate Rule's LETTER column, and the resulting string | ||
| 114 | // should be a time zone abbreviation | ||
| 115 | // | ||
| 116 | // Rule 1 is not strictly validated since America/Barbados uses a two letter | ||
| 117 | // abbreviation AT. | ||
| 118 | [[nodiscard]] static string | ||
| 119 | __format(const __tz::__continuation& __continuation, const string& __letters, seconds __save) { | ||
| 120 | bool __shift = false; | ||
| 121 | string __result; | ||
| 122 | for (char __c : __continuation.__format) { | ||
| 123 | if (__shift) { | ||
| 124 | switch (__c) { | ||
| 125 | case 's': | ||
| 126 | std::ranges::copy(__letters, std::back_inserter(__result)); | ||
| 127 | break; | ||
| 128 | |||
| 129 | case 'z': { | ||
| 130 | if (__continuation.__format.size() != 2) | ||
| 131 | std::__throw_runtime_error( | ||
| 132 | std::format("corrupt tzdb FORMAT field: %z should be the entire contents, instead contains '{}'", | ||
| 133 | __continuation.__format) | ||
| 134 | .c_str()); | ||
| 135 | chrono::hh_mm_ss __offset{__continuation.__stdoff + __save}; | ||
| 136 | if (__offset.is_negative()) { | ||
| 137 | __result += '-'; | ||
| 138 | __offset = chrono::hh_mm_ss{-(__continuation.__stdoff + __save)}; | ||
| 139 | } else | ||
| 140 | __result += '+'; | ||
| 141 | |||
| 142 | if (__offset.minutes() != 0min) | ||
| 143 | std::format_to(std::back_inserter(__result), "{:%H%M}", __offset); | ||
| 144 | else | ||
| 145 | std::format_to(std::back_inserter(__result), "{:%H}", __offset); | ||
| 146 | } break; | ||
| 147 | |||
| 148 | default: | ||
| 149 | std::__throw_runtime_error( | ||
| 150 | std::format("corrupt tzdb FORMAT field: invalid sequence '%{}' found, expected %s or %z", __c).c_str()); | ||
| 151 | } | ||
| 152 | __shift = false; | ||
| 153 | |||
| 154 | } else if (__c == '/') { | ||
| 155 | if (__save != 0s) | ||
| 156 | __result.clear(); | ||
| 157 | else | ||
| 158 | break; | ||
| 159 | |||
| 160 | } else if (__c == '%') { | ||
| 161 | __shift = true; | ||
| 162 | } else if (__c == '+' || __c == '-' || std::isalnum(__c)) { | ||
| 163 | __result.push_back(__c); | ||
| 164 | } else { | ||
| 165 | std::__throw_runtime_error( | ||
| 166 | std::format( | ||
| 167 | "corrupt tzdb FORMAT field: invalid character '{}' found, expected +, -, or an alphanumeric value", __c) | ||
| 168 | .c_str()); | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | if (__shift) | ||
| 173 | std::__throw_runtime_error("corrupt tzdb FORMAT field: input ended with the start of the escape sequence '%'"); | ||
| 174 | |||
| 175 | if (__result.empty()) | ||
| 176 | std::__throw_runtime_error("corrupt tzdb FORMAT field: result is empty"); | ||
| 177 | |||
| 178 | return __result; | ||
| 179 | } | ||
| 180 | |||
| 181 | [[nodiscard]] static sys_seconds __to_sys_seconds(year_month_day __ymd, seconds __seconds) { | ||
| 182 | seconds __result = static_cast<sys_days>(__ymd).time_since_epoch() + __seconds; | ||
| 183 | return sys_seconds{__result}; | ||
| 184 | } | ||
| 185 | |||
| 186 | [[nodiscard]] static seconds __at_to_sys_seconds(const __tz::__continuation& __continuation) { | ||
| 187 | switch (__continuation.__at.__clock) { | ||
| 188 | case __tz::__clock::__local: | ||
| 189 | return __continuation.__at.__time - __continuation.__stdoff - | ||
| 190 | std::visit( | ||
| 191 | [](const auto& __value) { | ||
| 192 | using _Tp = decay_t<decltype(__value)>; | ||
| 193 | if constexpr (same_as<_Tp, monostate>) | ||
| 194 | return chrono::seconds{0}; | ||
| 195 | else if constexpr (same_as<_Tp, __tz::__save>) | ||
| 196 | return chrono::duration_cast<seconds>(__value.__time); | ||
| 197 | else if constexpr (same_as<_Tp, std::string>) | ||
| 198 | // For a named rule based continuation the SAVE depends on the RULE | ||
| 199 | // active at the end. This should be determined separately. | ||
| 200 | return chrono::seconds{0}; | ||
| 201 | else | ||
| 202 | static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support | ||
| 203 | |||
| 204 | std::__libcpp_unreachable(); | ||
| 205 | }, | ||
| 206 | __continuation.__rules); | ||
| 207 | |||
| 208 | case __tz::__clock::__universal: | ||
| 209 | return __continuation.__at.__time; | ||
| 210 | |||
| 211 | case __tz::__clock::__standard: | ||
| 212 | return __continuation.__at.__time - __continuation.__stdoff; | ||
| 213 | } | ||
| 214 | std::__libcpp_unreachable(); | ||
| 215 | } | ||
| 216 | |||
| 217 | [[nodiscard]] static year_month_day __to_year_month_day(year __year, month __month, __tz::__on __on) { | ||
| 218 | return std::visit( | ||
| 219 | [&](const auto& __value) { | ||
| 220 | using _Tp = decay_t<decltype(__value)>; | ||
| 221 | if constexpr (same_as<_Tp, chrono::day>) | ||
| 222 | return year_month_day{__year, __month, __value}; | ||
| 223 | else if constexpr (same_as<_Tp, weekday_last>) | ||
| 224 | return year_month_day{static_cast<sys_days>(year_month_weekday_last{__year, __month, __value})}; | ||
| 225 | else if constexpr (same_as<_Tp, __tz::__constrained_weekday>) | ||
| 226 | return __value(__year, __month); | ||
| 227 | else | ||
| 228 | static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support | ||
| 229 | |||
| 230 | std::__libcpp_unreachable(); | ||
| 231 | }, | ||
| 232 | __on); | ||
| 233 | } | ||
| 234 | |||
| 235 | [[nodiscard]] static sys_seconds __until_to_sys_seconds(const __tz::__continuation& __continuation) { | ||
| 236 | // Does UNTIL contain the magic value for the last continuation? | ||
| 237 | if (__continuation.__year == chrono::year::min()) | ||
| 238 | return sys_seconds::max(); | ||
| 239 | |||
| 240 | year_month_day __ymd = chrono::__to_year_month_day(__continuation.__year, __continuation.__in, __continuation.__on); | ||
| 241 | return chrono::__to_sys_seconds(__ymd, chrono::__at_to_sys_seconds(__continuation)); | ||
| 242 | } | ||
| 243 | |||
| 244 | // Holds the UNTIL time for a continuation with a named rule. | ||
| 245 | // | ||
| 246 | // Unlike continuations with an fixed SAVE named rules have a variable SAVE. | ||
| 247 | // This means when the UNTIL uses the local wall time the actual UNTIL value can | ||
| 248 | // only be determined when the SAVE is known. This class holds that abstraction. | ||
| 249 | class __named_rule_until { | ||
| 250 | public: | ||
| 251 | explicit __named_rule_until(const __tz::__continuation& __continuation) | ||
| 252 | : __until_{chrono::__until_to_sys_seconds(__continuation)}, | ||
| 253 | __needs_adjustment_{ | ||
| 254 | // The last continuation of a ZONE has no UNTIL which basically is | ||
| 255 | // until the end of _local_ time. This value is expressed by | ||
| 256 | // sys_seconds::max(). Subtracting the SAVE leaves large value. | ||
| 257 | // However SAVE can be negative, which would add a value to maximum | ||
| 258 | // leading to undefined behaviour. In practice this often results in | ||
| 259 | // an overflow to a very small value. | ||
| 260 | __until_ != sys_seconds::max() && __continuation.__at.__clock == __tz::__clock::__local} {} | ||
| 261 | |||
| 262 | // Gives the unadjusted until value, this is useful when the SAVE is not known | ||
| 263 | // at all. | ||
| 264 | sys_seconds __until() const noexcept { return __until_; } | ||
| 265 | |||
| 266 | bool __needs_adjustment() const noexcept { return __needs_adjustment_; } | ||
| 267 | |||
| 268 | // Returns the UNTIL adjusted for SAVE. | ||
| 269 | sys_seconds operator()(seconds __save) const noexcept { return __until_ - __needs_adjustment_ * __save; } | ||
| 270 | |||
| 271 | private: | ||
| 272 | sys_seconds __until_; | ||
| 273 | bool __needs_adjustment_; | ||
| 274 | }; | ||
| 275 | |||
| 276 | [[nodiscard]] static seconds __at_to_seconds(seconds __stdoff, const __tz::__rule& __rule) { | ||
| 277 | switch (__rule.__at.__clock) { | ||
| 278 | case __tz::__clock::__local: | ||
| 279 | // Local time and standard time behave the same. This is not | ||
| 280 | // correct. Local time needs to adjust for the current saved time. | ||
| 281 | // To know the saved time the rules need to be known and sorted. | ||
| 282 | // This needs a time so to avoid the chicken and egg adjust the | ||
| 283 | // saving of the local time later. | ||
| 284 | return __rule.__at.__time - __stdoff; | ||
| 285 | |||
| 286 | case __tz::__clock::__universal: | ||
| 287 | return __rule.__at.__time; | ||
| 288 | |||
| 289 | case __tz::__clock::__standard: | ||
| 290 | return __rule.__at.__time - __stdoff; | ||
| 291 | } | ||
| 292 | std::__libcpp_unreachable(); | ||
| 293 | } | ||
| 294 | |||
| 295 | [[nodiscard]] static sys_seconds __from_to_sys_seconds(seconds __stdoff, const __tz::__rule& __rule, year __year) { | ||
| 296 | year_month_day __ymd = chrono::__to_year_month_day(__year, __rule.__in, __rule.__on); | ||
| 297 | |||
| 298 | seconds __at = chrono::__at_to_seconds(__stdoff, __rule); | ||
| 299 | return chrono::__to_sys_seconds(__ymd, __at); | ||
| 300 | } | ||
| 301 | |||
| 302 | [[nodiscard]] static sys_seconds __from_to_sys_seconds(seconds __stdoff, const __tz::__rule& __rule) { | ||
| 303 | return chrono::__from_to_sys_seconds(__stdoff, __rule, __rule.__from); | ||
| 304 | } | ||
| 305 | |||
| 306 | [[nodiscard]] static const vector<__tz::__rule>& | ||
| 307 | __get_rules(const __tz::__rules_storage_type& __rules_db, const string& __rule_name) { | ||
| 308 | auto __result = chrono::__binary_find(__rules_db, __rule_name, {}, [](const auto& __p) { return __p.first; }); | ||
| 309 | if (__result == std::end(__rules_db)) | ||
| 310 | std::__throw_runtime_error(("corrupt tzdb: rule '" + __rule_name + " 'does not exist").c_str()); | ||
| 311 | |||
| 312 | return __result->second; | ||
| 313 | } | ||
| 314 | |||
| 315 | // Returns the letters field for a time before the first rule. | ||
| 316 | // | ||
| 317 | // Per https://data.iana.org/time-zones/tz-how-to.html | ||
| 318 | // One wrinkle, not fully explained in zic.8.txt, is what happens when switching | ||
| 319 | // to a named rule. To what values should the SAVE and LETTER data be | ||
| 320 | // initialized? | ||
| 321 | // | ||
| 322 | // 1 If at least one transition has happened, use the SAVE and LETTER data from | ||
| 323 | // the most recent. | ||
| 324 | // 2 If switching to a named rule before any transition has happened, assume | ||
| 325 | // standard time (SAVE zero), and use the LETTER data from the earliest | ||
| 326 | // transition with a SAVE of zero. | ||
| 327 | // | ||
| 328 | // This function implements case 2. | ||
| 329 | [[nodiscard]] static string __letters_before_first_rule(const vector<__tz::__rule>& __rules) { | ||
| 330 | auto __letters = | ||
| 331 | __rules // | ||
| 332 | | views::filter([](const __tz::__rule& __rule) { return __rule.__save.__time == 0s; }) // | ||
| 333 | | views::transform([](const __tz::__rule& __rule) { return __rule.__letters; }) // | ||
| 334 | | views::take(1); | ||
| 335 | |||
| 336 | if (__letters.empty()) | ||
| 337 | std::__throw_runtime_error("corrupt tzdb: rule has zero entries"); | ||
| 338 | |||
| 339 | return __letters.front(); | ||
| 340 | } | ||
| 341 | |||
| 342 | // Determines the information based on the continuation and the rules. | ||
| 343 | // | ||
| 344 | // There are several special cases to take into account | ||
| 345 | // | ||
| 346 | // === Entries before the first rule becomes active === | ||
| 347 | // Asia/Hong_Kong | ||
| 348 | // 9 - JST 1945 N 18 2 // (1) | ||
| 349 | // 8 HK HK%sT // (2) | ||
| 350 | // R HK 1946 o - Ap 21 0 1 S // (3) | ||
| 351 | // There (1) is active until Novemer 18th 1945 at 02:00, after this time | ||
| 352 | // (2) becomes active. The first rule entry for HK (3) becomes active | ||
| 353 | // from April 21st 1945 at 01:00. In the period between (2) is active. | ||
| 354 | // This entry has an offset. | ||
| 355 | // This entry has no save, letters, or dst flag. So in the period | ||
| 356 | // after (1) and until (3) no rule entry is associated with the time. | ||
| 357 | |||
| 358 | [[nodiscard]] static sys_info __get_sys_info_before_first_rule( | ||
| 359 | sys_seconds __begin, | ||
| 360 | sys_seconds __end, | ||
| 361 | const __tz::__continuation& __continuation, | ||
| 362 | const vector<__tz::__rule>& __rules) { | ||
| 363 | return sys_info{ | ||
| 364 | __begin, | ||
| 365 | __end, | ||
| 366 | __continuation.__stdoff, | ||
| 367 | chrono::minutes(0), | ||
| 368 | chrono::__format(__continuation, __letters_before_first_rule(__rules), 0s)}; | ||
| 369 | } | ||
| 370 | |||
| 371 | // Returns the sys_info object for a time before the first rule. | ||
| 372 | // When this first rule has a SAVE of 0s the sys_info for the time before the | ||
| 373 | // first rule and for the first rule are identical and will be merged. | ||
| 374 | [[nodiscard]] static sys_info __get_sys_info_before_first_rule( | ||
| 375 | sys_seconds __begin, | ||
| 376 | sys_seconds __rule_end, // The end used when SAVE != 0s | ||
| 377 | sys_seconds __next_end, // The end used when SAVE == 0s the times are merged | ||
| 378 | const __tz::__continuation& __continuation, | ||
| 379 | const vector<__tz::__rule>& __rules, | ||
| 380 | vector<__tz::__rule>::const_iterator __rule) { | ||
| 381 | if (__rule->__save.__time != 0s) | ||
| 382 | return __get_sys_info_before_first_rule(__begin, __rule_end, __continuation, __rules); | ||
| 383 | |||
| 384 | return sys_info{ | ||
| 385 | __begin, __next_end, __continuation.__stdoff, 0min, chrono::__format(__continuation, __rule->__letters, 0s)}; | ||
| 386 | } | ||
| 387 | |||
| 388 | [[nodiscard]] static seconds __at_to_seconds(seconds __stdoff, seconds __save, const __tz::__rule& __rule) { | ||
| 389 | switch (__rule.__at.__clock) { | ||
| 390 | case __tz::__clock::__local: | ||
| 391 | return __rule.__at.__time - __stdoff - __save; | ||
| 392 | |||
| 393 | case __tz::__clock::__universal: | ||
| 394 | return __rule.__at.__time; | ||
| 395 | |||
| 396 | case __tz::__clock::__standard: | ||
| 397 | return __rule.__at.__time - __stdoff; | ||
| 398 | } | ||
| 399 | std::__libcpp_unreachable(); | ||
| 400 | } | ||
| 401 | |||
| 402 | [[nodiscard]] static sys_seconds | ||
| 403 | __rule_to_sys_seconds(seconds __stdoff, seconds __save, const __tz::__rule& __rule, year __year) { | ||
| 404 | year_month_day __ymd = chrono::__to_year_month_day(__year, __rule.__in, __rule.__on); | ||
| 405 | |||
| 406 | seconds __at = chrono::__at_to_seconds(__stdoff, __save, __rule); | ||
| 407 | return chrono::__to_sys_seconds(__ymd, __at); | ||
| 408 | } | ||
| 409 | |||
| 410 | // Returns the first rule after __time. | ||
| 411 | // Note that a rule can be "active" in multiple years, this may result in an | ||
| 412 | // infinite loop where the same rule is returned every time, use __current to | ||
| 413 | // guard against that. | ||
| 414 | // | ||
| 415 | // When no next rule exists the returned time will be sys_seconds::max(). This | ||
| 416 | // can happen in practice. For example, | ||
| 417 | // | ||
| 418 | // R So 1945 o - May 24 2 2 M | ||
| 419 | // R So 1945 o - S 24 3 1 S | ||
| 420 | // R So 1945 o - N 18 2s 0 - | ||
| 421 | // | ||
| 422 | // Has 3 rules that are all only active in 1945. | ||
| 423 | [[nodiscard]] static pair<sys_seconds, vector<__tz::__rule>::const_iterator> | ||
| 424 | __next_rule(sys_seconds __time, | ||
| 425 | seconds __stdoff, | ||
| 426 | seconds __save, | ||
| 427 | const vector<__tz::__rule>& __rules, | ||
| 428 | vector<__tz::__rule>::const_iterator __current) { | ||
| 429 | year __year = year_month_day{chrono::floor<days>(__time)}.year(); | ||
| 430 | |||
| 431 | // Note it would probably be better to store the pairs in a vector and then | ||
| 432 | // use min() to get the smallest element | ||
| 433 | map<sys_seconds, vector<__tz::__rule>::const_iterator> __candidates; | ||
| 434 | // Note this evaluates all rules which is a waste of effort; when the entries | ||
| 435 | // are beyond the current year's "next year" (where "next year" is not always | ||
| 436 | // year + 1) the algorithm should end. | ||
| 437 | for (auto __it = __rules.begin(); __it != __rules.end(); ++__it) { | ||
| 438 | for (year __y = __it->__from; __y <= __it->__to; ++__y) { | ||
| 439 | // Adding the current entry for the current year may lead to infinite | ||
| 440 | // loops due to the SAVE adjustment. Skip these entries. | ||
| 441 | if (__y == __year && __it == __current) | ||
| 442 | continue; | ||
| 443 | |||
| 444 | sys_seconds __t = chrono::__rule_to_sys_seconds(__stdoff, __save, *__it, __y); | ||
| 445 | if (__t <= __time) | ||
| 446 | continue; | ||
| 447 | |||
| 448 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__candidates.contains(__t), "duplicated rule"); | ||
| 449 | __candidates[__t] = __it; | ||
| 450 | break; | ||
| 451 | } | ||
| 452 | } | ||
| 453 | |||
| 454 | if (!__candidates.empty()) [[likely]] { | ||
| 455 | auto __it = __candidates.begin(); | ||
| 456 | |||
| 457 | // When no rule is selected the time before the first rule and the first rule | ||
| 458 | // should not be merged. | ||
| 459 | if (__time == sys_seconds::min()) | ||
| 460 | return *__it; | ||
| 461 | |||
| 462 | // There can be two constitutive rules that are the same. For example, | ||
| 463 | // Hong Kong | ||
| 464 | // | ||
| 465 | // R HK 1973 o - D 30 3:30 1 S (R1) | ||
| 466 | // R HK 1965 1976 - Ap Su>=16 3:30 1 S (R2) | ||
| 467 | // | ||
| 468 | // 1973-12-29 19:30:00 R1 becomes active. | ||
| 469 | // 1974-04-20 18:30:00 R2 becomes active. | ||
| 470 | // Both rules have a SAVE of 1 hour and LETTERS are S for both of them. | ||
| 471 | while (__it != __candidates.end()) { | ||
| 472 | if (__current->__save.__time != __it->second->__save.__time || __current->__letters != __it->second->__letters) | ||
| 473 | return *__it; | ||
| 474 | |||
| 475 | ++__it; | ||
| 476 | } | ||
| 477 | } | ||
| 478 | |||
| 479 | return {sys_seconds::max(), __rules.end()}; | ||
| 480 | } | ||
| 481 | |||
| 482 | // Returns the first rule of a set of rules. | ||
| 483 | // This is not always the first of the listed rules. For example | ||
| 484 | // R Sa 2008 2009 - Mar Su>=8 0 0 - | ||
| 485 | // R Sa 2007 2008 - O Su>=8 0 1 - | ||
| 486 | // The transition in October 2007 happens before the transition in March 2008. | ||
| 487 | [[nodiscard]] static vector<__tz::__rule>::const_iterator | ||
| 488 | __first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) { | ||
| 489 | return chrono::__next_rule(sys_seconds::min(), __stdoff, 0s, __rules, __rules.end()).second; | ||
| 490 | } | ||
| 491 | |||
| 492 | [[nodiscard]] static __sys_info_result __get_sys_info_rule( | ||
| 493 | sys_seconds __time, | ||
| 494 | sys_seconds __continuation_begin, | ||
| 495 | const __tz::__continuation& __continuation, | ||
| 496 | const vector<__tz::__rule>& __rules) { | ||
| 497 | auto __rule = chrono::__first_rule(__continuation.__stdoff, __rules); | ||
| 498 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__rule != __rules.end(), "the set of rules has no first rule"); | ||
| 499 | |||
| 500 | // Avoid selecting a time before the start of the continuation | ||
| 501 | __time = std::max(__time, __continuation_begin); | ||
| 502 | |||
| 503 | sys_seconds __rule_begin = chrono::__from_to_sys_seconds(__continuation.__stdoff, *__rule); | ||
| 504 | |||
| 505 | // The time sought is very likely inside the current rule. | ||
| 506 | // When the continuation's UNTIL uses the local clock there are edge cases | ||
| 507 | // where this is not true. | ||
| 508 | // | ||
| 509 | // Start to walk the rules to find the proper one. | ||
| 510 | // | ||
| 511 | // For now we just walk all the rules TODO TZDB investigate whether a smarter | ||
| 512 | // algorithm would work. | ||
| 513 | auto __next = chrono::__next_rule(__rule_begin, __continuation.__stdoff, __rule->__save.__time, __rules, __rule); | ||
| 514 | |||
| 515 | // Ignore small steps, this happens with America/Punta_Arenas for the | ||
| 516 | // transition | ||
| 517 | // -4:42:46 - SMT 1927 S | ||
| 518 | // -5 x -05/-04 1932 S | ||
| 519 | // ... | ||
| 520 | // | ||
| 521 | // R x 1927 1931 - S 1 0 1 - | ||
| 522 | // R x 1928 1932 - Ap 1 0 0 - | ||
| 523 | // | ||
| 524 | // America/Punta_Arenas Thu Sep 1 04:42:45 1927 UT = Thu Sep 1 00:42:45 1927 -04 isdst=1 gmtoff=-14400 | ||
| 525 | // America/Punta_Arenas Sun Apr 1 03:59:59 1928 UT = Sat Mar 31 23:59:59 1928 -04 isdst=1 gmtoff=-14400 | ||
| 526 | // America/Punta_Arenas Sun Apr 1 04:00:00 1928 UT = Sat Mar 31 23:00:00 1928 -05 isdst=0 gmtoff=-18000 | ||
| 527 | // | ||
| 528 | // Without this there will be a transition | ||
| 529 | // [1927-09-01 04:42:45, 1927-09-01 05:00:00) -05:00:00 0min -05 | ||
| 530 | |||
| 531 | if (sys_seconds __begin = __rule->__save.__time != 0s ? __rule_begin : __next.first; __time < __begin) { | ||
| 532 | if (__continuation_begin == sys_seconds::min() || __begin - __continuation_begin > 12h) | ||
| 533 | return __sys_info{__get_sys_info_before_first_rule( | ||
| 534 | __continuation_begin, __rule_begin, __next.first, __continuation, __rules, __rule), | ||
| 535 | false}; | ||
| 536 | |||
| 537 | // Europe/Berlin | ||
| 538 | // 1 c CE%sT 1945 May 24 2 (C1) | ||
| 539 | // 1 So CE%sT 1946 (C2) | ||
| 540 | // | ||
| 541 | // R c 1944 1945 - Ap M>=1 2s 1 S (R1) | ||
| 542 | // | ||
| 543 | // R So 1945 o - May 24 2 2 M (R2) | ||
| 544 | // | ||
| 545 | // When C2 becomes active the time would be before the first rule R2, | ||
| 546 | // giving a 1 hour sys_info. | ||
| 547 | seconds __save = __rule->__save.__time; | ||
| 548 | __named_rule_until __continuation_end{__continuation}; | ||
| 549 | sys_seconds __sys_info_end = std::min(__continuation_end(__save), __next.first); | ||
| 550 | |||
| 551 | return __sys_info{ | ||
| 552 | sys_info{__continuation_begin, | ||
| 553 | __sys_info_end, | ||
| 554 | __continuation.__stdoff + __save, | ||
| 555 | chrono::duration_cast<minutes>(__save), | ||
| 556 | chrono::__format(__continuation, __rule->__letters, __save)}, | ||
| 557 | __sys_info_end == __continuation_end(__save)}; | ||
| 558 | } | ||
| 559 | |||
| 560 | // See above for America/Asuncion | ||
| 561 | if (__rule->__save.__time == 0s && __time < __next.first) { | ||
| 562 | return __sys_info{ | ||
| 563 | sys_info{__continuation_begin, | ||
| 564 | __next.first, | ||
| 565 | __continuation.__stdoff, | ||
| 566 | 0min, | ||
| 567 | chrono::__format(__continuation, __rule->__letters, 0s)}, | ||
| 568 | false}; | ||
| 569 | } | ||
| 570 | |||
| 571 | if (__rule->__save.__time != 0s) { | ||
| 572 | // another fix for America/Punta_Arenas when not at the start of the | ||
| 573 | // sys_info object. | ||
| 574 | seconds __save = __rule->__save.__time; | ||
| 575 | if (__continuation_begin >= __rule_begin - __save && __time < __next.first) { | ||
| 576 | return __sys_info{ | ||
| 577 | sys_info{__continuation_begin, | ||
| 578 | __next.first, | ||
| 579 | __continuation.__stdoff + __save, | ||
| 580 | chrono::duration_cast<minutes>(__save), | ||
| 581 | chrono::__format(__continuation, __rule->__letters, __save)}, | ||
| 582 | false}; | ||
| 583 | } | ||
| 584 | } | ||
| 585 | |||
| 586 | __named_rule_until __continuation_end{__continuation}; | ||
| 587 | while (__next.second != __rules.end()) { | ||
| 588 | #ifdef PRINT | ||
| 589 | std::print( | ||
| 590 | stderr, | ||
| 591 | "Rule for {}: [{}, {}) off={} save={} duration={}\n", | ||
| 592 | __time, | ||
| 593 | __rule_begin, | ||
| 594 | __next.first, | ||
| 595 | __continuation.__stdoff, | ||
| 596 | __rule->__save.__time, | ||
| 597 | __next.first - __rule_begin); | ||
| 598 | #endif | ||
| 599 | |||
| 600 | sys_seconds __end = __continuation_end(__rule->__save.__time); | ||
| 601 | |||
| 602 | sys_seconds __sys_info_begin = std::max(__continuation_begin, __rule_begin); | ||
| 603 | sys_seconds __sys_info_end = std::min(__end, __next.first); | ||
| 604 | seconds __diff = chrono::abs(__sys_info_end - __sys_info_begin); | ||
| 605 | |||
| 606 | if (__diff < 12h) { | ||
| 607 | // Z America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 O 31 | ||
| 608 | // -4:16:48 - CMT 1920 May | ||
| 609 | // -4 - -04 1930 D | ||
| 610 | // -4 A -04/-03 1969 O 5 | ||
| 611 | // -3 A -03/-02 1999 O 3 | ||
| 612 | // -4 A -04/-03 2000 Mar 3 | ||
| 613 | // ... | ||
| 614 | // | ||
| 615 | // ... | ||
| 616 | // R A 1989 1992 - O Su>=15 0 1 - | ||
| 617 | // R A 1999 o - O Su>=1 0 1 - | ||
| 618 | // R A 2000 o - Mar 3 0 0 - | ||
| 619 | // R A 2007 o - D 30 0 1 - | ||
| 620 | // ... | ||
| 621 | |||
| 622 | // The 1999 switch uses the same rule, but with a different stdoff. | ||
| 623 | // R A 1999 o - O Su>=1 0 1 - | ||
| 624 | // stdoff -3 -> 1999-10-03 03:00:00 | ||
| 625 | // stdoff -4 -> 1999-10-03 04:00:00 | ||
| 626 | // This generates an invalid entry and this is evaluated as a transition. | ||
| 627 | // Looking at the zdump like output in libc++ this generates jumps in | ||
| 628 | // the UTC time. | ||
| 629 | |||
| 630 | __rule = __next.second; | ||
| 631 | __next = __next_rule(__next.first, __continuation.__stdoff, __rule->__save.__time, __rules, __rule); | ||
| 632 | __end = __continuation_end(__rule->__save.__time); | ||
| 633 | __sys_info_end = std::min(__end, __next.first); | ||
| 634 | } | ||
| 635 | |||
| 636 | if ((__time >= __rule_begin && __time < __next.first) || __next.first >= __end) { | ||
| 637 | __sys_info_begin = std::max(__continuation_begin, __rule_begin); | ||
| 638 | __sys_info_end = std::min(__end, __next.first); | ||
| 639 | |||
| 640 | return __sys_info{ | ||
| 641 | sys_info{__sys_info_begin, | ||
| 642 | __sys_info_end, | ||
| 643 | __continuation.__stdoff + __rule->__save.__time, | ||
| 644 | chrono::duration_cast<minutes>(__rule->__save.__time), | ||
| 645 | chrono::__format(__continuation, __rule->__letters, __rule->__save.__time)}, | ||
| 646 | __sys_info_end == __end}; | ||
| 647 | } | ||
| 648 | |||
| 649 | __rule_begin = __next.first; | ||
| 650 | __rule = __next.second; | ||
| 651 | __next = __next_rule(__rule_begin, __continuation.__stdoff, __rule->__save.__time, __rules, __rule); | ||
| 652 | } | ||
| 653 | |||
| 654 | return __sys_info{ | ||
| 655 | sys_info{std::max(__continuation_begin, __rule_begin), | ||
| 656 | __continuation_end(__rule->__save.__time), | ||
| 657 | __continuation.__stdoff + __rule->__save.__time, | ||
| 658 | chrono::duration_cast<minutes>(__rule->__save.__time), | ||
| 659 | chrono::__format(__continuation, __rule->__letters, __rule->__save.__time)}, | ||
| 660 | true}; | ||
| 661 | } | ||
| 662 | |||
| 663 | [[nodiscard]] static __sys_info_result __get_sys_info_basic( | ||
| 664 | sys_seconds __time, sys_seconds __continuation_begin, const __tz::__continuation& __continuation, seconds __save) { | ||
| 665 | sys_seconds __continuation_end = chrono::__until_to_sys_seconds(__continuation); | ||
| 666 | return __sys_info{ | ||
| 667 | sys_info{__continuation_begin, | ||
| 668 | __continuation_end, | ||
| 669 | __continuation.__stdoff + __save, | ||
| 670 | chrono::duration_cast<minutes>(__save), | ||
| 671 | __continuation.__format}, | ||
| 672 | true}; | ||
| 673 | } | ||
| 674 | |||
| 675 | [[nodiscard]] static __sys_info_result | ||
| 676 | __get_sys_info(sys_seconds __time, | ||
| 677 | sys_seconds __continuation_begin, | ||
| 678 | const __tz::__continuation& __continuation, | ||
| 679 | const __tz::__rules_storage_type& __rules_db) { | ||
| 680 | return std::visit( | ||
| 681 | [&](const auto& __value) { | ||
| 682 | using _Tp = decay_t<decltype(__value)>; | ||
| 683 | if constexpr (same_as<_Tp, std::string>) | ||
| 684 | return chrono::__get_sys_info_rule( | ||
| 685 | __time, __continuation_begin, __continuation, __get_rules(__rules_db, __value)); | ||
| 686 | else if constexpr (same_as<_Tp, monostate>) | ||
| 687 | return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, chrono::seconds(0)); | ||
| 688 | else if constexpr (same_as<_Tp, __tz::__save>) | ||
| 689 | return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, __value.__time); | ||
| 690 | else | ||
| 691 | static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support | ||
| 692 | |||
| 693 | std::__libcpp_unreachable(); | ||
| 694 | }, | ||
| 695 | __continuation.__rules); | ||
| 696 | } | ||
| 697 | |||
| 698 | // The transition from one continuation to the next continuation may result in | ||
| 699 | // two constitutive continuations with the same "offset" information. | ||
| 700 | // [time.zone.info.sys]/3 | ||
| 701 | // The begin and end data members indicate that, for the associated time_zone | ||
| 702 | // and time_point, the offset and abbrev are in effect in the range | ||
| 703 | // [begin, end). This information can be used to efficiently iterate the | ||
| 704 | // transitions of a time_zone. | ||
| 705 | // | ||
| 706 | // Note that this does considers a change in the SAVE field not to be a | ||
| 707 | // different sys_info, zdump does consider this different. | ||
| 708 | // LWG XXXX The sys_info range should be affected by save | ||
| 709 | // matches the behaviour of the Standard and zdump. | ||
| 710 | // | ||
| 711 | // Iff the "offsets" are the same '__current.__end' is replaced with | ||
| 712 | // '__next.__end', which effectively merges the two objects in one object. The | ||
| 713 | // function returns true if a merge occurred. | ||
| 714 | [[nodiscard]] bool __merge_continuation(sys_info& __current, const sys_info& __next) { | ||
| 715 | if (__current.end != __next.begin) | ||
| 716 | return false; | ||
| 717 | |||
| 718 | if (__current.offset != __next.offset || __current.abbrev != __next.abbrev || __current.save != __next.save) | ||
| 719 | return false; | ||
| 720 | |||
| 721 | __current.end = __next.end; | ||
| 722 | return true; | ||
| 723 | } | ||
| 724 | |||
| 725 | //===----------------------------------------------------------------------===// | ||
| 726 | // Public API | ||
| 727 | //===----------------------------------------------------------------------===// | ||
| 728 | |||
| 729 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI time_zone time_zone::__create(unique_ptr<time_zone::__impl>&& __p) { | ||
| 730 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "initialized time_zone without a valid pimpl object"); | ||
| 731 | time_zone result; | ||
| 732 | result.__impl_ = std::move(__p); | ||
| 733 | return result; | ||
| 734 | } | ||
| 735 | |||
| 736 | _LIBCPP_EXPORTED_FROM_ABI time_zone::~time_zone() = default; | ||
| 737 | |||
| 738 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI string_view time_zone::__name() const noexcept { return __impl_->__name(); } | ||
| 739 | |||
| 740 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI sys_info | ||
| 741 | time_zone::__get_info(sys_seconds __time) const { | ||
| 742 | optional<sys_info> __result; | ||
| 743 | bool __valid_result = false; // true iff __result.has_value() is true and | ||
| 744 | // __result.begin <= __time < __result.end is true. | ||
| 745 | bool __can_merge = false; | ||
| 746 | sys_seconds __continuation_begin = sys_seconds::min(); | ||
| 747 | // Iterates over the Zone entry and its continuations. Internally the Zone | ||
| 748 | // entry is split in a Zone information and the first continuation. The last | ||
| 749 | // continuation has no UNTIL field. This means the loop should always find a | ||
| 750 | // continuation. | ||
| 751 | // | ||
| 752 | // For more information on background of zone information please consult the | ||
| 753 | // following information | ||
| 754 | // [zic manual](https://www.man7.org/linux/man-pages/man8/zic.8.html) | ||
| 755 | // [tz source info](https://data.iana.org/time-zones/tz-how-to.html) | ||
| 756 | // On POSIX systems the zdump tool can be useful: | ||
| 757 | // zdump -v Asia/Hong_Kong | ||
| 758 | // Gives all transitions in the Hong Kong time zone. | ||
| 759 | // | ||
| 760 | // During iteration the result for the current continuation is returned. If | ||
| 761 | // no continuation is applicable it will return the end time as "error". When | ||
| 762 | // two continuations are contiguous and contain the "same" information these | ||
| 763 | // ranges are merged as one range. | ||
| 764 | // The merging requires keeping any result that occurs before __time, | ||
| 765 | // likewise when a valid result is found the algorithm needs to test the next | ||
| 766 | // continuation to see whether it can be merged. For example, Africa/Ceuta | ||
| 767 | // Continuations | ||
| 768 | // 0 s WE%sT 1929 (C1) | ||
| 769 | // 0 - WET 1967 (C2) | ||
| 770 | // 0 Sp WE%sT 1984 Mar 16 (C3) | ||
| 771 | // | ||
| 772 | // Rules | ||
| 773 | // R s 1926 1929 - O Sa>=1 24s 0 - (R1) | ||
| 774 | // | ||
| 775 | // R Sp 1967 o - Jun 3 12 1 S (R2) | ||
| 776 | // | ||
| 777 | // The rule R1 is the last rule used in C1. The rule R2 is the first rule in | ||
| 778 | // C3. Since R2 is the first rule this means when a continuation uses this | ||
| 779 | // rule its value prior to R2 will be SAVE 0 LETTERS of the first entry with a | ||
| 780 | // SAVE of 0, in this case WET. | ||
| 781 | // This gives the following changes in the information. | ||
| 782 | // 1928-10-07 00:00:00 C1 R1 becomes active: offset 0 save 0 abbrev WET | ||
| 783 | // 1929-01-01 00:00:00 C2 becomes active: offset 0 save 0 abbrev WET | ||
| 784 | // 1967-01-01 00:00:00 C3 becomes active: offset 0 save 0 abbrev WET | ||
| 785 | // 1967-06-03 12:00:00 C3 R2 becomes active: offset 0 save 1 abbrev WEST | ||
| 786 | // | ||
| 787 | // The first 3 entries are contiguous and contain the same information, this | ||
| 788 | // means the period [1928-10-07 00:00:00, 1967-06-03 12:00:00) should be | ||
| 789 | // returned in one sys_info object. | ||
| 790 | |||
| 791 | const auto& __continuations = __impl_->__continuations(); | ||
| 792 | const __tz::__rules_storage_type& __rules_db = __impl_->__rules_db(); | ||
| 793 | for (auto __it = __continuations.begin(); __it != __continuations.end(); ++__it) { | ||
| 794 | const auto& __continuation = *__it; | ||
| 795 | __sys_info_result __sys_info = chrono::__get_sys_info(__time, __continuation_begin, __continuation, __rules_db); | ||
| 796 | |||
| 797 | if (__sys_info) { | ||
| 798 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 799 | __sys_info->__info.begin < __sys_info->__info.end, "invalid sys_info range"); | ||
| 800 | |||
| 801 | // Filters out dummy entries | ||
| 802 | // Z America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 O 31 | ||
| 803 | // ... | ||
| 804 | // -4 A -04/-03 2000 Mar 3 (C1) | ||
| 805 | // -3 A -03/-02 (C2) | ||
| 806 | // | ||
| 807 | // ... | ||
| 808 | // R A 2000 o - Mar 3 0 0 - | ||
| 809 | // R A 2007 o - D 30 0 1 - | ||
| 810 | // ... | ||
| 811 | // | ||
| 812 | // This results in an entry | ||
| 813 | // [2000-03-03 03:00:00, 2000-03-03 04:00:00) -10800s 60min -03 | ||
| 814 | // for [C1 & R1, C1, R2) which due to the end of the continuation is an | ||
| 815 | // one hour "sys_info". Instead the entry should be ignored and replaced | ||
| 816 | // by [C2 & R1, C2 & R2) which is the proper range | ||
| 817 | // "[2000-03-03 03:00:00, 2007-12-30 03:00:00) -02:00:00 60min -02 | ||
| 818 | |||
| 819 | if (std::holds_alternative<string>(__continuation.__rules) && __sys_info->__can_merge && | ||
| 820 | __sys_info->__info.begin + 12h > __sys_info->__info.end) { | ||
| 821 | __continuation_begin = __sys_info->__info.begin; | ||
| 822 | continue; | ||
| 823 | } | ||
| 824 | |||
| 825 | if (!__result) { | ||
| 826 | // First entry found, always keep it. | ||
| 827 | __result = __sys_info->__info; | ||
| 828 | |||
| 829 | __valid_result = __time >= __result->begin && __time < __result->end; | ||
| 830 | __can_merge = __sys_info->__can_merge; | ||
| 831 | } else if (__can_merge && chrono::__merge_continuation(*__result, __sys_info->__info)) { | ||
| 832 | // The results are merged, update the result state. This may | ||
| 833 | // "overwrite" a valid sys_info object with another valid sys_info | ||
| 834 | // object. | ||
| 835 | __valid_result = __time >= __result->begin && __time < __result->end; | ||
| 836 | __can_merge = __sys_info->__can_merge; | ||
| 837 | } else { | ||
| 838 | // Here things get interesting: | ||
| 839 | // For example, America/Argentina/San_Luis | ||
| 840 | // | ||
| 841 | // -3 A -03/-02 2008 Ja 21 (C1) | ||
| 842 | // -4 Sa -04/-03 2009 O 11 (C2) | ||
| 843 | // | ||
| 844 | // R A 2007 o - D 30 0 1 - (R1) | ||
| 845 | // | ||
| 846 | // R Sa 2007 2008 - O Su>=8 0 1 - (R2) | ||
| 847 | // | ||
| 848 | // Based on C1 & R1 the end time of C1 is 2008-01-21 03:00:00 | ||
| 849 | // Based on C2 & R2 the end time of C1 is 2008-01-21 02:00:00 | ||
| 850 | // In this case the earlier time is the real time of the transition. | ||
| 851 | // However the algorithm used gives 2008-01-21 03:00:00. | ||
| 852 | // | ||
| 853 | // So we need to calculate the previous UNTIL in the current context and | ||
| 854 | // see whether it's earlier. | ||
| 855 | |||
| 856 | // The results could not be merged. | ||
| 857 | // - When we have a valid result that result is the final result. | ||
| 858 | // - Otherwise the result we had is before __time and the result we got | ||
| 859 | // is at a later time (possibly valid). This result is always better | ||
| 860 | // than the previous result. | ||
| 861 | if (__valid_result) { | ||
| 862 | return *__result; | ||
| 863 | } else { | ||
| 864 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | ||
| 865 | __it != __continuations.begin(), "the first rule should always seed the result"); | ||
| 866 | const auto& __last = *(__it - 1); | ||
| 867 | if (std::holds_alternative<string>(__last.__rules)) { | ||
| 868 | // Europe/Berlin | ||
| 869 | // 1 c CE%sT 1945 May 24 2 (C1) | ||
| 870 | // 1 So CE%sT 1946 (C2) | ||
| 871 | // | ||
| 872 | // R c 1944 1945 - Ap M>=1 2s 1 S (R1) | ||
| 873 | // | ||
| 874 | // R So 1945 o - May 24 2 2 M (R2) | ||
| 875 | // | ||
| 876 | // When C2 becomes active the time would be before the first rule R2, | ||
| 877 | // giving a 1 hour sys_info. This is not valid and the results need | ||
| 878 | // merging. | ||
| 879 | |||
| 880 | if (__result->end != __sys_info->__info.begin) { | ||
| 881 | // When the UTC gap between the rules is due to the change of | ||
| 882 | // offsets adjust the new time to remove the gap. | ||
| 883 | sys_seconds __end = __result->end - __result->offset; | ||
| 884 | sys_seconds __begin = __sys_info->__info.begin - __sys_info->__info.offset; | ||
| 885 | if (__end == __begin) { | ||
| 886 | __sys_info->__info.begin = __result->end; | ||
| 887 | } | ||
| 888 | } | ||
| 889 | } | ||
| 890 | |||
| 891 | __result = __sys_info->__info; | ||
| 892 | __valid_result = __time >= __result->begin && __time < __result->end; | ||
| 893 | __can_merge = __sys_info->__can_merge; | ||
| 894 | } | ||
| 895 | } | ||
| 896 | __continuation_begin = __result->end; | ||
| 897 | } else { | ||
| 898 | __continuation_begin = __sys_info.error(); | ||
| 899 | } | ||
| 900 | } | ||
| 901 | if (__valid_result) | ||
| 902 | return *__result; | ||
| 903 | |||
| 904 | std::__throw_runtime_error("tzdb: corrupt db"); | ||
| 905 | } | ||
| 906 | |||
| 907 | // Is the "__local_time" present in "__first" and "__second". If so the | ||
| 908 | // local_info has an ambiguous result. | ||
| 909 | [[nodiscard]] static bool | ||
| 910 | __is_ambiguous(local_seconds __local_time, const sys_info& __first, const sys_info& __second) { | ||
| 911 | std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + __first.offset}; | ||
| 912 | std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() + __second.offset}; | ||
| 913 | |||
| 914 | return __local_time < __end_first && __local_time >= __begin_second; | ||
| 915 | } | ||
| 916 | |||
| 917 | // Determines the result of the "__local_time". This expects the object | ||
| 918 | // "__first" to be earlier in time than "__second". | ||
| 919 | [[nodiscard]] static local_info | ||
| 920 | __get_info(local_seconds __local_time, const sys_info& __first, const sys_info& __second) { | ||
| 921 | std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + __first.offset}; | ||
| 922 | std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() + __second.offset}; | ||
| 923 | |||
| 924 | if (__local_time < __end_first) { | ||
| 925 | if (__local_time >= __begin_second) | ||
| 926 | // |--------| | ||
| 927 | // |------| | ||
| 928 | // ^ | ||
| 929 | return {local_info::ambiguous, __first, __second}; | ||
| 930 | |||
| 931 | // |--------| | ||
| 932 | // |------| | ||
| 933 | // ^ | ||
| 934 | return {local_info::unique, __first, sys_info{}}; | ||
| 935 | } | ||
| 936 | |||
| 937 | if (__local_time < __begin_second) | ||
| 938 | // |--------| | ||
| 939 | // |------| | ||
| 940 | // ^ | ||
| 941 | return {local_info::nonexistent, __first, __second}; | ||
| 942 | |||
| 943 | // |--------| | ||
| 944 | // |------| | ||
| 945 | // ^ | ||
| 946 | return {local_info::unique, __second, sys_info{}}; | ||
| 947 | } | ||
| 948 | |||
| 949 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info | ||
| 950 | time_zone::__get_info(local_seconds __local_time) const { | ||
| 951 | seconds __local_seconds = __local_time.time_since_epoch(); | ||
| 952 | |||
| 953 | /* An example of a typical year with a DST switch displayed in local time. | ||
| 954 | * | ||
| 955 | * At the first of April the time goes forward one hour. This means the | ||
| 956 | * time marked with ~~ is not a valid local time. This is represented by the | ||
| 957 | * nonexistent value in local_info.result. | ||
| 958 | * | ||
| 959 | * At the first of November the time goes backward one hour. This means the | ||
| 960 | * time marked with ^^ happens twice. This is represented by the ambiguous | ||
| 961 | * value in local_info.result. | ||
| 962 | * | ||
| 963 | * 2020.11.01 2021.04.01 2021.11.01 | ||
| 964 | * offset +05 offset +05 offset +05 | ||
| 965 | * save 0s save 1h save 0s | ||
| 966 | * |------------//----------| | ||
| 967 | * |---------//--------------| | ||
| 968 | * |------------- | ||
| 969 | * ~~ ^^ | ||
| 970 | * | ||
| 971 | * These shifts can happen due to changes in the current time zone for a | ||
| 972 | * location. For example, Indian/Kerguelen switched only once. In 1950 from an | ||
| 973 | * offset of 0 hours to an offset of +05 hours. | ||
| 974 | * | ||
| 975 | * During all these shifts the UTC time will not have gaps. | ||
| 976 | */ | ||
| 977 | |||
| 978 | // The code needs to determine the system time for the local time. There is no | ||
| 979 | // information available. Assume the offset between system time and local time | ||
| 980 | // is 0s. This gives an initial estimate. | ||
| 981 | sys_seconds __guess{__local_seconds}; | ||
| 982 | sys_info __info = __get_info(__guess); | ||
| 983 | |||
| 984 | // At this point the offset can be used to determine an estimate for the local | ||
| 985 | // time. Before doing that, determine the offset and validate whether the | ||
| 986 | // local time is the range [chrono::local_seconds::min(), | ||
| 987 | // chrono::local_seconds::max()). | ||
| 988 | if (__local_seconds < 0s && __info.offset > 0s) | ||
| 989 | if (__local_seconds - chrono::local_seconds::min().time_since_epoch() < __info.offset) | ||
| 990 | return {-1, __info, {}}; | ||
| 991 | |||
| 992 | if (__local_seconds > 0s && __info.offset < 0s) | ||
| 993 | if (chrono::local_seconds::max().time_since_epoch() - __local_seconds < -__info.offset) | ||
| 994 | return {-2, __info, {}}; | ||
| 995 | |||
| 996 | // Based on the information found in the sys_info, the local time can be | ||
| 997 | // converted to a system time. This resulting time can be in the following | ||
| 998 | // locations of the sys_info: | ||
| 999 | // | ||
| 1000 | // |---------//--------------| | ||
| 1001 | // 1 2.1 2.2 2.3 3 | ||
| 1002 | // | ||
| 1003 | // 1. The estimate is before the returned sys_info object. | ||
| 1004 | // The result is either non-existent or unique in the previous sys_info. | ||
| 1005 | // 2. The estimate is in the sys_info object | ||
| 1006 | // - If the sys_info begin is not sys_seconds::min(), then it might be at | ||
| 1007 | // 2.1 and could be ambiguous with the previous or unique. | ||
| 1008 | // - If sys_info end is not sys_seconds::max(), then it might be at 2.3 | ||
| 1009 | // and could be ambiguous with the next or unique. | ||
| 1010 | // - Else it is at 2.2 and always unique. This case happens when a | ||
| 1011 | // time zone has no transitions. For example, UTC or GMT+1. | ||
| 1012 | // 3. The estimate is after the returned sys_info object. | ||
| 1013 | // The result is either non-existent or unique in the next sys_info. | ||
| 1014 | // | ||
| 1015 | // There is no specification where the "middle" starts. Similar issues can | ||
| 1016 | // happen when sys_info objects are "short", then "unique in the next" could | ||
| 1017 | // become "ambiguous in the next and the one following". Theoretically there | ||
| 1018 | // is the option of the following time-line | ||
| 1019 | // | ||
| 1020 | // |------------| | ||
| 1021 | // |----| | ||
| 1022 | // |-----------------| | ||
| 1023 | // | ||
| 1024 | // However the local_info object only has 2 sys_info objects, so this option | ||
| 1025 | // is not tested. | ||
| 1026 | |||
| 1027 | sys_seconds __sys_time{__local_seconds - __info.offset}; | ||
| 1028 | if (__sys_time < __info.begin) | ||
| 1029 | // Case 1 before __info | ||
| 1030 | return chrono::__get_info(__local_time, __get_info(__info.begin - 1s), __info); | ||
| 1031 | |||
| 1032 | if (__sys_time >= __info.end) | ||
| 1033 | // Case 3 after __info | ||
| 1034 | return chrono::__get_info(__local_time, __info, __get_info(__info.end)); | ||
| 1035 | |||
| 1036 | // Case 2 in __info | ||
| 1037 | if (__info.begin != sys_seconds::min()) { | ||
| 1038 | // Case 2.1 Not at the beginning, when not ambiguous the result should test | ||
| 1039 | // case 2.3. | ||
| 1040 | sys_info __prev = __get_info(__info.begin - 1s); | ||
| 1041 | if (__is_ambiguous(__local_time, __prev, __info)) | ||
| 1042 | return {local_info::ambiguous, __prev, __info}; | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | if (__info.end == sys_seconds::max()) | ||
| 1046 | // At the end so it's case 2.2 | ||
| 1047 | return {local_info::unique, __info, sys_info{}}; | ||
| 1048 | |||
| 1049 | // This tests case 2.2 or case 2.3. | ||
| 1050 | return chrono::__get_info(__local_time, __info, __get_info(__info.end)); | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | } // namespace chrono | ||
| 1054 | |||
| 1055 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/experimental/tzdb.cpp created+781| ... | @@ -0,0 +1,781 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | #include <algorithm> | ||
| 12 | #include <chrono> | ||
| 13 | #include <filesystem> | ||
| 14 | #include <fstream> | ||
| 15 | #include <stdexcept> | ||
| 16 | #include <string> | ||
| 17 | |||
| 18 | #include "include/tzdb/time_zone_private.h" | ||
| 19 | #include "include/tzdb/types_private.h" | ||
| 20 | #include "include/tzdb/tzdb_list_private.h" | ||
| 21 | #include "include/tzdb/tzdb_private.h" | ||
| 22 | |||
| 23 | // Contains a parser for the IANA time zone data files. | ||
| 24 | // | ||
| 25 | // These files can be found at https://data.iana.org/time-zones/ and are in the | ||
| 26 | // public domain. Information regarding the input can be found at | ||
| 27 | // https://data.iana.org/time-zones/tz-how-to.html and | ||
| 28 | // https://man7.org/linux/man-pages/man8/zic.8.html. | ||
| 29 | // | ||
| 30 | // As indicated at https://howardhinnant.github.io/date/tz.html#Installation | ||
| 31 | // For Windows another file seems to be required | ||
| 32 | // https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml | ||
| 33 | // This file seems to contain the mapping of Windows time zone name to IANA | ||
| 34 | // time zone names. | ||
| 35 | // | ||
| 36 | // However this article mentions another way to do the mapping on Windows | ||
| 37 | // https://devblogs.microsoft.com/oldnewthing/20210527-00/?p=105255 | ||
| 38 | // This requires Windows 10 Version 1903, which was released in May of 2019 | ||
| 39 | // and considered end of life in December 2020 | ||
| 40 | // https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1903-end-of-servicing | ||
| 41 | // | ||
| 42 | // TODO TZDB Implement the Windows mapping in tzdb::current_zone | ||
| 43 | |||
| 44 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 45 | |||
| 46 | namespace chrono { | ||
| 47 | |||
| 48 | // This function is weak so it can be overriden in the tests. The | ||
| 49 | // declaration is in the test header test/support/test_tzdb.h | ||
| 50 | _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { | ||
| 51 | #if defined(__linux__) | ||
| 52 | return "/usr/share/zoneinfo/"; | ||
| 53 | #else | ||
| 54 | // Zig patch: change this compilation error into a runtime crash. | ||
| 55 | //# error "unknown path to the IANA Time Zone Database" | ||
| 56 | abort(); | ||
| 57 | #endif | ||
| 58 | } | ||
| 59 | |||
| 60 | //===----------------------------------------------------------------------===// | ||
| 61 | // Details | ||
| 62 | //===----------------------------------------------------------------------===// | ||
| 63 | |||
| 64 | [[nodiscard]] static bool __is_whitespace(int __c) { return __c == ' ' || __c == '\t'; } | ||
| 65 | |||
| 66 | static void __skip_optional_whitespace(istream& __input) { | ||
| 67 | while (chrono::__is_whitespace(__input.peek())) | ||
| 68 | __input.get(); | ||
| 69 | } | ||
| 70 | |||
| 71 | static void __skip_mandatory_whitespace(istream& __input) { | ||
| 72 | if (!chrono::__is_whitespace(__input.get())) | ||
| 73 | std::__throw_runtime_error("corrupt tzdb: expected whitespace"); | ||
| 74 | |||
| 75 | chrono::__skip_optional_whitespace(__input); | ||
| 76 | } | ||
| 77 | |||
| 78 | [[nodiscard]] static bool __is_eol(int __c) { return __c == '\n' || __c == std::char_traits<char>::eof(); } | ||
| 79 | |||
| 80 | static void __skip_line(istream& __input) { | ||
| 81 | while (!chrono::__is_eol(__input.peek())) { | ||
| 82 | __input.get(); | ||
| 83 | } | ||
| 84 | __input.get(); | ||
| 85 | } | ||
| 86 | |||
| 87 | static void __skip(istream& __input, char __suffix) { | ||
| 88 | if (std::tolower(__input.peek()) == __suffix) | ||
| 89 | __input.get(); | ||
| 90 | } | ||
| 91 | |||
| 92 | static void __skip(istream& __input, string_view __suffix) { | ||
| 93 | for (auto __c : __suffix) | ||
| 94 | if (std::tolower(__input.peek()) == __c) | ||
| 95 | __input.get(); | ||
| 96 | } | ||
| 97 | |||
| 98 | static void __matches(istream& __input, char __expected) { | ||
| 99 | if (std::tolower(__input.get()) != __expected) | ||
| 100 | std::__throw_runtime_error((string("corrupt tzdb: expected character '") + __expected + '\'').c_str()); | ||
| 101 | } | ||
| 102 | |||
| 103 | static void __matches(istream& __input, string_view __expected) { | ||
| 104 | for (auto __c : __expected) | ||
| 105 | if (std::tolower(__input.get()) != __c) | ||
| 106 | std::__throw_runtime_error((string("corrupt tzdb: expected string '") + string(__expected) + '\'').c_str()); | ||
| 107 | } | ||
| 108 | |||
| 109 | [[nodiscard]] static string __parse_string(istream& __input) { | ||
| 110 | string __result; | ||
| 111 | while (true) { | ||
| 112 | int __c = __input.get(); | ||
| 113 | switch (__c) { | ||
| 114 | case ' ': | ||
| 115 | case '\t': | ||
| 116 | case '\n': | ||
| 117 | __input.unget(); | ||
| 118 | [[fallthrough]]; | ||
| 119 | case istream::traits_type::eof(): | ||
| 120 | if (__result.empty()) | ||
| 121 | std::__throw_runtime_error("corrupt tzdb: expected a string"); | ||
| 122 | |||
| 123 | return __result; | ||
| 124 | |||
| 125 | default: | ||
| 126 | __result.push_back(__c); | ||
| 127 | } | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | [[nodiscard]] static int64_t __parse_integral(istream& __input, bool __leading_zero_allowed) { | ||
| 132 | int64_t __result = __input.get(); | ||
| 133 | if (__leading_zero_allowed) { | ||
| 134 | if (__result < '0' || __result > '9') | ||
| 135 | std::__throw_runtime_error("corrupt tzdb: expected a digit"); | ||
| 136 | } else { | ||
| 137 | if (__result < '1' || __result > '9') | ||
| 138 | std::__throw_runtime_error("corrupt tzdb: expected a non-zero digit"); | ||
| 139 | } | ||
| 140 | __result -= '0'; | ||
| 141 | while (true) { | ||
| 142 | if (__input.peek() < '0' || __input.peek() > '9') | ||
| 143 | return __result; | ||
| 144 | |||
| 145 | // In order to avoid possible overflows we limit the accepted range. | ||
| 146 | // Most values parsed are expected to be very small: | ||
| 147 | // - 8784 hours in a year | ||
| 148 | // - 31 days in a month | ||
| 149 | // - year no real maximum, these values are expected to be less than | ||
| 150 | // the range of the year type. | ||
| 151 | // | ||
| 152 | // However the leapseconds use a seconds after epoch value. Using an | ||
| 153 | // int would run into an overflow in 2038. By using a 64-bit value | ||
| 154 | // the range is large enough for the bilions of years. Limiting that | ||
| 155 | // range slightly to make the code easier is not an issue. | ||
| 156 | if (__result > (std::numeric_limits<int64_t>::max() / 16)) | ||
| 157 | std::__throw_runtime_error("corrupt tzdb: integral too large"); | ||
| 158 | |||
| 159 | __result *= 10; | ||
| 160 | __result += __input.get() - '0'; | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | //===----------------------------------------------------------------------===// | ||
| 165 | // Calendar | ||
| 166 | //===----------------------------------------------------------------------===// | ||
| 167 | |||
| 168 | [[nodiscard]] static day __parse_day(istream& __input) { | ||
| 169 | unsigned __result = chrono::__parse_integral(__input, false); | ||
| 170 | if (__result > 31) | ||
| 171 | std::__throw_runtime_error("corrupt tzdb day: value too large"); | ||
| 172 | return day{__result}; | ||
| 173 | } | ||
| 174 | |||
| 175 | [[nodiscard]] static weekday __parse_weekday(istream& __input) { | ||
| 176 | // TZDB allows the shortest unique name. | ||
| 177 | switch (std::tolower(__input.get())) { | ||
| 178 | case 'f': | ||
| 179 | chrono::__skip(__input, "riday"); | ||
| 180 | return Friday; | ||
| 181 | |||
| 182 | case 'm': | ||
| 183 | chrono::__skip(__input, "onday"); | ||
| 184 | return Monday; | ||
| 185 | |||
| 186 | case 's': | ||
| 187 | switch (std::tolower(__input.get())) { | ||
| 188 | case 'a': | ||
| 189 | chrono::__skip(__input, "turday"); | ||
| 190 | return Saturday; | ||
| 191 | |||
| 192 | case 'u': | ||
| 193 | chrono::__skip(__input, "nday"); | ||
| 194 | return Sunday; | ||
| 195 | } | ||
| 196 | break; | ||
| 197 | |||
| 198 | case 't': | ||
| 199 | switch (std::tolower(__input.get())) { | ||
| 200 | case 'h': | ||
| 201 | chrono::__skip(__input, "ursday"); | ||
| 202 | return Thursday; | ||
| 203 | |||
| 204 | case 'u': | ||
| 205 | chrono::__skip(__input, "esday"); | ||
| 206 | return Tuesday; | ||
| 207 | } | ||
| 208 | break; | ||
| 209 | case 'w': | ||
| 210 | chrono::__skip(__input, "ednesday"); | ||
| 211 | return Wednesday; | ||
| 212 | } | ||
| 213 | |||
| 214 | std::__throw_runtime_error("corrupt tzdb weekday: invalid name"); | ||
| 215 | } | ||
| 216 | |||
| 217 | [[nodiscard]] static month __parse_month(istream& __input) { | ||
| 218 | // TZDB allows the shortest unique name. | ||
| 219 | switch (std::tolower(__input.get())) { | ||
| 220 | case 'a': | ||
| 221 | switch (std::tolower(__input.get())) { | ||
| 222 | case 'p': | ||
| 223 | chrono::__skip(__input, "ril"); | ||
| 224 | return April; | ||
| 225 | |||
| 226 | case 'u': | ||
| 227 | chrono::__skip(__input, "gust"); | ||
| 228 | return August; | ||
| 229 | } | ||
| 230 | break; | ||
| 231 | |||
| 232 | case 'd': | ||
| 233 | chrono::__skip(__input, "ecember"); | ||
| 234 | return December; | ||
| 235 | |||
| 236 | case 'f': | ||
| 237 | chrono::__skip(__input, "ebruary"); | ||
| 238 | return February; | ||
| 239 | |||
| 240 | case 'j': | ||
| 241 | switch (std::tolower(__input.get())) { | ||
| 242 | case 'a': | ||
| 243 | chrono::__skip(__input, "nuary"); | ||
| 244 | return January; | ||
| 245 | |||
| 246 | case 'u': | ||
| 247 | switch (std::tolower(__input.get())) { | ||
| 248 | case 'n': | ||
| 249 | chrono::__skip(__input, 'e'); | ||
| 250 | return June; | ||
| 251 | |||
| 252 | case 'l': | ||
| 253 | chrono::__skip(__input, 'y'); | ||
| 254 | return July; | ||
| 255 | } | ||
| 256 | } | ||
| 257 | break; | ||
| 258 | |||
| 259 | case 'm': | ||
| 260 | if (std::tolower(__input.get()) == 'a') | ||
| 261 | switch (std::tolower(__input.get())) { | ||
| 262 | case 'y': | ||
| 263 | return May; | ||
| 264 | |||
| 265 | case 'r': | ||
| 266 | chrono::__skip(__input, "ch"); | ||
| 267 | return March; | ||
| 268 | } | ||
| 269 | break; | ||
| 270 | |||
| 271 | case 'n': | ||
| 272 | chrono::__skip(__input, "ovember"); | ||
| 273 | return November; | ||
| 274 | |||
| 275 | case 'o': | ||
| 276 | chrono::__skip(__input, "ctober"); | ||
| 277 | return October; | ||
| 278 | |||
| 279 | case 's': | ||
| 280 | chrono::__skip(__input, "eptember"); | ||
| 281 | return September; | ||
| 282 | } | ||
| 283 | std::__throw_runtime_error("corrupt tzdb month: invalid name"); | ||
| 284 | } | ||
| 285 | |||
| 286 | [[nodiscard]] static year __parse_year_value(istream& __input) { | ||
| 287 | bool __negative = __input.peek() == '-'; | ||
| 288 | if (__negative) [[unlikely]] | ||
| 289 | __input.get(); | ||
| 290 | |||
| 291 | int64_t __result = __parse_integral(__input, true); | ||
| 292 | if (__result > static_cast<int>(year::max())) { | ||
| 293 | if (__negative) | ||
| 294 | std::__throw_runtime_error("corrupt tzdb year: year is less than the minimum"); | ||
| 295 | |||
| 296 | std::__throw_runtime_error("corrupt tzdb year: year is greater than the maximum"); | ||
| 297 | } | ||
| 298 | |||
| 299 | return year{static_cast<int>(__negative ? -__result : __result)}; | ||
| 300 | } | ||
| 301 | |||
| 302 | [[nodiscard]] static year __parse_year(istream& __input) { | ||
| 303 | if (std::tolower(__input.peek()) != 'm') [[likely]] | ||
| 304 | return chrono::__parse_year_value(__input); | ||
| 305 | |||
| 306 | __input.get(); | ||
| 307 | switch (std::tolower(__input.peek())) { | ||
| 308 | case 'i': | ||
| 309 | __input.get(); | ||
| 310 | chrono::__skip(__input, 'n'); | ||
| 311 | [[fallthrough]]; | ||
| 312 | |||
| 313 | case ' ': | ||
| 314 | // The m is minimum, even when that is ambiguous. | ||
| 315 | return year::min(); | ||
| 316 | |||
| 317 | case 'a': | ||
| 318 | __input.get(); | ||
| 319 | chrono::__skip(__input, 'x'); | ||
| 320 | return year::max(); | ||
| 321 | } | ||
| 322 | |||
| 323 | std::__throw_runtime_error("corrupt tzdb year: expected 'min' or 'max'"); | ||
| 324 | } | ||
| 325 | |||
| 326 | //===----------------------------------------------------------------------===// | ||
| 327 | // TZDB fields | ||
| 328 | //===----------------------------------------------------------------------===// | ||
| 329 | |||
| 330 | [[nodiscard]] static year __parse_to(istream& __input, year __only) { | ||
| 331 | if (std::tolower(__input.peek()) != 'o') | ||
| 332 | return chrono::__parse_year(__input); | ||
| 333 | |||
| 334 | __input.get(); | ||
| 335 | chrono::__skip(__input, "nly"); | ||
| 336 | return __only; | ||
| 337 | } | ||
| 338 | |||
| 339 | [[nodiscard]] static __tz::__constrained_weekday::__comparison_t __parse_comparison(istream& __input) { | ||
| 340 | switch (__input.get()) { | ||
| 341 | case '>': | ||
| 342 | chrono::__matches(__input, '='); | ||
| 343 | return __tz::__constrained_weekday::__ge; | ||
| 344 | |||
| 345 | case '<': | ||
| 346 | chrono::__matches(__input, '='); | ||
| 347 | return __tz::__constrained_weekday::__le; | ||
| 348 | } | ||
| 349 | std::__throw_runtime_error("corrupt tzdb on: expected '>=' or '<='"); | ||
| 350 | } | ||
| 351 | |||
| 352 | [[nodiscard]] static __tz::__on __parse_on(istream& __input) { | ||
| 353 | if (std::isdigit(__input.peek())) | ||
| 354 | return chrono::__parse_day(__input); | ||
| 355 | |||
| 356 | if (std::tolower(__input.peek()) == 'l') { | ||
| 357 | chrono::__matches(__input, "last"); | ||
| 358 | return weekday_last(chrono::__parse_weekday(__input)); | ||
| 359 | } | ||
| 360 | |||
| 361 | return __tz::__constrained_weekday{ | ||
| 362 | chrono::__parse_weekday(__input), chrono::__parse_comparison(__input), chrono::__parse_day(__input)}; | ||
| 363 | } | ||
| 364 | |||
| 365 | [[nodiscard]] static seconds __parse_duration(istream& __input) { | ||
| 366 | seconds __result{0}; | ||
| 367 | int __c = __input.peek(); | ||
| 368 | bool __negative = __c == '-'; | ||
| 369 | if (__negative) { | ||
| 370 | __input.get(); | ||
| 371 | // Negative is either a negative value or a single -. | ||
| 372 | // The latter means 0 and the parsing is complete. | ||
| 373 | if (!std::isdigit(__input.peek())) | ||
| 374 | return __result; | ||
| 375 | } | ||
| 376 | |||
| 377 | __result += hours(__parse_integral(__input, true)); | ||
| 378 | if (__input.peek() != ':') | ||
| 379 | return __negative ? -__result : __result; | ||
| 380 | |||
| 381 | __input.get(); | ||
| 382 | __result += minutes(__parse_integral(__input, true)); | ||
| 383 | if (__input.peek() != ':') | ||
| 384 | return __negative ? -__result : __result; | ||
| 385 | |||
| 386 | __input.get(); | ||
| 387 | __result += seconds(__parse_integral(__input, true)); | ||
| 388 | if (__input.peek() != '.') | ||
| 389 | return __negative ? -__result : __result; | ||
| 390 | |||
| 391 | __input.get(); | ||
| 392 | (void)__parse_integral(__input, true); // Truncate the digits. | ||
| 393 | |||
| 394 | return __negative ? -__result : __result; | ||
| 395 | } | ||
| 396 | |||
| 397 | [[nodiscard]] static __tz::__clock __parse_clock(istream& __input) { | ||
| 398 | switch (__input.get()) { // case sensitive | ||
| 399 | case 'w': | ||
| 400 | return __tz::__clock::__local; | ||
| 401 | case 's': | ||
| 402 | return __tz::__clock::__standard; | ||
| 403 | |||
| 404 | case 'u': | ||
| 405 | case 'g': | ||
| 406 | case 'z': | ||
| 407 | return __tz::__clock::__universal; | ||
| 408 | } | ||
| 409 | |||
| 410 | __input.unget(); | ||
| 411 | return __tz::__clock::__local; | ||
| 412 | } | ||
| 413 | |||
| 414 | [[nodiscard]] static bool __parse_dst(istream& __input, seconds __offset) { | ||
| 415 | switch (__input.get()) { // case sensitive | ||
| 416 | case 's': | ||
| 417 | return false; | ||
| 418 | |||
| 419 | case 'd': | ||
| 420 | return true; | ||
| 421 | } | ||
| 422 | |||
| 423 | __input.unget(); | ||
| 424 | return __offset != 0s; | ||
| 425 | } | ||
| 426 | |||
| 427 | [[nodiscard]] static __tz::__at __parse_at(istream& __input) { | ||
| 428 | return {__parse_duration(__input), __parse_clock(__input)}; | ||
| 429 | } | ||
| 430 | |||
| 431 | [[nodiscard]] static __tz::__save __parse_save(istream& __input) { | ||
| 432 | seconds __time = chrono::__parse_duration(__input); | ||
| 433 | return {__time, chrono::__parse_dst(__input, __time)}; | ||
| 434 | } | ||
| 435 | |||
| 436 | [[nodiscard]] static string __parse_letters(istream& __input) { | ||
| 437 | string __result = __parse_string(__input); | ||
| 438 | // Canonicalize "-" to "" since they are equivalent in the specification. | ||
| 439 | return __result != "-" ? __result : ""; | ||
| 440 | } | ||
| 441 | |||
| 442 | [[nodiscard]] static __tz::__continuation::__rules_t __parse_rules(istream& __input) { | ||
| 443 | int __c = __input.peek(); | ||
| 444 | // A single - is not a SAVE but a special case. | ||
| 445 | if (__c == '-') { | ||
| 446 | __input.get(); | ||
| 447 | if (chrono::__is_whitespace(__input.peek())) | ||
| 448 | return monostate{}; | ||
| 449 | __input.unget(); | ||
| 450 | return chrono::__parse_save(__input); | ||
| 451 | } | ||
| 452 | |||
| 453 | if (std::isdigit(__c) || __c == '+') | ||
| 454 | return chrono::__parse_save(__input); | ||
| 455 | |||
| 456 | return chrono::__parse_string(__input); | ||
| 457 | } | ||
| 458 | |||
| 459 | [[nodiscard]] static __tz::__continuation __parse_continuation(__tz::__rules_storage_type& __rules, istream& __input) { | ||
| 460 | __tz::__continuation __result; | ||
| 461 | |||
| 462 | __result.__rule_database_ = std::addressof(__rules); | ||
| 463 | |||
| 464 | // Note STDOFF is specified as | ||
| 465 | // This field has the same format as the AT and SAVE fields of rule lines; | ||
| 466 | // These fields have different suffix letters, these letters seem | ||
| 467 | // not to be used so do not allow any of them. | ||
| 468 | |||
| 469 | __result.__stdoff = chrono::__parse_duration(__input); | ||
| 470 | chrono::__skip_mandatory_whitespace(__input); | ||
| 471 | __result.__rules = chrono::__parse_rules(__input); | ||
| 472 | chrono::__skip_mandatory_whitespace(__input); | ||
| 473 | __result.__format = chrono::__parse_string(__input); | ||
| 474 | chrono::__skip_optional_whitespace(__input); | ||
| 475 | |||
| 476 | if (chrono::__is_eol(__input.peek())) | ||
| 477 | return __result; | ||
| 478 | __result.__year = chrono::__parse_year(__input); | ||
| 479 | chrono::__skip_optional_whitespace(__input); | ||
| 480 | |||
| 481 | if (chrono::__is_eol(__input.peek())) | ||
| 482 | return __result; | ||
| 483 | __result.__in = chrono::__parse_month(__input); | ||
| 484 | chrono::__skip_optional_whitespace(__input); | ||
| 485 | |||
| 486 | if (chrono::__is_eol(__input.peek())) | ||
| 487 | return __result; | ||
| 488 | __result.__on = chrono::__parse_on(__input); | ||
| 489 | chrono::__skip_optional_whitespace(__input); | ||
| 490 | |||
| 491 | if (chrono::__is_eol(__input.peek())) | ||
| 492 | return __result; | ||
| 493 | __result.__at = __parse_at(__input); | ||
| 494 | |||
| 495 | return __result; | ||
| 496 | } | ||
| 497 | |||
| 498 | //===----------------------------------------------------------------------===// | ||
| 499 | // Time Zone Database entries | ||
| 500 | //===----------------------------------------------------------------------===// | ||
| 501 | |||
| 502 | static string __parse_version(istream& __input) { | ||
| 503 | // The first line in tzdata.zi contains | ||
| 504 | // # version YYYYw | ||
| 505 | // The parser expects this pattern | ||
| 506 | // #\s*version\s*\(.*) | ||
| 507 | // This part is not documented. | ||
| 508 | chrono::__matches(__input, '#'); | ||
| 509 | chrono::__skip_optional_whitespace(__input); | ||
| 510 | chrono::__matches(__input, "version"); | ||
| 511 | chrono::__skip_mandatory_whitespace(__input); | ||
| 512 | return chrono::__parse_string(__input); | ||
| 513 | } | ||
| 514 | |||
| 515 | [[nodiscard]] | ||
| 516 | static __tz::__rule& __create_entry(__tz::__rules_storage_type& __rules, const string& __name) { | ||
| 517 | auto __result = [&]() -> __tz::__rule& { | ||
| 518 | auto& __rule = __rules.emplace_back(__name, vector<__tz::__rule>{}); | ||
| 519 | return __rule.second.emplace_back(); | ||
| 520 | }; | ||
| 521 | |||
| 522 | if (__rules.empty()) | ||
| 523 | return __result(); | ||
| 524 | |||
| 525 | // Typically rules are in contiguous order in the database. | ||
| 526 | // But there are exceptions, some rules are interleaved. | ||
| 527 | if (__rules.back().first == __name) | ||
| 528 | return __rules.back().second.emplace_back(); | ||
| 529 | |||
| 530 | if (auto __it = ranges::find(__rules, __name, [](const auto& __r) { return __r.first; }); | ||
| 531 | __it != ranges::end(__rules)) | ||
| 532 | return __it->second.emplace_back(); | ||
| 533 | |||
| 534 | return __result(); | ||
| 535 | } | ||
| 536 | |||
| 537 | static void __parse_rule(tzdb& __tzdb, __tz::__rules_storage_type& __rules, istream& __input) { | ||
| 538 | chrono::__skip_mandatory_whitespace(__input); | ||
| 539 | string __name = chrono::__parse_string(__input); | ||
| 540 | |||
| 541 | __tz::__rule& __rule = __create_entry(__rules, __name); | ||
| 542 | |||
| 543 | chrono::__skip_mandatory_whitespace(__input); | ||
| 544 | __rule.__from = chrono::__parse_year(__input); | ||
| 545 | chrono::__skip_mandatory_whitespace(__input); | ||
| 546 | __rule.__to = chrono::__parse_to(__input, __rule.__from); | ||
| 547 | chrono::__skip_mandatory_whitespace(__input); | ||
| 548 | chrono::__matches(__input, '-'); | ||
| 549 | chrono::__skip_mandatory_whitespace(__input); | ||
| 550 | __rule.__in = chrono::__parse_month(__input); | ||
| 551 | chrono::__skip_mandatory_whitespace(__input); | ||
| 552 | __rule.__on = chrono::__parse_on(__input); | ||
| 553 | chrono::__skip_mandatory_whitespace(__input); | ||
| 554 | __rule.__at = __parse_at(__input); | ||
| 555 | chrono::__skip_mandatory_whitespace(__input); | ||
| 556 | __rule.__save = __parse_save(__input); | ||
| 557 | chrono::__skip_mandatory_whitespace(__input); | ||
| 558 | __rule.__letters = chrono::__parse_letters(__input); | ||
| 559 | chrono::__skip_line(__input); | ||
| 560 | } | ||
| 561 | |||
| 562 | static void __parse_zone(tzdb& __tzdb, __tz::__rules_storage_type& __rules, istream& __input) { | ||
| 563 | chrono::__skip_mandatory_whitespace(__input); | ||
| 564 | auto __p = std::make_unique<time_zone::__impl>(chrono::__parse_string(__input), __rules); | ||
| 565 | vector<__tz::__continuation>& __continuations = __p->__continuations(); | ||
| 566 | chrono::__skip_mandatory_whitespace(__input); | ||
| 567 | |||
| 568 | do { | ||
| 569 | // The first line must be valid, continuations are optional. | ||
| 570 | __continuations.emplace_back(__parse_continuation(__rules, __input)); | ||
| 571 | chrono::__skip_line(__input); | ||
| 572 | chrono::__skip_optional_whitespace(__input); | ||
| 573 | } while (std::isdigit(__input.peek()) || __input.peek() == '-'); | ||
| 574 | |||
| 575 | __tzdb.zones.emplace_back(time_zone::__create(std::move(__p))); | ||
| 576 | } | ||
| 577 | |||
| 578 | static void __parse_link(tzdb& __tzdb, istream& __input) { | ||
| 579 | chrono::__skip_mandatory_whitespace(__input); | ||
| 580 | string __target = chrono::__parse_string(__input); | ||
| 581 | chrono::__skip_mandatory_whitespace(__input); | ||
| 582 | string __name = chrono::__parse_string(__input); | ||
| 583 | chrono::__skip_line(__input); | ||
| 584 | |||
| 585 | __tzdb.links.emplace_back(std::__private_constructor_tag{}, std::move(__name), std::move(__target)); | ||
| 586 | } | ||
| 587 | |||
| 588 | static void __parse_tzdata(tzdb& __db, __tz::__rules_storage_type& __rules, istream& __input) { | ||
| 589 | while (true) { | ||
| 590 | int __c = std::tolower(__input.get()); | ||
| 591 | |||
| 592 | switch (__c) { | ||
| 593 | case istream::traits_type::eof(): | ||
| 594 | return; | ||
| 595 | |||
| 596 | case ' ': | ||
| 597 | case '\t': | ||
| 598 | case '\n': | ||
| 599 | break; | ||
| 600 | |||
| 601 | case '#': | ||
| 602 | chrono::__skip_line(__input); | ||
| 603 | break; | ||
| 604 | |||
| 605 | case 'r': | ||
| 606 | chrono::__skip(__input, "ule"); | ||
| 607 | chrono::__parse_rule(__db, __rules, __input); | ||
| 608 | break; | ||
| 609 | |||
| 610 | case 'z': | ||
| 611 | chrono::__skip(__input, "one"); | ||
| 612 | chrono::__parse_zone(__db, __rules, __input); | ||
| 613 | break; | ||
| 614 | |||
| 615 | case 'l': | ||
| 616 | chrono::__skip(__input, "ink"); | ||
| 617 | chrono::__parse_link(__db, __input); | ||
| 618 | break; | ||
| 619 | |||
| 620 | default: | ||
| 621 | std::__throw_runtime_error("corrupt tzdb: unexpected input"); | ||
| 622 | } | ||
| 623 | } | ||
| 624 | } | ||
| 625 | |||
| 626 | static void __parse_leap_seconds(vector<leap_second>& __leap_seconds, istream&& __input) { | ||
| 627 | // The file stores dates since 1 January 1900, 00:00:00, we want | ||
| 628 | // seconds since 1 January 1970. | ||
| 629 | constexpr auto __offset = sys_days{1970y / January / 1} - sys_days{1900y / January / 1}; | ||
| 630 | |||
| 631 | struct __entry { | ||
| 632 | sys_seconds __timestamp; | ||
| 633 | seconds __value; | ||
| 634 | }; | ||
| 635 | vector<__entry> __entries; | ||
| 636 | [&] { | ||
| 637 | while (true) { | ||
| 638 | switch (__input.peek()) { | ||
| 639 | case istream::traits_type::eof(): | ||
| 640 | return; | ||
| 641 | |||
| 642 | case ' ': | ||
| 643 | case '\t': | ||
| 644 | case '\n': | ||
| 645 | __input.get(); | ||
| 646 | continue; | ||
| 647 | |||
| 648 | case '#': | ||
| 649 | chrono::__skip_line(__input); | ||
| 650 | continue; | ||
| 651 | } | ||
| 652 | |||
| 653 | sys_seconds __date = sys_seconds{seconds{chrono::__parse_integral(__input, false)}} - __offset; | ||
| 654 | chrono::__skip_mandatory_whitespace(__input); | ||
| 655 | seconds __value{chrono::__parse_integral(__input, false)}; | ||
| 656 | chrono::__skip_line(__input); | ||
| 657 | |||
| 658 | __entries.emplace_back(__date, __value); | ||
| 659 | } | ||
| 660 | }(); | ||
| 661 | // The Standard requires the leap seconds to be sorted. The file | ||
| 662 | // leap-seconds.list usually provides them in sorted order, but that is not | ||
| 663 | // guaranteed so we ensure it here. | ||
| 664 | ranges::sort(__entries, {}, &__entry::__timestamp); | ||
| 665 | |||
| 666 | // The database should contain the number of seconds inserted by a leap | ||
| 667 | // second (1 or -1). So the difference between the two elements is stored. | ||
| 668 | // std::ranges::views::adjacent has not been implemented yet. | ||
| 669 | (void)ranges::adjacent_find(__entries, [&](const __entry& __first, const __entry& __second) { | ||
| 670 | __leap_seconds.emplace_back( | ||
| 671 | std::__private_constructor_tag{}, __second.__timestamp, __second.__value - __first.__value); | ||
| 672 | return false; | ||
| 673 | }); | ||
| 674 | } | ||
| 675 | |||
| 676 | void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { | ||
| 677 | filesystem::path __root = chrono::__libcpp_tzdb_directory(); | ||
| 678 | ifstream __tzdata{__root / "tzdata.zi"}; | ||
| 679 | |||
| 680 | __tzdb.version = chrono::__parse_version(__tzdata); | ||
| 681 | chrono::__parse_tzdata(__tzdb, __rules, __tzdata); | ||
| 682 | ranges::sort(__tzdb.zones); | ||
| 683 | ranges::sort(__tzdb.links); | ||
| 684 | ranges::sort(__rules, {}, [](const auto& p) { return p.first; }); | ||
| 685 | |||
| 686 | // There are two files with the leap second information | ||
| 687 | // - leapseconds as specified by zic | ||
| 688 | // - leap-seconds.list the source data | ||
| 689 | // The latter is much easier to parse, it seems Howard shares that | ||
| 690 | // opinion. | ||
| 691 | chrono::__parse_leap_seconds(__tzdb.leap_seconds, ifstream{__root / "leap-seconds.list"}); | ||
| 692 | } | ||
| 693 | |||
| 694 | #ifdef _WIN32 | ||
| 695 | [[nodiscard]] static const time_zone* __current_zone_windows(const tzdb& tzdb) { | ||
| 696 | // TODO TZDB Implement this on Windows. | ||
| 697 | std::__throw_runtime_error("unknown time zone"); | ||
| 698 | } | ||
| 699 | #else // ifdef _WIN32 | ||
| 700 | [[nodiscard]] static const time_zone* __current_zone_posix(const tzdb& tzdb) { | ||
| 701 | // On POSIX systems there are several ways to configure the time zone. | ||
| 702 | // In order of priority they are: | ||
| 703 | // - TZ environment variable | ||
| 704 | // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08 | ||
| 705 | // The documentation is unclear whether or not it's allowed to | ||
| 706 | // change time zone information. For example the TZ string | ||
| 707 | // MST7MDT | ||
| 708 | // this is an entry in tzdata.zi. The value | ||
| 709 | // MST | ||
| 710 | // is also an entry. Is it allowed to use the following? | ||
| 711 | // MST-3 | ||
| 712 | // Even when this is valid there is no time_zone record in the | ||
| 713 | // database. Since the library would need to return a valid pointer, | ||
| 714 | // this means the library needs to allocate and leak a pointer. | ||
| 715 | // | ||
| 716 | // - The time zone name is the target of the symlink /etc/localtime | ||
| 717 | // relative to /usr/share/zoneinfo/ | ||
| 718 | |||
| 719 | // The algorithm is like this: | ||
| 720 | // - If the environment variable TZ is set and points to a valid | ||
| 721 | // record use this value. | ||
| 722 | // - Else use the name based on the `/etc/localtime` symlink. | ||
| 723 | |||
| 724 | if (const char* __tz = getenv("TZ")) | ||
| 725 | if (const time_zone* __result = tzdb.__locate_zone(__tz)) | ||
| 726 | return __result; | ||
| 727 | |||
| 728 | filesystem::path __path = "/etc/localtime"; | ||
| 729 | if (!filesystem::exists(__path)) | ||
| 730 | std::__throw_runtime_error("tzdb: the symlink '/etc/localtime' does not exist"); | ||
| 731 | |||
| 732 | if (!filesystem::is_symlink(__path)) | ||
| 733 | std::__throw_runtime_error("tzdb: the path '/etc/localtime' is not a symlink"); | ||
| 734 | |||
| 735 | filesystem::path __tz = filesystem::read_symlink(__path); | ||
| 736 | // The path may be a relative path, in that case convert it to an absolute | ||
| 737 | // path based on the proper initial directory. | ||
| 738 | if (__tz.is_relative()) | ||
| 739 | __tz = filesystem::canonical("/etc" / __tz); | ||
| 740 | |||
| 741 | string __name = filesystem::relative(__tz, "/usr/share/zoneinfo/"); | ||
| 742 | if (const time_zone* __result = tzdb.__locate_zone(__name)) | ||
| 743 | return __result; | ||
| 744 | |||
| 745 | std::__throw_runtime_error(("tzdb: the time zone '" + __name + "' is not found in the database").c_str()); | ||
| 746 | } | ||
| 747 | #endif // ifdef _WIN32 | ||
| 748 | |||
| 749 | //===----------------------------------------------------------------------===// | ||
| 750 | // Public API | ||
| 751 | //===----------------------------------------------------------------------===// | ||
| 752 | |||
| 753 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list() { | ||
| 754 | static tzdb_list __result{new tzdb_list::__impl()}; | ||
| 755 | return __result; | ||
| 756 | } | ||
| 757 | |||
| 758 | [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* tzdb::__current_zone() const { | ||
| 759 | #ifdef _WIN32 | ||
| 760 | return chrono::__current_zone_windows(*this); | ||
| 761 | #else | ||
| 762 | return chrono::__current_zone_posix(*this); | ||
| 763 | #endif | ||
| 764 | } | ||
| 765 | |||
| 766 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb() { | ||
| 767 | if (chrono::remote_version() == chrono::get_tzdb().version) | ||
| 768 | return chrono::get_tzdb(); | ||
| 769 | |||
| 770 | return chrono::get_tzdb_list().__implementation().__load(); | ||
| 771 | } | ||
| 772 | |||
| 773 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version() { | ||
| 774 | filesystem::path __root = chrono::__libcpp_tzdb_directory(); | ||
| 775 | ifstream __tzdata{__root / "tzdata.zi"}; | ||
| 776 | return chrono::__parse_version(__tzdata); | ||
| 777 | } | ||
| 778 | |||
| 779 | } // namespace chrono | ||
| 780 | |||
| 781 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/experimental/tzdb_list.cpp created+43| ... | @@ -0,0 +1,43 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | #include <chrono> | ||
| 12 | |||
| 13 | #include "include/tzdb/tzdb_list_private.h" | ||
| 14 | |||
| 15 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 16 | |||
| 17 | namespace chrono { | ||
| 18 | |||
| 19 | _LIBCPP_EXPORTED_FROM_ABI tzdb_list::~tzdb_list() { delete __impl_; } | ||
| 20 | |||
| 21 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const tzdb& tzdb_list::__front() const noexcept { return __impl_->__front(); } | ||
| 22 | |||
| 23 | _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__erase_after(const_iterator __p) { | ||
| 24 | return __impl_->__erase_after(__p); | ||
| 25 | } | ||
| 26 | |||
| 27 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__begin() const noexcept { | ||
| 28 | return __impl_->__begin(); | ||
| 29 | } | ||
| 30 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__end() const noexcept { | ||
| 31 | return __impl_->__end(); | ||
| 32 | } | ||
| 33 | |||
| 34 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__cbegin() const noexcept { | ||
| 35 | return __impl_->__begin(); | ||
| 36 | } | ||
| 37 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__cend() const noexcept { | ||
| 38 | return __impl_->__end(); | ||
| 39 | } | ||
| 40 | |||
| 41 | } // namespace chrono | ||
| 42 | |||
| 43 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/filesystem/operations.cpp+22-19| ... | @@ -109,26 +109,23 @@ void __copy(const path& from, const path& to, copy_options options, error_code* | ... | @@ -109,26 +109,23 @@ void __copy(const path& from, const path& to, copy_options options, error_code* |
| 109 | const bool sym_status2 = bool(options & copy_options::copy_symlinks); | 109 | const bool sym_status2 = bool(options & copy_options::copy_symlinks); |
| 110 | 110 | ||
| 111 | error_code m_ec1; | 111 | error_code m_ec1; |
| 112 | StatT f_st = {}; | 112 | StatT f_st; |
| 113 | const file_status f = | 113 | const file_status f = |
| 114 | sym_status || sym_status2 ? detail::posix_lstat(from, f_st, &m_ec1) : detail::posix_stat(from, f_st, &m_ec1); | 114 | sym_status || sym_status2 ? detail::posix_lstat(from, f_st, &m_ec1) : detail::posix_stat(from, f_st, &m_ec1); |
| 115 | if (m_ec1) | 115 | if (m_ec1) |
| 116 | return err.report(m_ec1); | 116 | return err.report(m_ec1); |
| 117 | 117 | ||
| 118 | StatT t_st = {}; | 118 | StatT t_st; |
| 119 | const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1) : detail::posix_stat(to, t_st, &m_ec1); | 119 | const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1) : detail::posix_stat(to, t_st, &m_ec1); |
| 120 | 120 | ||
| 121 | if (not status_known(t)) | 121 | if (not status_known(t)) |
| 122 | return err.report(m_ec1); | 122 | return err.report(m_ec1); |
| 123 | 123 | ||
| 124 | if (!exists(f) || is_other(f) || is_other(t) || (is_directory(f) && is_regular_file(t)) || | 124 | if (!exists(f) || is_other(f) || is_other(t) || (is_directory(f) && is_regular_file(t)) || |
| 125 | detail::stat_equivalent(f_st, t_st)) { | 125 | (exists(t) && detail::stat_equivalent(f_st, t_st))) { |
| 126 | return err.report(errc::function_not_supported); | 126 | return err.report(errc::function_not_supported); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | if (ec) | ||
| 130 | ec->clear(); | ||
| 131 | |||
| 132 | if (is_symlink(f)) { | 129 | if (is_symlink(f)) { |
| 133 | if (bool(copy_options::skip_symlinks & options)) { | 130 | if (bool(copy_options::skip_symlinks & options)) { |
| 134 | // do nothing | 131 | // do nothing |
| ... | @@ -166,15 +163,15 @@ void __copy(const path& from, const path& to, copy_options options, error_code* | ... | @@ -166,15 +163,15 @@ void __copy(const path& from, const path& to, copy_options options, error_code* |
| 166 | return; | 163 | return; |
| 167 | } | 164 | } |
| 168 | error_code m_ec2; | 165 | error_code m_ec2; |
| 169 | for (; it != directory_iterator(); it.increment(m_ec2)) { | 166 | for (; !m_ec2 && it != directory_iterator(); it.increment(m_ec2)) { |
| 170 | if (m_ec2) { | ||
| 171 | return err.report(m_ec2); | ||
| 172 | } | ||
| 173 | __copy(it->path(), to / it->path().filename(), options | copy_options::__in_recursive_copy, ec); | 167 | __copy(it->path(), to / it->path().filename(), options | copy_options::__in_recursive_copy, ec); |
| 174 | if (ec && *ec) { | 168 | if (ec && *ec) { |
| 175 | return; | 169 | return; |
| 176 | } | 170 | } |
| 177 | } | 171 | } |
| 172 | if (m_ec2) { | ||
| 173 | return err.report(m_ec2); | ||
| 174 | } | ||
| 178 | } | 175 | } |
| 179 | } | 176 | } |
| 180 | 177 | ||
| ... | @@ -815,8 +812,9 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { | ... | @@ -815,8 +812,9 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { |
| 815 | 812 | ||
| 816 | // If opening `p` failed because it wasn't a directory, remove it as | 813 | // If opening `p` failed because it wasn't a directory, remove it as |
| 817 | // a normal file instead. Note that `openat()` can return either ENOTDIR | 814 | // a normal file instead. Note that `openat()` can return either ENOTDIR |
| 818 | // or ELOOP depending on the exact reason of the failure. | 815 | // or ELOOP depending on the exact reason of the failure. On FreeBSD it |
| 819 | if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) { | 816 | // may return EMLINK instead of ELOOP, contradicting POSIX. |
| 817 | if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels || ec == errc::too_many_links) { | ||
| 820 | ec.clear(); | 818 | ec.clear(); |
| 821 | if (::unlinkat(parent_directory, p.c_str(), /* flags = */ 0) == -1) { | 819 | if (::unlinkat(parent_directory, p.c_str(), /* flags = */ 0) == -1) { |
| 822 | ec = detail::capture_errno(); | 820 | ec = detail::capture_errno(); |
| ... | @@ -935,23 +933,28 @@ path __weakly_canonical(const path& p, error_code* ec) { | ... | @@ -935,23 +933,28 @@ path __weakly_canonical(const path& p, error_code* ec) { |
| 935 | --PP; | 933 | --PP; |
| 936 | vector<string_view_t> DNEParts; | 934 | vector<string_view_t> DNEParts; |
| 937 | 935 | ||
| 938 | while (PP.State != PathParser::PS_BeforeBegin) { | 936 | error_code m_ec; |
| 937 | while (PP.State_ != PathParser::PS_BeforeBegin) { | ||
| 939 | tmp.assign(createView(p.native().data(), &PP.RawEntry.back())); | 938 | tmp.assign(createView(p.native().data(), &PP.RawEntry.back())); |
| 940 | error_code m_ec; | ||
| 941 | file_status st = __status(tmp, &m_ec); | 939 | file_status st = __status(tmp, &m_ec); |
| 942 | if (!status_known(st)) { | 940 | if (!status_known(st)) { |
| 943 | return err.report(m_ec); | 941 | return err.report(m_ec); |
| 944 | } else if (exists(st)) { | 942 | } else if (exists(st)) { |
| 945 | result = __canonical(tmp, ec); | 943 | result = __canonical(tmp, &m_ec); |
| 944 | if (m_ec) { | ||
| 945 | return err.report(m_ec); | ||
| 946 | } | ||
| 946 | break; | 947 | break; |
| 947 | } | 948 | } |
| 948 | DNEParts.push_back(*PP); | 949 | DNEParts.push_back(*PP); |
| 949 | --PP; | 950 | --PP; |
| 950 | } | 951 | } |
| 951 | if (PP.State == PathParser::PS_BeforeBegin) | 952 | if (PP.State_ == PathParser::PS_BeforeBegin) { |
| 952 | result = __canonical("", ec); | 953 | result = __canonical("", &m_ec); |
| 953 | if (ec) | 954 | if (m_ec) { |
| 954 | ec->clear(); | 955 | return err.report(m_ec); |
| 956 | } | ||
| 957 | } | ||
| 955 | if (DNEParts.empty()) | 958 | if (DNEParts.empty()) |
| 956 | return result; | 959 | return result; |
| 957 | for (auto It = DNEParts.rbegin(); It != DNEParts.rend(); ++It) | 960 | for (auto It = DNEParts.rbegin(); It != DNEParts.rend(); ++It) |
lib/libcxx/src/filesystem/path.cpp+14-14| ... | @@ -45,23 +45,23 @@ path& path::replace_extension(path const& replacement) { | ... | @@ -45,23 +45,23 @@ path& path::replace_extension(path const& replacement) { |
| 45 | 45 | ||
| 46 | string_view_t path::__root_name() const { | 46 | string_view_t path::__root_name() const { |
| 47 | auto PP = PathParser::CreateBegin(__pn_); | 47 | auto PP = PathParser::CreateBegin(__pn_); |
| 48 | if (PP.State == PathParser::PS_InRootName) | 48 | if (PP.State_ == PathParser::PS_InRootName) |
| 49 | return *PP; | 49 | return *PP; |
| 50 | return {}; | 50 | return {}; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | string_view_t path::__root_directory() const { | 53 | string_view_t path::__root_directory() const { |
| 54 | auto PP = PathParser::CreateBegin(__pn_); | 54 | auto PP = PathParser::CreateBegin(__pn_); |
| 55 | if (PP.State == PathParser::PS_InRootName) | 55 | if (PP.State_ == PathParser::PS_InRootName) |
| 56 | ++PP; | 56 | ++PP; |
| 57 | if (PP.State == PathParser::PS_InRootDir) | 57 | if (PP.State_ == PathParser::PS_InRootDir) |
| 58 | return *PP; | 58 | return *PP; |
| 59 | return {}; | 59 | return {}; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | string_view_t path::__root_path_raw() const { | 62 | string_view_t path::__root_path_raw() const { |
| 63 | auto PP = PathParser::CreateBegin(__pn_); | 63 | auto PP = PathParser::CreateBegin(__pn_); |
| 64 | if (PP.State == PathParser::PS_InRootName) { | 64 | if (PP.State_ == PathParser::PS_InRootName) { |
| 65 | auto NextCh = PP.peek(); | 65 | auto NextCh = PP.peek(); |
| 66 | if (NextCh && isSeparator(*NextCh)) { | 66 | if (NextCh && isSeparator(*NextCh)) { |
| 67 | ++PP; | 67 | ++PP; |
| ... | @@ -69,24 +69,24 @@ string_view_t path::__root_path_raw() const { | ... | @@ -69,24 +69,24 @@ string_view_t path::__root_path_raw() const { |
| 69 | } | 69 | } |
| 70 | return PP.RawEntry; | 70 | return PP.RawEntry; |
| 71 | } | 71 | } |
| 72 | if (PP.State == PathParser::PS_InRootDir) | 72 | if (PP.State_ == PathParser::PS_InRootDir) |
| 73 | return *PP; | 73 | return *PP; |
| 74 | return {}; | 74 | return {}; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | static bool ConsumeRootName(PathParser* PP) { | 77 | static bool ConsumeRootName(PathParser* PP) { |
| 78 | static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2, "Values for enums are incorrect"); | 78 | static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2, "Values for enums are incorrect"); |
| 79 | while (PP->State <= PathParser::PS_InRootName) | 79 | while (PP->State_ <= PathParser::PS_InRootName) |
| 80 | ++(*PP); | 80 | ++(*PP); |
| 81 | return PP->State == PathParser::PS_AtEnd; | 81 | return PP->State_ == PathParser::PS_AtEnd; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | static bool ConsumeRootDir(PathParser* PP) { | 84 | static bool ConsumeRootDir(PathParser* PP) { |
| 85 | static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2 && PathParser::PS_InRootDir == 3, | 85 | static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2 && PathParser::PS_InRootDir == 3, |
| 86 | "Values for enums are incorrect"); | 86 | "Values for enums are incorrect"); |
| 87 | while (PP->State <= PathParser::PS_InRootDir) | 87 | while (PP->State_ <= PathParser::PS_InRootDir) |
| 88 | ++(*PP); | 88 | ++(*PP); |
| 89 | return PP->State == PathParser::PS_AtEnd; | 89 | return PP->State_ == PathParser::PS_AtEnd; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | string_view_t path::__relative_path() const { | 92 | string_view_t path::__relative_path() const { |
| ... | @@ -248,7 +248,7 @@ path path::lexically_relative(const path& base) const { | ... | @@ -248,7 +248,7 @@ path path::lexically_relative(const path& base) const { |
| 248 | auto PP = PathParser::CreateBegin(__pn_); | 248 | auto PP = PathParser::CreateBegin(__pn_); |
| 249 | auto PPBase = PathParser::CreateBegin(base.__pn_); | 249 | auto PPBase = PathParser::CreateBegin(base.__pn_); |
| 250 | auto CheckIterMismatchAtBase = [&]() { | 250 | auto CheckIterMismatchAtBase = [&]() { |
| 251 | return PP.State != PPBase.State && (PP.inRootPath() || PPBase.inRootPath()); | 251 | return PP.State_ != PPBase.State_ && (PP.inRootPath() || PPBase.inRootPath()); |
| 252 | }; | 252 | }; |
| 253 | if (PP.inRootName() && PPBase.inRootName()) { | 253 | if (PP.inRootName() && PPBase.inRootName()) { |
| 254 | if (*PP != *PPBase) | 254 | if (*PP != *PPBase) |
| ... | @@ -267,7 +267,7 @@ path path::lexically_relative(const path& base) const { | ... | @@ -267,7 +267,7 @@ path path::lexically_relative(const path& base) const { |
| 267 | // Find the first mismatching element | 267 | // Find the first mismatching element |
| 268 | auto PP = PathParser::CreateBegin(__pn_); | 268 | auto PP = PathParser::CreateBegin(__pn_); |
| 269 | auto PPBase = PathParser::CreateBegin(base.__pn_); | 269 | auto PPBase = PathParser::CreateBegin(base.__pn_); |
| 270 | while (PP && PPBase && PP.State == PPBase.State && *PP == *PPBase) { | 270 | while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) { |
| 271 | ++PP; | 271 | ++PP; |
| 272 | ++PPBase; | 272 | ++PPBase; |
| 273 | } | 273 | } |
| ... | @@ -380,7 +380,7 @@ path::iterator path::begin() const { | ... | @@ -380,7 +380,7 @@ path::iterator path::begin() const { |
| 380 | auto PP = PathParser::CreateBegin(__pn_); | 380 | auto PP = PathParser::CreateBegin(__pn_); |
| 381 | iterator it; | 381 | iterator it; |
| 382 | it.__path_ptr_ = this; | 382 | it.__path_ptr_ = this; |
| 383 | it.__state_ = static_cast<path::iterator::_ParserState>(PP.State); | 383 | it.__state_ = static_cast<path::iterator::_ParserState>(PP.State_); |
| 384 | it.__entry_ = PP.RawEntry; | 384 | it.__entry_ = PP.RawEntry; |
| 385 | it.__stashed_elem_.__assign_view(*PP); | 385 | it.__stashed_elem_.__assign_view(*PP); |
| 386 | return it; | 386 | return it; |
| ... | @@ -396,7 +396,7 @@ path::iterator path::end() const { | ... | @@ -396,7 +396,7 @@ path::iterator path::end() const { |
| 396 | path::iterator& path::iterator::__increment() { | 396 | path::iterator& path::iterator::__increment() { |
| 397 | PathParser PP(__path_ptr_->native(), __entry_, __state_); | 397 | PathParser PP(__path_ptr_->native(), __entry_, __state_); |
| 398 | ++PP; | 398 | ++PP; |
| 399 | __state_ = static_cast<_ParserState>(PP.State); | 399 | __state_ = static_cast<_ParserState>(PP.State_); |
| 400 | __entry_ = PP.RawEntry; | 400 | __entry_ = PP.RawEntry; |
| 401 | __stashed_elem_.__assign_view(*PP); | 401 | __stashed_elem_.__assign_view(*PP); |
| 402 | return *this; | 402 | return *this; |
| ... | @@ -405,7 +405,7 @@ path::iterator& path::iterator::__increment() { | ... | @@ -405,7 +405,7 @@ path::iterator& path::iterator::__increment() { |
| 405 | path::iterator& path::iterator::__decrement() { | 405 | path::iterator& path::iterator::__decrement() { |
| 406 | PathParser PP(__path_ptr_->native(), __entry_, __state_); | 406 | PathParser PP(__path_ptr_->native(), __entry_, __state_); |
| 407 | --PP; | 407 | --PP; |
| 408 | __state_ = static_cast<_ParserState>(PP.State); | 408 | __state_ = static_cast<_ParserState>(PP.State_); |
| 409 | __entry_ = PP.RawEntry; | 409 | __entry_ = PP.RawEntry; |
| 410 | __stashed_elem_.__assign_view(*PP); | 410 | __stashed_elem_.__assign_view(*PP); |
| 411 | return *this; | 411 | return *this; |
lib/libcxx/src/filesystem/path_parser.h+14-14| ... | @@ -50,14 +50,14 @@ struct PathParser { | ... | @@ -50,14 +50,14 @@ struct PathParser { |
| 50 | 50 | ||
| 51 | const string_view_t Path; | 51 | const string_view_t Path; |
| 52 | string_view_t RawEntry; | 52 | string_view_t RawEntry; |
| 53 | ParserState State; | 53 | ParserState State_; |
| 54 | 54 | ||
| 55 | private: | 55 | private: |
| 56 | PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {} | 56 | PathParser(string_view_t P, ParserState State) noexcept : Path(P), State_(State) {} |
| 57 | 57 | ||
| 58 | public: | 58 | public: |
| 59 | PathParser(string_view_t P, string_view_t E, unsigned char S) | 59 | PathParser(string_view_t P, string_view_t E, unsigned char S) |
| 60 | : Path(P), RawEntry(E), State(static_cast<ParserState>(S)) { | 60 | : Path(P), RawEntry(E), State_(static_cast<ParserState>(S)) { |
| 61 | // S cannot be '0' or PS_BeforeBegin. | 61 | // S cannot be '0' or PS_BeforeBegin. |
| 62 | } | 62 | } |
| 63 | 63 | ||
| ... | @@ -84,7 +84,7 @@ public: | ... | @@ -84,7 +84,7 @@ public: |
| 84 | if (Start == End) | 84 | if (Start == End) |
| 85 | return makeState(PS_AtEnd); | 85 | return makeState(PS_AtEnd); |
| 86 | 86 | ||
| 87 | switch (State) { | 87 | switch (State_) { |
| 88 | case PS_BeforeBegin: { | 88 | case PS_BeforeBegin: { |
| 89 | PosPtr TkEnd = consumeRootName(Start, End); | 89 | PosPtr TkEnd = consumeRootName(Start, End); |
| 90 | if (TkEnd) | 90 | if (TkEnd) |
| ... | @@ -125,7 +125,7 @@ public: | ... | @@ -125,7 +125,7 @@ public: |
| 125 | if (RStart == REnd) // we're decrementing the begin | 125 | if (RStart == REnd) // we're decrementing the begin |
| 126 | return makeState(PS_BeforeBegin); | 126 | return makeState(PS_BeforeBegin); |
| 127 | 127 | ||
| 128 | switch (State) { | 128 | switch (State_) { |
| 129 | case PS_AtEnd: { | 129 | case PS_AtEnd: { |
| 130 | // Try to consume a trailing separator or root directory first. | 130 | // Try to consume a trailing separator or root directory first. |
| 131 | if (PosPtr SepEnd = consumeAllSeparators(RStart, REnd)) { | 131 | if (PosPtr SepEnd = consumeAllSeparators(RStart, REnd)) { |
| ... | @@ -169,7 +169,7 @@ public: | ... | @@ -169,7 +169,7 @@ public: |
| 169 | /// \brief Return a view with the "preferred representation" of the current | 169 | /// \brief Return a view with the "preferred representation" of the current |
| 170 | /// element. For example trailing separators are represented as a '.' | 170 | /// element. For example trailing separators are represented as a '.' |
| 171 | string_view_t operator*() const noexcept { | 171 | string_view_t operator*() const noexcept { |
| 172 | switch (State) { | 172 | switch (State_) { |
| 173 | case PS_BeforeBegin: | 173 | case PS_BeforeBegin: |
| 174 | case PS_AtEnd: | 174 | case PS_AtEnd: |
| 175 | return PATHSTR(""); | 175 | return PATHSTR(""); |
| ... | @@ -187,7 +187,7 @@ public: | ... | @@ -187,7 +187,7 @@ public: |
| 187 | __libcpp_unreachable(); | 187 | __libcpp_unreachable(); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | explicit operator bool() const noexcept { return State != PS_BeforeBegin && State != PS_AtEnd; } | 190 | explicit operator bool() const noexcept { return State_ != PS_BeforeBegin && State_ != PS_AtEnd; } |
| 191 | 191 | ||
| 192 | PathParser& operator++() noexcept { | 192 | PathParser& operator++() noexcept { |
| 193 | increment(); | 193 | increment(); |
| ... | @@ -199,21 +199,21 @@ public: | ... | @@ -199,21 +199,21 @@ public: |
| 199 | return *this; | 199 | return *this; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | bool atEnd() const noexcept { return State == PS_AtEnd; } | 202 | bool atEnd() const noexcept { return State_ == PS_AtEnd; } |
| 203 | 203 | ||
| 204 | bool inRootDir() const noexcept { return State == PS_InRootDir; } | 204 | bool inRootDir() const noexcept { return State_ == PS_InRootDir; } |
| 205 | 205 | ||
| 206 | bool inRootName() const noexcept { return State == PS_InRootName; } | 206 | bool inRootName() const noexcept { return State_ == PS_InRootName; } |
| 207 | 207 | ||
| 208 | bool inRootPath() const noexcept { return inRootName() || inRootDir(); } | 208 | bool inRootPath() const noexcept { return inRootName() || inRootDir(); } |
| 209 | 209 | ||
| 210 | private: | 210 | private: |
| 211 | void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept { | 211 | void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept { |
| 212 | State = NewState; | 212 | State_ = NewState; |
| 213 | RawEntry = string_view_t(Start, End - Start); | 213 | RawEntry = string_view_t(Start, End - Start); |
| 214 | } | 214 | } |
| 215 | void makeState(ParserState NewState) noexcept { | 215 | void makeState(ParserState NewState) noexcept { |
| 216 | State = NewState; | 216 | State_ = NewState; |
| 217 | RawEntry = {}; | 217 | RawEntry = {}; |
| 218 | } | 218 | } |
| 219 | 219 | ||
| ... | @@ -224,7 +224,7 @@ private: | ... | @@ -224,7 +224,7 @@ private: |
| 224 | /// \brief Return a pointer to the first character after the currently | 224 | /// \brief Return a pointer to the first character after the currently |
| 225 | /// lexed element. | 225 | /// lexed element. |
| 226 | PosPtr getNextTokenStartPos() const noexcept { | 226 | PosPtr getNextTokenStartPos() const noexcept { |
| 227 | switch (State) { | 227 | switch (State_) { |
| 228 | case PS_BeforeBegin: | 228 | case PS_BeforeBegin: |
| 229 | return Path.data(); | 229 | return Path.data(); |
| 230 | case PS_InRootName: | 230 | case PS_InRootName: |
| ... | @@ -241,7 +241,7 @@ private: | ... | @@ -241,7 +241,7 @@ private: |
| 241 | /// \brief Return a pointer to the first character in the currently lexed | 241 | /// \brief Return a pointer to the first character in the currently lexed |
| 242 | /// element. | 242 | /// element. |
| 243 | PosPtr getCurrentTokenStartPos() const noexcept { | 243 | PosPtr getCurrentTokenStartPos() const noexcept { |
| 244 | switch (State) { | 244 | switch (State_) { |
| 245 | case PS_BeforeBegin: | 245 | case PS_BeforeBegin: |
| 246 | case PS_InRootName: | 246 | case PS_InRootName: |
| 247 | return &Path.front(); | 247 | return &Path.front(); |
lib/libcxx/src/functional.cpp-2| ... | @@ -10,9 +10,7 @@ | ... | @@ -10,9 +10,7 @@ |
| 10 | 10 | ||
| 11 | _LIBCPP_BEGIN_NAMESPACE_STD | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | ||
| 13 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | ||
| 14 | bad_function_call::~bad_function_call() noexcept {} | 13 | bad_function_call::~bad_function_call() noexcept {} |
| 15 | #endif | ||
| 16 | 14 | ||
| 17 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | 15 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE |
| 18 | const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; } | 16 | const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; } |
lib/libcxx/src/include/overridable_function.h+12-2| ... | @@ -13,6 +13,10 @@ | ... | @@ -13,6 +13,10 @@ |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <cstdint> | 14 | #include <cstdint> |
| 15 | 15 | ||
| 16 | #if __has_feature(ptrauth_calls) | ||
| 17 | # include <ptrauth.h> | ||
| 18 | #endif | ||
| 19 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 21 | # pragma GCC system_header |
| 18 | #endif | 22 | #endif |
| ... | @@ -57,8 +61,6 @@ | ... | @@ -57,8 +61,6 @@ |
| 57 | // This mechanism should never be used outside of the libc++ built library. In particular, | 61 | // This mechanism should never be used outside of the libc++ built library. In particular, |
| 58 | // attempting to use this within the libc++ headers will not work at all because we don't | 62 | // attempting to use this within the libc++ headers will not work at all because we don't |
| 59 | // want to be defining special sections inside user's executables which use our headers. | 63 | // want to be defining special sections inside user's executables which use our headers. |
| 60 | // This is provided inside libc++'s include tree solely to make it easier to share with | ||
| 61 | // libc++abi, which needs the same mechanism. | ||
| 62 | // | 64 | // |
| 63 | 65 | ||
| 64 | #if defined(_LIBCPP_OBJECT_FORMAT_MACHO) | 66 | #if defined(_LIBCPP_OBJECT_FORMAT_MACHO) |
| ... | @@ -81,6 +83,14 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no | ... | @@ -81,6 +83,14 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no |
| 81 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end); | 83 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end); |
| 82 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); | 84 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); |
| 83 | 85 | ||
| 86 | # if __has_feature(ptrauth_calls) | ||
| 87 | // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular, | ||
| 88 | // we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt | ||
| 89 | // to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just | ||
| 90 | // stripped the function pointer. See rdar://122927845. | ||
| 91 | __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer)); | ||
| 92 | # endif | ||
| 93 | |||
| 84 | // Finally, the function was overridden if it falls outside of the section's bounds. | 94 | // Finally, the function was overridden if it falls outside of the section's bounds. |
| 85 | return __ptr < __start || __ptr > __end; | 95 | return __ptr < __start || __ptr > __end; |
| 86 | } | 96 | } |
lib/libcxx/src/ios.cpp+4| ... | @@ -195,6 +195,10 @@ void ios_base::register_callback(event_callback fn, int index) { | ... | @@ -195,6 +195,10 @@ void ios_base::register_callback(event_callback fn, int index) { |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | ios_base::~ios_base() { | 197 | ios_base::~ios_base() { |
| 198 | // Avoid UB when not properly initialized. See ios_base::ios_base for | ||
| 199 | // more information. | ||
| 200 | if (!__loc_) | ||
| 201 | return; | ||
| 198 | __call_callbacks(erase_event); | 202 | __call_callbacks(erase_event); |
| 199 | locale& loc_storage = *reinterpret_cast<locale*>(&__loc_); | 203 | locale& loc_storage = *reinterpret_cast<locale*>(&__loc_); |
| 200 | loc_storage.~locale(); | 204 | loc_storage.~locale(); |
lib/libcxx/src/iostream.cpp+14-22| ... | @@ -21,74 +21,67 @@ | ... | @@ -21,74 +21,67 @@ |
| 21 | 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | _ALIGNAS_TYPE(istream) | 24 | alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)] |
| 25 | _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)] | ||
| 26 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 25 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 27 | __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | 26 | __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR |
| 28 | "@std@@@12@A") | 27 | "@std@@@12@A") |
| 29 | #endif | 28 | #endif |
| 30 | ; | 29 | ; |
| 31 | _ALIGNAS_TYPE(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)]; | 30 | alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)]; |
| 32 | static mbstate_t mb_cin; | 31 | static mbstate_t mb_cin; |
| 33 | 32 | ||
| 34 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 33 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 35 | _ALIGNAS_TYPE(wistream) | 34 | alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)] |
| 36 | _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)] | ||
| 37 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 35 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 38 | __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | 36 | __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| 39 | "@std@@@12@A") | 37 | "@std@@@12@A") |
| 40 | # endif | 38 | # endif |
| 41 | ; | 39 | ; |
| 42 | _ALIGNAS_TYPE(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)]; | 40 | alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)]; |
| 43 | static mbstate_t mb_wcin; | 41 | static mbstate_t mb_wcin; |
| 44 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 42 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 45 | 43 | ||
| 46 | _ALIGNAS_TYPE(ostream) | 44 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)] |
| 47 | _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)] | ||
| 48 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 45 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 49 | __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | 46 | __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR |
| 50 | "@std@@@12@A") | 47 | "@std@@@12@A") |
| 51 | #endif | 48 | #endif |
| 52 | ; | 49 | ; |
| 53 | _ALIGNAS_TYPE(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)]; | 50 | alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)]; |
| 54 | static mbstate_t mb_cout; | 51 | static mbstate_t mb_cout; |
| 55 | 52 | ||
| 56 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 53 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 57 | _ALIGNAS_TYPE(wostream) | 54 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)] |
| 58 | _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)] | ||
| 59 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 55 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 60 | __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | 56 | __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| 61 | "@std@@@12@A") | 57 | "@std@@@12@A") |
| 62 | # endif | 58 | # endif |
| 63 | ; | 59 | ; |
| 64 | _ALIGNAS_TYPE(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; | 60 | alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; |
| 65 | static mbstate_t mb_wcout; | 61 | static mbstate_t mb_wcout; |
| 66 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 62 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 67 | 63 | ||
| 68 | _ALIGNAS_TYPE(ostream) | 64 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)] |
| 69 | _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)] | ||
| 70 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 65 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 71 | __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | 66 | __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR |
| 72 | "@std@@@12@A") | 67 | "@std@@@12@A") |
| 73 | #endif | 68 | #endif |
| 74 | ; | 69 | ; |
| 75 | _ALIGNAS_TYPE(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)]; | 70 | alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)]; |
| 76 | static mbstate_t mb_cerr; | 71 | static mbstate_t mb_cerr; |
| 77 | 72 | ||
| 78 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 73 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 79 | _ALIGNAS_TYPE(wostream) | 74 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)] |
| 80 | _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)] | ||
| 81 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 75 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 82 | __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | 76 | __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| 83 | "@std@@@12@A") | 77 | "@std@@@12@A") |
| 84 | # endif | 78 | # endif |
| 85 | ; | 79 | ; |
| 86 | _ALIGNAS_TYPE(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; | 80 | alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; |
| 87 | static mbstate_t mb_wcerr; | 81 | static mbstate_t mb_wcerr; |
| 88 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | 82 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 89 | 83 | ||
| 90 | _ALIGNAS_TYPE(ostream) | 84 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] |
| 91 | _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] | ||
| 92 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 85 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 93 | __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | 86 | __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR |
| 94 | "@std@@@12@A") | 87 | "@std@@@12@A") |
| ... | @@ -96,8 +89,7 @@ _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] | ... | @@ -96,8 +89,7 @@ _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] |
| 96 | ; | 89 | ; |
| 97 | 90 | ||
| 98 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 91 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 99 | _ALIGNAS_TYPE(wostream) | 92 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)] |
| 100 | _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)] | ||
| 101 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 93 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 102 | __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | 94 | __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| 103 | "@std@@@12@A") | 95 | "@std@@@12@A") |
lib/libcxx/src/locale.cpp+6-8| ... | @@ -34,9 +34,7 @@ | ... | @@ -34,9 +34,7 @@ |
| 34 | # define _CTYPE_DISABLE_MACROS | 34 | # define _CTYPE_DISABLE_MACROS |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) | 37 | #if !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__) && !defined(__BIONIC__) && !defined(__NuttX__) |
| 38 | # include "__support/win32/locale_win32.h" | ||
| 39 | #elif !defined(__BIONIC__) && !defined(__NuttX__) | ||
| 40 | # include <langinfo.h> | 38 | # include <langinfo.h> |
| 41 | #endif | 39 | #endif |
| 42 | 40 | ||
| ... | @@ -104,8 +102,6 @@ inline constexpr size_t countof(const T* const begin, const T* const end) { | ... | @@ -104,8 +102,6 @@ inline constexpr size_t countof(const T* const begin, const T* const end) { |
| 104 | return static_cast<size_t>(end - begin); | 102 | return static_cast<size_t>(end - begin); |
| 105 | } | 103 | } |
| 106 | 104 | ||
| 107 | } // namespace | ||
| 108 | |||
| 109 | string build_name(const string& other, const string& one, locale::category c) { | 105 | string build_name(const string& other, const string& one, locale::category c) { |
| 110 | if (other == "*" || one == "*") | 106 | if (other == "*" || one == "*") |
| 111 | return "*"; | 107 | return "*"; |
| ... | @@ -117,6 +113,8 @@ string build_name(const string& other, const string& one, locale::category c) { | ... | @@ -117,6 +113,8 @@ string build_name(const string& other, const string& one, locale::category c) { |
| 117 | return "*"; | 113 | return "*"; |
| 118 | } | 114 | } |
| 119 | 115 | ||
| 116 | } // namespace | ||
| 117 | |||
| 120 | const locale::category locale::none; | 118 | const locale::category locale::none; |
| 121 | const locale::category locale::collate; | 119 | const locale::category locale::collate; |
| 122 | const locale::category locale::ctype; | 120 | const locale::category locale::ctype; |
| ... | @@ -499,7 +497,7 @@ constinit __no_destroy<locale::__imp> | ... | @@ -499,7 +497,7 @@ constinit __no_destroy<locale::__imp> |
| 499 | locale::__imp::classic_locale_imp_(__uninitialized_tag{}); // initialized below in classic() | 497 | locale::__imp::classic_locale_imp_(__uninitialized_tag{}); // initialized below in classic() |
| 500 | 498 | ||
| 501 | const locale& locale::classic() { | 499 | const locale& locale::classic() { |
| 502 | static const __no_destroy<locale> classic_locale(__private_tag{}, [] { | 500 | static const __no_destroy<locale> classic_locale(__private_constructor_tag{}, [] { |
| 503 | // executed exactly once on first initialization of `classic_locale` | 501 | // executed exactly once on first initialization of `classic_locale` |
| 504 | locale::__imp::classic_locale_imp_.__emplace(1u); | 502 | locale::__imp::classic_locale_imp_.__emplace(1u); |
| 505 | return &locale::__imp::classic_locale_imp_.__get(); | 503 | return &locale::__imp::classic_locale_imp_.__get(); |
| ... | @@ -559,9 +557,9 @@ locale::locale(const locale& other, const locale& one, category c) | ... | @@ -559,9 +557,9 @@ locale::locale(const locale& other, const locale& one, category c) |
| 559 | 557 | ||
| 560 | string locale::name() const { return __locale_->name(); } | 558 | string locale::name() const { return __locale_->name(); } |
| 561 | 559 | ||
| 562 | void locale::__install_ctor(const locale& other, facet* f, long id) { | 560 | void locale::__install_ctor(const locale& other, facet* f, long facet_id) { |
| 563 | if (f) | 561 | if (f) |
| 564 | __locale_ = new __imp(*other.__locale_, f, id); | 562 | __locale_ = new __imp(*other.__locale_, f, facet_id); |
| 565 | else | 563 | else |
| 566 | __locale_ = other.__locale_; | 564 | __locale_ = other.__locale_; |
| 567 | __locale_->acquire(); | 565 | __locale_->acquire(); |
lib/libcxx/src/mutex_destructor.cpp+1-1| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | // _LIBCPP_BUILDING_LIBRARY to change the definition in the headers. | 17 | // _LIBCPP_BUILDING_LIBRARY to change the definition in the headers. |
| 18 | 18 | ||
| 19 | #include <__config> | 19 | #include <__config> |
| 20 | #include <__threading_support> | 20 | #include <__thread/support.h> |
| 21 | 21 | ||
| 22 | #if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) | 22 | #if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) |
| 23 | # define NEEDS_MUTEX_DESTRUCTOR | 23 | # define NEEDS_MUTEX_DESTRUCTOR |
lib/libcxx/src/new.cpp+1| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include "include/overridable_function.h" | 9 | #include "include/overridable_function.h" |
| 10 | #include <__assert> | ||
| 10 | #include <__memory/aligned_alloc.h> | 11 | #include <__memory/aligned_alloc.h> |
| 11 | #include <cstddef> | 12 | #include <cstddef> |
| 12 | #include <cstdlib> | 13 | #include <cstdlib> |
lib/libcxx/src/optional.cpp-1| ... | @@ -6,7 +6,6 @@ | ... | @@ -6,7 +6,6 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__availability> | ||
| 10 | #include <optional> | 9 | #include <optional> |
| 11 | #include <stdexcept> | 10 | #include <stdexcept> |
| 12 | 11 |
lib/libcxx/src/ostream.cpp-1| ... | @@ -6,7 +6,6 @@ | ... | @@ -6,7 +6,6 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__availability> | ||
| 10 | #include <__config> | 9 | #include <__config> |
| 11 | #ifndef _LIBCPP_HAS_NO_FILESYSTEM | 10 | #ifndef _LIBCPP_HAS_NO_FILESYSTEM |
| 12 | # include <fstream> | 11 | # include <fstream> |
lib/libcxx/src/pstl/libdispatch.cpp+3-6| ... | @@ -7,13 +7,12 @@ | ... | @@ -7,13 +7,12 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__algorithm/min.h> | 9 | #include <__algorithm/min.h> |
| 10 | #include <__algorithm/pstl_backends/cpu_backends/libdispatch.h> | ||
| 11 | #include <__config> | 10 | #include <__config> |
| 11 | #include <__pstl/backends/libdispatch.h> | ||
| 12 | #include <dispatch/dispatch.h> | 12 | #include <dispatch/dispatch.h> |
| 13 | 13 | ||
| 14 | _LIBCPP_BEGIN_NAMESPACE_STD | 14 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 15 | 15 | namespace __pstl::__libdispatch { | |
| 16 | namespace __par_backend::inline __libdispatch { | ||
| 17 | 16 | ||
| 18 | void __dispatch_apply(size_t chunk_count, void* context, void (*func)(void* context, size_t chunk)) noexcept { | 17 | void __dispatch_apply(size_t chunk_count, void* context, void (*func)(void* context, size_t chunk)) noexcept { |
| 19 | ::dispatch_apply_f(chunk_count, DISPATCH_APPLY_AUTO, context, func); | 18 | ::dispatch_apply_f(chunk_count, DISPATCH_APPLY_AUTO, context, func); |
| ... | @@ -29,7 +28,5 @@ __chunk_partitions __partition_chunks(ptrdiff_t element_count) noexcept { | ... | @@ -29,7 +28,5 @@ __chunk_partitions __partition_chunks(ptrdiff_t element_count) noexcept { |
| 29 | return partitions; | 28 | return partitions; |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | // NOLINTNEXTLINE(llvm-namespace-comment) // This is https://llvm.org/PR56804 | 31 | } // namespace __pstl::__libdispatch |
| 33 | } // namespace __par_backend::inline __libdispatch | ||
| 34 | |||
| 35 | _LIBCPP_END_NAMESPACE_STD | 32 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/random.cpp+1-1| ... | @@ -80,7 +80,7 @@ unsigned random_device::operator()() { | ... | @@ -80,7 +80,7 @@ unsigned random_device::operator()() { |
| 80 | while (n > 0) { | 80 | while (n > 0) { |
| 81 | ssize_t s = read(__f_, p, n); | 81 | ssize_t s = read(__f_, p, n); |
| 82 | if (s == 0) | 82 | if (s == 0) |
| 83 | __throw_system_error(ENODATA, "random_device got EOF"); | 83 | __throw_system_error(ENOMSG, "random_device got EOF"); |
| 84 | if (s == -1) { | 84 | if (s == -1) { |
| 85 | if (errno != EINTR) | 85 | if (errno != EINTR) |
| 86 | __throw_system_error(errno, "random_device got an unexpected error"); | 86 | __throw_system_error(errno, "random_device got an unexpected error"); |
lib/libcxx/src/support/win32/thread_win32.cpp+1-1| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__threading_support> | 9 | #include <__thread/support/windows.h> |
| 10 | #include <chrono> | 10 | #include <chrono> |
| 11 | 11 | ||
| 12 | #define NOMINMAX | 12 | #define NOMINMAX |
lib/libcxx/src/tz.cpp deleted-148| ... | @@ -1,148 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | #include <chrono> | ||
| 12 | #include <filesystem> | ||
| 13 | #include <fstream> | ||
| 14 | #include <stdexcept> | ||
| 15 | #include <string> | ||
| 16 | |||
| 17 | // Contains a parser for the IANA time zone data files. | ||
| 18 | // | ||
| 19 | // These files can be found at https://data.iana.org/time-zones/ and are in the | ||
| 20 | // public domain. Information regarding the input can be found at | ||
| 21 | // https://data.iana.org/time-zones/tz-how-to.html and | ||
| 22 | // https://man7.org/linux/man-pages/man8/zic.8.html. | ||
| 23 | // | ||
| 24 | // As indicated at https://howardhinnant.github.io/date/tz.html#Installation | ||
| 25 | // For Windows another file seems to be required | ||
| 26 | // https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml | ||
| 27 | // This file seems to contain the mapping of Windows time zone name to IANA | ||
| 28 | // time zone names. | ||
| 29 | // | ||
| 30 | // However this article mentions another way to do the mapping on Windows | ||
| 31 | // https://devblogs.microsoft.com/oldnewthing/20210527-00/?p=105255 | ||
| 32 | // This requires Windows 10 Version 1903, which was released in May of 2019 | ||
| 33 | // and considered end of life in December 2020 | ||
| 34 | // https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1903-end-of-servicing | ||
| 35 | // | ||
| 36 | // TODO TZDB Implement the Windows mapping in tzdb::current_zone | ||
| 37 | |||
| 38 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 39 | |||
| 40 | namespace chrono { | ||
| 41 | |||
| 42 | // This function is weak so it can be overriden in the tests. The | ||
| 43 | // declaration is in the test header test/support/test_tzdb.h | ||
| 44 | _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { | ||
| 45 | #if defined(__linux__) | ||
| 46 | return "/usr/share/zoneinfo/"; | ||
| 47 | #else | ||
| 48 | // Zig patch: change this compilation error into a runtime crash. | ||
| 49 | //# error "unknown path to the IANA Time Zone Database" | ||
| 50 | abort(); | ||
| 51 | #endif | ||
| 52 | } | ||
| 53 | |||
| 54 | [[nodiscard]] static bool __is_whitespace(int __c) { return __c == ' ' || __c == '\t'; } | ||
| 55 | |||
| 56 | static void __skip_optional_whitespace(istream& __input) { | ||
| 57 | while (chrono::__is_whitespace(__input.peek())) | ||
| 58 | __input.get(); | ||
| 59 | } | ||
| 60 | |||
| 61 | static void __skip_mandatory_whitespace(istream& __input) { | ||
| 62 | if (!chrono::__is_whitespace(__input.get())) | ||
| 63 | std::__throw_runtime_error("corrupt tzdb: expected whitespace"); | ||
| 64 | |||
| 65 | chrono::__skip_optional_whitespace(__input); | ||
| 66 | } | ||
| 67 | |||
| 68 | static void __matches(istream& __input, char __expected) { | ||
| 69 | if (std::tolower(__input.get()) != __expected) | ||
| 70 | std::__throw_runtime_error((string("corrupt tzdb: expected character '") + __expected + '\'').c_str()); | ||
| 71 | } | ||
| 72 | |||
| 73 | static void __matches(istream& __input, string_view __expected) { | ||
| 74 | for (auto __c : __expected) | ||
| 75 | if (std::tolower(__input.get()) != __c) | ||
| 76 | std::__throw_runtime_error((string("corrupt tzdb: expected string '") + string(__expected) + '\'').c_str()); | ||
| 77 | } | ||
| 78 | |||
| 79 | [[nodiscard]] static string __parse_string(istream& __input) { | ||
| 80 | string __result; | ||
| 81 | while (true) { | ||
| 82 | int __c = __input.get(); | ||
| 83 | switch (__c) { | ||
| 84 | case ' ': | ||
| 85 | case '\t': | ||
| 86 | case '\n': | ||
| 87 | __input.unget(); | ||
| 88 | [[fallthrough]]; | ||
| 89 | case istream::traits_type::eof(): | ||
| 90 | if (__result.empty()) | ||
| 91 | std::__throw_runtime_error("corrupt tzdb: expected a string"); | ||
| 92 | |||
| 93 | return __result; | ||
| 94 | |||
| 95 | default: | ||
| 96 | __result.push_back(__c); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | static string __parse_version(istream& __input) { | ||
| 102 | // The first line in tzdata.zi contains | ||
| 103 | // # version YYYYw | ||
| 104 | // The parser expects this pattern | ||
| 105 | // #\s*version\s*\(.*) | ||
| 106 | // This part is not documented. | ||
| 107 | chrono::__matches(__input, '#'); | ||
| 108 | chrono::__skip_optional_whitespace(__input); | ||
| 109 | chrono::__matches(__input, "version"); | ||
| 110 | chrono::__skip_mandatory_whitespace(__input); | ||
| 111 | return chrono::__parse_string(__input); | ||
| 112 | } | ||
| 113 | |||
| 114 | static tzdb __make_tzdb() { | ||
| 115 | tzdb __result; | ||
| 116 | |||
| 117 | filesystem::path __root = chrono::__libcpp_tzdb_directory(); | ||
| 118 | ifstream __tzdata{__root / "tzdata.zi"}; | ||
| 119 | |||
| 120 | __result.version = chrono::__parse_version(__tzdata); | ||
| 121 | return __result; | ||
| 122 | } | ||
| 123 | |||
| 124 | //===----------------------------------------------------------------------===// | ||
| 125 | // Public API | ||
| 126 | //===----------------------------------------------------------------------===// | ||
| 127 | |||
| 128 | _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list() { | ||
| 129 | static tzdb_list __result{chrono::__make_tzdb()}; | ||
| 130 | return __result; | ||
| 131 | } | ||
| 132 | |||
| 133 | _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb() { | ||
| 134 | if (chrono::remote_version() == chrono::get_tzdb().version) | ||
| 135 | return chrono::get_tzdb(); | ||
| 136 | |||
| 137 | return chrono::get_tzdb_list().__emplace_front(chrono::__make_tzdb()); | ||
| 138 | } | ||
| 139 | |||
| 140 | _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version() { | ||
| 141 | filesystem::path __root = chrono::__libcpp_tzdb_directory(); | ||
| 142 | ifstream __tzdata{__root / "tzdata.zi"}; | ||
| 143 | return chrono::__parse_version(__tzdata); | ||
| 144 | } | ||
| 145 | |||
| 146 | } // namespace chrono | ||
| 147 | |||
| 148 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/tzdb_list.cpp deleted-113| ... | @@ -1,113 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html | ||
| 10 | |||
| 11 | #include <chrono> | ||
| 12 | |||
| 13 | #include <__mutex/unique_lock.h> | ||
| 14 | #include <forward_list> | ||
| 15 | |||
| 16 | // When threads are not available the locking is not required. | ||
| 17 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 18 | # include <shared_mutex> | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | namespace chrono { | ||
| 24 | |||
| 25 | //===----------------------------------------------------------------------===// | ||
| 26 | // Private API | ||
| 27 | //===----------------------------------------------------------------------===// | ||
| 28 | |||
| 29 | class tzdb_list::__impl { | ||
| 30 | public: | ||
| 31 | explicit __impl(tzdb&& __tzdb) { __tzdb_.push_front(std::move(__tzdb)); } | ||
| 32 | |||
| 33 | using const_iterator = tzdb_list::const_iterator; | ||
| 34 | |||
| 35 | const tzdb& front() const noexcept { | ||
| 36 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 37 | shared_lock __lock{__mutex_}; | ||
| 38 | #endif | ||
| 39 | return __tzdb_.front(); | ||
| 40 | } | ||
| 41 | |||
| 42 | const_iterator erase_after(const_iterator __p) { | ||
| 43 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 44 | unique_lock __lock{__mutex_}; | ||
| 45 | #endif | ||
| 46 | return __tzdb_.erase_after(__p); | ||
| 47 | } | ||
| 48 | |||
| 49 | tzdb& __emplace_front(tzdb&& __tzdb) { | ||
| 50 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 51 | unique_lock __lock{__mutex_}; | ||
| 52 | #endif | ||
| 53 | return __tzdb_.emplace_front(std::move(__tzdb)); | ||
| 54 | } | ||
| 55 | |||
| 56 | const_iterator begin() const noexcept { | ||
| 57 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 58 | shared_lock __lock{__mutex_}; | ||
| 59 | #endif | ||
| 60 | return __tzdb_.begin(); | ||
| 61 | } | ||
| 62 | const_iterator end() const noexcept { | ||
| 63 | // forward_list<T>::end does not access the list, so no need to take a lock. | ||
| 64 | return __tzdb_.end(); | ||
| 65 | } | ||
| 66 | |||
| 67 | const_iterator cbegin() const noexcept { return begin(); } | ||
| 68 | const_iterator cend() const noexcept { return end(); } | ||
| 69 | |||
| 70 | private: | ||
| 71 | #ifndef _LIBCPP_HAS_NO_THREADS | ||
| 72 | mutable shared_mutex __mutex_; | ||
| 73 | #endif | ||
| 74 | forward_list<tzdb> __tzdb_; | ||
| 75 | }; | ||
| 76 | |||
| 77 | //===----------------------------------------------------------------------===// | ||
| 78 | // Public API | ||
| 79 | //===----------------------------------------------------------------------===// | ||
| 80 | |||
| 81 | _LIBCPP_EXPORTED_FROM_ABI tzdb_list::tzdb_list(tzdb&& __tzdb) : __impl_{new __impl(std::move(__tzdb))} {} | ||
| 82 | |||
| 83 | _LIBCPP_EXPORTED_FROM_ABI tzdb_list::~tzdb_list() { delete __impl_; } | ||
| 84 | |||
| 85 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const tzdb& tzdb_list::front() const noexcept { | ||
| 86 | return __impl_->front(); | ||
| 87 | } | ||
| 88 | |||
| 89 | _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::erase_after(const_iterator __p) { | ||
| 90 | return __impl_->erase_after(__p); | ||
| 91 | } | ||
| 92 | |||
| 93 | _LIBCPP_EXPORTED_FROM_ABI tzdb& tzdb_list::__emplace_front(tzdb&& __tzdb) { | ||
| 94 | return __impl_->__emplace_front(std::move(__tzdb)); | ||
| 95 | } | ||
| 96 | |||
| 97 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::begin() const noexcept { | ||
| 98 | return __impl_->begin(); | ||
| 99 | } | ||
| 100 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::end() const noexcept { | ||
| 101 | return __impl_->end(); | ||
| 102 | } | ||
| 103 | |||
| 104 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::cbegin() const noexcept { | ||
| 105 | return __impl_->cbegin(); | ||
| 106 | } | ||
| 107 | _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::cend() const noexcept { | ||
| 108 | return __impl_->cend(); | ||
| 109 | } | ||
| 110 | |||
| 111 | } // namespace chrono | ||
| 112 | |||
| 113 | _LIBCPP_END_NAMESPACE_STD | ||
src/libcxx.zig+1-3| ... | @@ -46,7 +46,7 @@ const libcxx_base_files = [_][]const u8{ | ... | @@ -46,7 +46,7 @@ const libcxx_base_files = [_][]const u8{ |
| 46 | "src/chrono.cpp", | 46 | "src/chrono.cpp", |
| 47 | "src/error_category.cpp", | 47 | "src/error_category.cpp", |
| 48 | "src/exception.cpp", | 48 | "src/exception.cpp", |
| 49 | "src/experimental/keep.cpp", | 49 | "src/expected.cpp", |
| 50 | "src/filesystem/directory_entry.cpp", | 50 | "src/filesystem/directory_entry.cpp", |
| 51 | "src/filesystem/directory_iterator.cpp", | 51 | "src/filesystem/directory_iterator.cpp", |
| 52 | "src/filesystem/filesystem_clock.cpp", | 52 | "src/filesystem/filesystem_clock.cpp", |
| ... | @@ -89,8 +89,6 @@ const libcxx_base_files = [_][]const u8{ | ... | @@ -89,8 +89,6 @@ const libcxx_base_files = [_][]const u8{ |
| 89 | "src/support/win32/support.cpp", | 89 | "src/support/win32/support.cpp", |
| 90 | "src/system_error.cpp", | 90 | "src/system_error.cpp", |
| 91 | "src/typeinfo.cpp", | 91 | "src/typeinfo.cpp", |
| 92 | "src/tz.cpp", | ||
| 93 | "src/tzdb_list.cpp", | ||
| 94 | "src/valarray.cpp", | 92 | "src/valarray.cpp", |
| 95 | "src/variant.cpp", | 93 | "src/variant.cpp", |
| 96 | "src/vector.cpp", | 94 | "src/vector.cpp", |